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

Unified Diff: crypto/nss_util.cc

Issue 8913018: Revert 114499 - Simplify PRTimeToBaseTime implementation, add BaseTimeToPRTime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | « crypto/nss_util.h ('k') | crypto/nss_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/nss_util.cc
===================================================================
--- crypto/nss_util.cc (revision 114522)
+++ crypto/nss_util.cc (working copy)
@@ -769,13 +769,23 @@
}
#endif // defined(OS_CHROMEOS)
+// TODO(port): Implement this more simply. We can convert by subtracting an
+// offset (the difference between NSPR's and base::Time's epochs).
base::Time PRTimeToBaseTime(PRTime prtime) {
- return base::Time::FromInternalValue(
- prtime + base::Time::UnixEpoch().ToInternalValue());
-}
+ PRExplodedTime prxtime;
+ PR_ExplodeTime(prtime, PR_GMTParameters, &prxtime);
-PRTime BaseTimeToPRTime(base::Time time) {
- return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue();
+ base::Time::Exploded exploded;
+ exploded.year = prxtime.tm_year;
+ exploded.month = prxtime.tm_month + 1;
+ exploded.day_of_week = prxtime.tm_wday;
+ exploded.day_of_month = prxtime.tm_mday;
+ exploded.hour = prxtime.tm_hour;
+ exploded.minute = prxtime.tm_min;
+ exploded.second = prxtime.tm_sec;
+ exploded.millisecond = prxtime.tm_usec / 1000;
+
+ return base::Time::FromUTCExploded(exploded);
}
PK11SlotInfo* GetPublicNSSKeySlot() {
« no previous file with comments | « crypto/nss_util.h ('k') | crypto/nss_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698