Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-1083

toJson serialization behaves incorrectly for dates on Windows, Linux, and Android

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      We're testing round-tripping date properties in the dart SDK and noticed that json serialization behaves inconsistently. For example, the date `-0001-01-01 00:00:00` - I.e. year 1 BCE is encoded as `-001-01-01 00:00:00` on Apple platforms, but as empty string on Windows (looks like all dates equal to or below 0000-01-01 00:00:00 get encoded as empty on Windows).

      The date 0000-01-01 00:00:00 gets encoded as 0000-01-01 00:00:00 on Apple platforms but 0-01-01 00:00:00 (note the lack of leading zeroes) and as 1905-06-06 18:35:44 on Android.

      The date -271821-04-21 00:00:00 gets encoded as 2016-09-19 11:52:32 on Android, but correctly on Apple platforms.

      It is possible that there's also a bug in the dart SDK in the way we represent dates on some platforms, but I verified that the reported that it's a serialization bug on windows (Studio correctly visualizes the expected date) and non-negative/zero dates work just fine, so there are strong indications that the bug is in the to_json implementation in Core.

            Assignee:
            jorgen.edelbo@mongodb.com Jørgen Edelbo
            Reporter:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: