[GODRIVER-1181] Using only UnixNano to convert time.Time to MongoDB Datetimes misses large amounts of possible datetimes Created: 02/Jul/19  Updated: 07/Aug/20  Resolved: 07/Aug/20

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Patrick Meredith Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: jeff-close
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to GODRIVER-983 extjson date parser doesn't work for ... Closed

 Description   

https://github.com/mongodb/mongo-go-driver/search?q=UnixNano&unscoped_q=UnixNano

Using UnixNano results in underflow for large and small dates (dates sufficiently far from January 1st, 1970). The following calculation should be used instead:

return t.Unix()*1000 + int64(t.Nanosecond()/1e6)


Generated at Thu Feb 08 08:35:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.