Skip to content

Commit b8c93ac

Browse files
committed
Fixed converting microseconds in bson.EC.Time
1 parent 545effe commit b8c93ac

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bson/constructor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ func (ElementConstructor) DateTime(key string, dt int64) *Element {
342342

343343
// Time creates a datetime element with the given key and value.
344344
func (c ElementConstructor) Time(key string, time time.Time) *Element {
345-
return c.DateTime(key, time.Unix()*1000)
345+
// Apply nanoseconds to milliseconds conversion
346+
return c.DateTime(key, time.UnixNano()/1000000)
346347
}
347348

348349
// Null creates a null element with the given key.

0 commit comments

Comments
 (0)