-
Type: New Feature
-
Resolution: Done
-
Priority: Trivial - P5
-
Affects Version/s: None
-
Component/s: Internal Client, Usability
-
None
A small enhancement just to be able to do:
BSONObj o = BSON("date" << std::time(0));
Currently, we have to manipulate BSONObjBuilder::appendDate() in order to append a date from a std::time_t.
There is no append() overload which takes an unsigned long long (in the case we would like to cast std::time_t)
diff --git a/db/jsobj.h b/db/jsobj.h
index 3afc916..8783f5e 100644
— a/db/jsobj.h
+++ b/db/jsobj.h
@@ -1167,6 +1167,13 @@ namespace mongo
+
+ /** Append a date from a std::time_t */
+ void append(const char *fieldName, std::time_t dt)
/** Append a BSON Object ID (OID type). */
void appendOID(const char *fieldName, OID *oid = 0 , bool generateIfBlank = false ) {