File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 3030#define UCHAR_TYPE wchar_t
3131#include < icu.h>
3232#elif FIREBASE_PLATFORM_LINUX
33+ #include < stdio.h>
34+
3335#include < clocale>
3436#include < ctime>
3537#else
@@ -180,6 +182,20 @@ std::string GetTimezone() {
180182 return iana_tz_utf8;
181183
182184#elif FIREBASE_PLATFORM_LINUX
185+ // Ubuntu: Check /etc/timezone for the full time zone name.
186+ FILE* tz_file = fopen (" /etc/timezone" , " r" );
187+ if (tz_file) {
188+ const size_t kBufSize = 128 ;
189+ char buf[kBufSize ];
190+ if (fgets (buf, kBufSize , tz_file)) {
191+ // Remove a trailing '\n', if any.
192+ size_t len = strlen (buf);
193+ if (buf[len - 1 ] == ' \n ' ) {
194+ buf[len - 1 ] = ' \0 ' ;
195+ }
196+ return std::string (buf);
197+ }
198+ }
183199 // If TZ environment variable is defined and not empty, use it, else use
184200 // tzname.
185201 return (getenv (" TZ" ) && *getenv (" TZ" )) ? getenv (" TZ" )
You can’t perform that action at this time.
0 commit comments