-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: BSON
-
None
-
Minor Change
When a Time is encoded to bson and decoded the result is a UTC time:
irb(main):008:0> Time.now => 2020-03-04 14:40:18.04943667 -0500 irb(main):009:0> Time.now.to_bson => #<BSON::ByteBuffer:0x0000557ab847d370> irb(main):010:0> Time.from_bson(Time.now.to_bson) => 2020-03-04 19:40:26.553 UTC
When a Time is encoded to extended json and decoded the result is a local time:
irb(main):003:0> Time.now.as_extended_json => {"$date"=>{"$numberLong"=>"1583350627753"}} irb(main):005:0> BSON::ExtJSON.parse_obj(Time.now.as_extended_json) => 2020-03-04 14:37:25.927 -0500
For consistency between the two serializations we should be returning the time in UTC when performing extended json parsing.
Note that plain to_json does not round-trip times:
irb(main):006:0> Time.now.to_json => "\"2020-03-04 14:38:24 -0500\"" irb(main):007:0> JSON.parse(Time.now.to_json) => "2020-03-04 14:38:40 -0500"
When the times are returned in UTC, the workaround added in https://github.com/mongodb/mongo-ruby-driver/pull/1756 for this issue should be removed.
- related to
-
RUBY-2152 Implement FLE prose tests
- Closed
- links to