Chromium Code Reviews| Index: base/third_party/nspr/prtime.cc |
| diff --git a/base/third_party/nspr/prtime.cc b/base/third_party/nspr/prtime.cc |
| index a7c5a3a949680ae87541d86e8c032a9fb432eab5..525ee602d62a777788fdc3c7603ecfbdba1bf877 100644 |
| --- a/base/third_party/nspr/prtime.cc |
| +++ b/base/third_party/nspr/prtime.cc |
| @@ -73,6 +73,7 @@ |
| #include <windows.h> |
| #elif defined(OS_MACOSX) |
| #include <CoreFoundation/CoreFoundation.h> |
| +#include "base/mac/scoped_cftyperef.h" |
| #elif defined(OS_ANDROID) |
| #include <ctype.h> |
| #include "base/os_compat_android.h" // For timegm() |
| @@ -138,20 +139,23 @@ PR_ImplodeTime(const PRExplodedTime *exploded) |
| result += exploded->tm_usec % 1000; |
| return result; |
| #elif defined(OS_MACOSX) |
| - // Create the system struct representing our exploded time. |
| - CFGregorianDate gregorian_date; |
| - gregorian_date.year = exploded->tm_year; |
| - gregorian_date.month = exploded->tm_month + 1; |
| - gregorian_date.day = exploded->tm_mday; |
| - gregorian_date.hour = exploded->tm_hour; |
| - gregorian_date.minute = exploded->tm_min; |
| - gregorian_date.second = exploded->tm_sec; |
| - |
| // Compute |absolute_time| in seconds, correct for gmt and dst |
| // (note the combined offset will be negative when we need to add it), then |
| // convert to microseconds which is what PRTime expects. |
| - CFAbsoluteTime absolute_time = |
| - CFGregorianDateGetAbsoluteTime(gregorian_date, NULL); |
| + base::ScopedCFTypeRef<CFCalendarRef> gregorian( |
| + CFCalendarCreateWithIdentifier(kCFAllocatorDefault, |
| + kCFGregorianCalendar)); |
| + base::ScopedCFTypeRef<CFTimeZoneRef> time_zone( |
| + CFTimeZoneCreateWithTimeIntervalFromGMT(kCFAllocatorDefault, 0)); |
| + CFCalendarSetTimeZone(gregorian, time_zone); |
| + CFAbsoluteTime absolute_time; |
| + CFCalendarComposeAbsoluteTime(gregorian, &absolute_time, "yMdHms", |
| + static_cast<int>(exploded->tm_year), |
| + static_cast<int>(exploded->tm_month + 1), |
| + static_cast<int>(exploded->tm_mday), |
| + static_cast<int>(exploded->tm_hour), |
| + static_cast<int>(exploded->tm_min), |
|
Nico
2015/12/04 20:18:59
I looked at upstream NSPR to see if they have this
pkl (ping after 24h if needed)
2016/02/03 06:42:31
This change has been moved to https://codereview.c
|
| + static_cast<int>(exploded->tm_sec)); |
| PRTime result = static_cast<PRTime>(absolute_time); |
| result -= exploded->tm_params.tp_gmt_offset + |
| exploded->tm_params.tp_dst_offset; |