Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Jan 27, 2025
1 parent feaeee5 commit 7ff1dff
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/typing/mongo/bson.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,19 @@ func bsonBinaryValueToMap(value primitive.Binary) (any, error) {
func bsonValueToGoValue(value any) (any, error) {
switch v := value.(type) {
case primitive.DateTime:
return v.Time().UTC(), nil
dt := v.Time().UTC()
if dt.Year() > 9999 {
return nil, nil
}

return dt, nil
case primitive.Timestamp:
return time.Unix(int64(v.T), 0).UTC(), nil
ts := time.Unix(int64(v.T), 0).UTC()
if ts.Year() > 9999 {
return nil, nil
}

return ts, nil
case primitive.ObjectID:
return v.Hex(), nil
case primitive.Binary:
Expand Down

0 comments on commit 7ff1dff

Please sign in to comment.