summaryrefslogtreecommitdiff
path: root/src/mongo/bson/bsonobjbuilder.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-05-07 16:45:29 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-05-13 17:58:55 -0400
commit532dfe1180c2da552bebed70af1e7fba34cf355c (patch)
tree9fb15c1576003307169bd249db500ad1aee21d99 /src/mongo/bson/bsonobjbuilder.cpp
parentcd97edbe4be0e6ddc9139a21e13594fd19a26a5e (diff)
downloadmongo-532dfe1180c2da552bebed70af1e7fba34cf355c.tar.gz
SERVER-13874 Make mongo::Milliseconds et al. aliases for equivalent stdx::chrono types.
Also introduces operators for adding stdx::chrono::duration to Date_t, subtracting two Date_ts to get Milliseconds, and remove the use of reinterpret_cast from the implementation of BSON Timestamp type.
Diffstat (limited to 'src/mongo/bson/bsonobjbuilder.cpp')
-rw-r--r--src/mongo/bson/bsonobjbuilder.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/mongo/bson/bsonobjbuilder.cpp b/src/mongo/bson/bsonobjbuilder.cpp
index d0fd2665ff3..a9878b28adc 100644
--- a/src/mongo/bson/bsonobjbuilder.cpp
+++ b/src/mongo/bson/bsonobjbuilder.cpp
@@ -109,7 +109,9 @@ namespace mongo {
case String:
appendMinForType( fieldName, Object ); return;
case Date:
- appendDate( fieldName , std::numeric_limits<long long>::max() ); return;
+ appendDate(fieldName,
+ Date_t::fromMillisSinceEpoch(std::numeric_limits<long long>::max()));
+ return;
case bsonTimestamp:
append( fieldName , Timestamp::max() ); return;
case Undefined: // shared with EOO
@@ -196,16 +198,9 @@ namespace mongo {
}
BSONObjBuilder& BSONObjBuilder::appendDate(StringData fieldName, Date_t dt) {
- /* easy to pass a time_t to this and get a bad result. thus this warning. */
- if ( kDebugBuild && dt > 0 && dt <= 0xffffffff ) {
- static int n;
- if( n++ == 0 )
- log() << "DEV WARNING appendDate() called with a tiny (but nonzero) date" << std::endl;
- }
-
_b.appendNum((char) Date);
_b.appendStr(fieldName);
- _b.appendNum(dt);
+ _b.appendNum(dt.toMillisSinceEpoch());
return *this;
}