Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(992)

Unified Diff: base/third_party/nspr/prtime.cc

Issue 1494083005: Replaces deprecated CFGregorianDate with CFCalendar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved mac include file Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/time/time_mac.cc » ('j') | base/time/time_mac.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | base/time/time_mac.cc » ('j') | base/time/time_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698