[DRIVERS-1586] Consider changing relaxed representation of dates before the epoch Created: 26/Feb/21  Updated: 29/Mar/23

Status: Backlog
Project: Drivers
Component/s: Extended JSON
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to JAVA-4023 Dates before epoch get serialized dif... Blocked
is related to VSCODE-363 Date fields show as $numberLong in th... Open
Driver Changes: Needed
Case:

 Description   

The Relaxed Extended JSON format for DateTime specifies that dates before the epoch are represented the same as Canonical Extended JSON:

{
    "$date": {
       "$numberLong": <64-bit signed integer giving ms relative to the epoch, as a string>}
}	

A user of the Java driver was very surprised by the behavior. The expectation was that dates before the epoch would be represented the same. And indeed, this is how mongoexport has worked since the 3.0 release (which is pointed out in the spec rationale:

~$ mongoexport -d test -c test
2021-02-26T10:15:52.455-0500	connected to: localhost
{"_id":{"$oid":"6039106dc6d0b365cd1f7454"},"d":{"$date":"2021-02-26T15:14:53.340Z"}}
{"_id":{"$oid":"60391099c6d0b365cd1f7455"},"d":{"$date":"1931-11-10T07:45:32.962Z"}}
2021-02-26T10:15:52.456-0500	exported 2 records

Let's consider whether we should update the spec for Relaxed Extended JSON to match this behavior, which is probably what would be expected by most users.



 Comments   
Comment by Alexander Golin (Inactive) [ 01/Mar/21 ]

Triage: Users are finding our formatting unexpected. Should be able to change this without introducing breaking changes, though want to definitely make sure. Should look up best practices for edge cases like "date of the end of the universe". For now not burning priority, placing in the backlog for future consideration.

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