diff --git a/runtime/vm/os_android.cc b/runtime/vm/os_android.cc index 5547201ae105..e9fc73ced95b 100644 --- a/runtime/vm/os_android.cc +++ b/runtime/vm/os_android.cc @@ -102,6 +102,9 @@ intptr_t OS::ProcessId() { static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { time_t seconds = static_cast(seconds_since_epoch); if (seconds != seconds_since_epoch) return false; + // No need to call tzset() before localtime_r() because bionic + // will handle timezone changes for us (starting from Android O). + // See https://android.googlesource.com/platform/bionic/+/ea87716696bf635706b6f3fa56b8a145add83aff struct tm* error_code = localtime_r(&seconds, tm_result); return error_code != nullptr; } diff --git a/runtime/vm/os_linux.cc b/runtime/vm/os_linux.cc index a09fbfddc448..8bdfda024d31 100644 --- a/runtime/vm/os_linux.cc +++ b/runtime/vm/os_linux.cc @@ -418,6 +418,7 @@ intptr_t OS::ProcessId() { static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) { time_t seconds = static_cast(seconds_since_epoch); if (seconds != seconds_since_epoch) return false; + tzset(); // Not guaranteed by POSIX to be called by `localtime_r`. struct tm* error_code = localtime_r(&seconds, tm_result); return error_code != nullptr; }