-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 3.0.0
-
Component/s: BSON, Documentation, Implementation
-
None
We're in the process of testing conversion of our code base from the legacy C++ driver to the 3.0 driver.
In the legacy driver, it's a common use case to use the BSONObjBuilder's appendTimeT() function, which accepts a time_t.
The closest analog to this in the 3.0 driver appears to be bsoncxx::types::b_date class, which accepts either an int64 or a std::chrono::system_clock::time_point.
Neither of these are actually what you want when you've got a std::time_t, but it's not unreasonable for someone performing this conversion to hand the class a time_t, which will compile without issue or warning, and which results in Bad Things happening.
It might be advantageous to at the least note in the documentation or porting notes that if one is moving from the legacy driver, then use of std::chrono::system_clock::from_time_t to get a time_point is one option here.