summaryrefslogtreecommitdiffstats
path: root/crypto/nss_util.cc
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-14 23:16:00 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-14 23:16:00 +0000
commit390d037275969c9902f3df0d475c3dd83b980a59 (patch)
tree3a20a5b21c770ef72c3eb8e4a84b2a7205b9e0b5 /crypto/nss_util.cc
parent7f18e945afc5c93ad9937e8f36990ce46a0f4170 (diff)
downloadchromium_src-390d037275969c9902f3df0d475c3dd83b980a59.zip
chromium_src-390d037275969c9902f3df0d475c3dd83b980a59.tar.gz
chromium_src-390d037275969c9902f3df0d475c3dd83b980a59.tar.bz2
Revert 114499 - Simplify PRTimeToBaseTime implementation, add BaseTimeToPRTime.
BUG=107047 TEST=crypto_unittests Review URL: http://codereview.chromium.org/8894023 TBR=mattm@chromium.org Review URL: http://codereview.chromium.org/8913018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto/nss_util.cc')
-rw-r--r--crypto/nss_util.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
index 2540c0c..53602c3 100644
--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -769,13 +769,23 @@ 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) {
- return base::Time::FromInternalValue(
- prtime + base::Time::UnixEpoch().ToInternalValue());
-}
-
-PRTime BaseTimeToPRTime(base::Time time) {
- return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue();
+ 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);
}
PK11SlotInfo* GetPublicNSSKeySlot() {