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 30
30
#define UCHAR_TYPE wchar_t
31
31
#include < icu.h>
32
32
#elif FIREBASE_PLATFORM_LINUX
33
+ #include < stdio.h>
34
+
33
35
#include < clocale>
34
36
#include < ctime>
35
37
#else
@@ -180,6 +182,20 @@ std::string GetTimezone() {
180
182
return iana_tz_utf8;
181
183
182
184
#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
+ }
183
199
// If TZ environment variable is defined and not empty, use it, else use
184
200
// tzname.
185
201
return (getenv (" TZ" ) && *getenv (" TZ" )) ? getenv (" TZ" )
You can’t perform that action at this time.
0 commit comments