summaryrefslogtreecommitdiffstats
path: root/crypto/nss_util.cc
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 20:37:28 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 20:37:28 +0000
commitca929ed34121d8f90788f16dfd1fe555bb5701ae (patch)
treed4aedc59332c18e21c2368f9006fa92e1bf44b65 /crypto/nss_util.cc
parentb95b08d0da727df948ecbd8d3bebe4ecb09b97d5 (diff)
downloadchromium_src-ca929ed34121d8f90788f16dfd1fe555bb5701ae.zip
chromium_src-ca929ed34121d8f90788f16dfd1fe555bb5701ae.tar.gz
chromium_src-ca929ed34121d8f90788f16dfd1fe555bb5701ae.tar.bz2
Reland: Simplify PRTimeToBaseTime implementation, add BaseTimeToPRTime.
BUG=107047 TEST=crypto_unittests TBR=wtc@chromium.org Review URL: http://codereview.chromium.org/8956003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto/nss_util.cc')
-rw-r--r--crypto/nss_util.cc22
1 files changed, 6 insertions, 16 deletions
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
index 53602c3..2540c0c 100644
--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -769,23 +769,13 @@ SymmetricKey* GetSupplementalUserKey() {
}
#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) {
- PRExplodedTime prxtime;
- PR_ExplodeTime(prtime, PR_GMTParameters, &prxtime);
-
- 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);
+ return base::Time::FromInternalValue(
+ prtime + base::Time::UnixEpoch().ToInternalValue());
+}
+
+PRTime BaseTimeToPRTime(base::Time time) {
+ return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue();
}
PK11SlotInfo* GetPublicNSSKeySlot() {