File tree Expand file tree Collapse file tree 2 files changed +4
-0
lines changed Expand file tree Collapse file tree 2 files changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,9 @@ intptr_t OS::ProcessId() {
102
102
static bool LocalTime (int64_t seconds_since_epoch, tm* tm_result) {
103
103
time_t seconds = static_cast <time_t >(seconds_since_epoch);
104
104
if (seconds != seconds_since_epoch) return false ;
105
+ // No need to call tzset() before localtime_r() because bionic
106
+ // will handle timezone changes for us (starting from Android O).
107
+ // See https://android.googlesource.com/platform/bionic/+/ea87716696bf635706b6f3fa56b8a145add83aff
105
108
struct tm * error_code = localtime_r (&seconds, tm_result);
106
109
return error_code != nullptr ;
107
110
}
Original file line number Diff line number Diff line change @@ -418,6 +418,7 @@ intptr_t OS::ProcessId() {
418
418
static bool LocalTime (int64_t seconds_since_epoch, tm* tm_result) {
419
419
time_t seconds = static_cast <time_t >(seconds_since_epoch);
420
420
if (seconds != seconds_since_epoch) return false ;
421
+ tzset (); // Not guaranteed by POSIX to be called by `localtime_r`.
421
422
struct tm * error_code = localtime_r (&seconds, tm_result);
422
423
return error_code != nullptr ;
423
424
}
You can’t perform that action at this time.
0 commit comments