Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
-
None
Description
When using the msSinceEpoch initializer in our BSONValue extension of Date, some precision is lost. This initializer is used by the from method, so we can see the error when retrieving Date s from a document.
e.g.
let d: Document = ["a": Date(timeIntervalSince1970: 0.001)]
|
expect(d["a"] as? Date).to(equal(Date(timeIntervalSince1970: 0.001)))
|
Fails with:
expected to equal <1969-12-31 19:00:00.0010>, got <1969-12-31 19:00:00.0000>
There is also a loss of precision in theĀ msSinceEpoch computed property, as it simply truncates as opposed to rounding.