Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bson/bson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ var allItems = []testItemType{
"\x08_\x00\x00"},
{bson.M{"_": true},
"\x08_\x00\x01"},
{bson.M{"_": time.Unix(0, 258e6)}, // Note the NS <=> MS conversion.
{bson.M{"_": time.Unix(0, 258e6).UTC()}, // Note the NS <=> MS conversion.
"\x09_\x00\x02\x01\x00\x00\x00\x00\x00\x00"},
{bson.M{"_": nil},
"\x0A_\x00"},
Expand Down Expand Up @@ -1265,7 +1265,7 @@ var twoWayCrossItems = []crossTypeItem{
{&condPtr{&falsevar}, map[string]bool{"v": false}},
{&condPtr{}, map[string]string{}},

{&condTime{time.Unix(123456789, 123e6)}, map[string]time.Time{"v": time.Unix(123456789, 123e6)}},
{&condTime{time.Unix(123456789, 123e6).UTC()}, map[string]time.Time{"v": time.Unix(123456789, 123e6).UTC()}},
{&condTime{}, map[string]string{}},

{&condStruct{struct{ A []int }{[]int{1}}}, bson.M{"v": bson.M{"a": []interface{}{1}}}},
Expand Down Expand Up @@ -1320,8 +1320,8 @@ var twoWayCrossItems = []crossTypeItem{
{&struct{ V time.Time }{}, map[string]interface{}{"v": time.Time{}}},

// zero time + 1 second + 1 millisecond; overflows int64 as nanoseconds
{&struct{ V time.Time }{time.Unix(-62135596799, 1e6).Local()},
map[string]interface{}{"v": time.Unix(-62135596799, 1e6).Local()}},
{&struct{ V time.Time }{time.Unix(-62135596799, 1e6).UTC()},
map[string]interface{}{"v": time.Unix(-62135596799, 1e6).UTC()}},

// bson.D <=> []DocElem
{&bson.D{{"a", bson.D{{"b", 1}, {"c", 2}}}}, &bson.D{{"a", bson.D{{"b", 1}, {"c", 2}}}}},
Expand Down
2 changes: 1 addition & 1 deletion bson/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func (d *decoder) readElemTo(out reflect.Value, kind byte) (good bool) {
if i == -62135596800000 {
in = time.Time{} // In UTC for convenience.
} else {
in = time.Unix(i/1e3, i%1e3*1e6)
in = time.Unix(i/1e3, i%1e3*1e6).UTC()
}
case 0x0A: // Nil
in = nil
Expand Down