summaryrefslogtreecommitdiff
path: root/src/mongo/bson/bsonelement.cpp
diff options
context:
space:
mode:
authorPavithra Vetriselvan <pavithra.vetriselvan@mongodb.com>2017-11-16 14:45:53 -0500
committerPavithra Vetriselvan <pavithra.vetriselvan@mongodb.com>2017-11-16 14:59:12 -0500
commitfcf3ce24838425eda2d9b2aeb21be5b272d3eb6b (patch)
tree66a3db0578dc0630afe86efc8b2ef6c706a7c209 /src/mongo/bson/bsonelement.cpp
parentb0ef90bc3495561fe1cba07b1a8d7f8e20b3a564 (diff)
downloadmongo-fcf3ce24838425eda2d9b2aeb21be5b272d3eb6b.tar.gz
SERVER-27814 Prints Timestamp consistently, changes toString(), and removes toStringLong()
(cherry picked from commit 3248ccbff8078af7351ee39dda30f77a158fe7a6)
Diffstat (limited to 'src/mongo/bson/bsonelement.cpp')
-rw-r--r--src/mongo/bson/bsonelement.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp
index 416865d6f04..3a4e754fa31 100644
--- a/src/mongo/bson/bsonelement.cpp
+++ b/src/mongo/bson/bsonelement.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/platform/strnlen.h"
#include "mongo/util/base64.h"
+#include "mongo/util/duration.h"
#include "mongo/util/hex.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
@@ -878,9 +879,11 @@ void BSONElement::toString(
}
} break;
- case bsonTimestamp:
- s << "Timestamp " << timestampTime().toMillisSinceEpoch() << "|" << timestampInc();
- break;
+ case bsonTimestamp: {
+ // Convert from Milliseconds to Seconds for consistent Timestamp printing.
+ auto secs = duration_cast<Seconds>(timestampTime().toDurationSinceEpoch());
+ s << "Timestamp(" << secs.count() << ", " << timestampInc() << ")";
+ } break;
default:
s << "?type=" << type();
break;