summaryrefslogtreecommitdiff
path: root/src/mongo/util/time_support.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-05-14 17:22:29 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-05-15 11:10:57 -0400
commit2518e60c495a700cbb44237425ecf064db970dbd (patch)
tree60806c821a19a1f97d7e766771cc6297440205df /src/mongo/util/time_support.cpp
parent5b1bb5cf93b3e15393ea9118602d3d72e9703fff (diff)
downloadmongo-2518e60c495a700cbb44237425ecf064db970dbd.tar.gz
SERVER-13874 Support converting Date_t to system_clock::time_point and back.
Diffstat (limited to 'src/mongo/util/time_support.cpp')
-rw-r--r--src/mongo/util/time_support.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/util/time_support.cpp b/src/mongo/util/time_support.cpp
index 4c588d39071..57eefa80775 100644
--- a/src/mongo/util/time_support.cpp
+++ b/src/mongo/util/time_support.cpp
@@ -126,6 +126,13 @@ namespace {
return fromMillisSinceEpoch(curTimeMillis64());
}
+ Date_t::Date_t(stdx::chrono::system_clock::time_point tp) :
+ millis(durationCount<Milliseconds>(tp - stdx::chrono::system_clock::from_time_t(0))) {}
+
+ stdx::chrono::system_clock::time_point Date_t::toSystemTimePoint() const {
+ return stdx::chrono::system_clock::from_time_t(0) + toDurationSinceEpoch();
+ }
+
bool Date_t::isFormattable() const {
if (millis < 0) {
return false;