Chromium Code Reviews| Index: base/time/time_posix.cc | 
| diff --git a/base/time/time_posix.cc b/base/time/time_posix.cc | 
| index 2cceb0c610c27cd65f5797aec1e0547dd4888d41..f83880f0c623da4f9b224d5d8c5d18e8fabde604 100644 | 
| --- a/base/time/time_posix.cc | 
| +++ b/base/time/time_posix.cc | 
| @@ -61,6 +61,49 @@ void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) { | 
| gmtime64_r(&t, timestruct); | 
| } | 
| +#elif defined(OS_AIX) | 
| + | 
| +// timegm is not available on AIX | 
| +// we should perhaps use a more portable alternative | 
| 
 
Nico
2017/04/25 18:50:40
Use sentence case for comments. Remove second line
 
rayb
2017/04/25 22:40:17
That was just a leftover comment. Sorry about that
 
 | 
| +time_t aix_timegm(struct tm* tm) { | 
| + time_t ret; | 
| + char* tz; | 
| + | 
| + tz = getenv("TZ"); | 
| + if (tz) { | 
| + tz = strdup(tz); | 
| + } | 
| + setenv("TZ", "GMT0", 1); | 
| + tzset(); | 
| + ret = mktime(tm); | 
| + if (tz) { | 
| + setenv("TZ", tz, 1); | 
| + free(tz); | 
| + } else { | 
| + unsetenv("TZ"); | 
| + } | 
| + tzset(); | 
| + return ret; | 
| +} | 
| + | 
| +typedef time_t SysTime; | 
| + | 
| +SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) { | 
| + base::AutoLock locked(*GetSysTimeToTimeStructLock()); | 
| + if (is_local) | 
| + return mktime(timestruct); | 
| + else | 
| + return aix_timegm(timestruct); | 
| +} | 
| + | 
| +void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) { | 
| + base::AutoLock locked(*GetSysTimeToTimeStructLock()); | 
| + if (is_local) | 
| + localtime_r(&t, timestruct); | 
| + else | 
| + gmtime_r(&t, timestruct); | 
| +} | 
| + | 
| #else // OS_ANDROID && !__LP64__ | 
| typedef time_t SysTime; | 
| @@ -248,7 +291,7 @@ bool Time::FromExploded(bool is_local, const Exploded& exploded, Time* time) { | 
| timestruct.tm_wday = exploded.day_of_week; // mktime/timegm ignore this | 
| timestruct.tm_yday = 0; // mktime/timegm ignore this | 
| timestruct.tm_isdst = -1; // attempt to figure it out | 
| -#if !defined(OS_NACL) && !defined(OS_SOLARIS) | 
| +#if !defined(OS_NACL) && !defined(OS_SOLARIS) && !defined(OS_AIX) | 
| timestruct.tm_gmtoff = 0; // not a POSIX field, so mktime/timegm ignore | 
| timestruct.tm_zone = NULL; // not a POSIX field, so mktime/timegm ignore | 
| #endif |