realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.27k stars 2.14k forks source link

Dates in Swift created before Unix epoch (Jan 1, 1970) are not accurate once synced to Atlas. #7049

Open sync-by-unito[bot] opened 3 years ago

sync-by-unito[bot] commented 3 years ago

User has this:

|----| |@objc dynamic var DisplayDate: Date? = Date(timeIntervalSince1970: 62135596800)// 000101-03 00:00:00 +0000|

They get this in Atlas:

|----| |00010101 00:00:00 +0000|

I have reproduce this issue with DateFormatter as well.

Example:

|----| |let dateFormatter = DateFormatter()| |dateFormatter.locale = Locale(identifier: "en_US_POSIX")| |dateFormatter.dateFormat = "yyyyMMdd'T'HH:mm:ss.SSSZ"| |let date = dateFormatter.date(from: "00010103T11:00:00.000Z")| |task.date = date|

Task document in Atlas has: 

|----| |00010101T00:00:00.000+00:00|

If I use:

|----| |let date = dateFormatter.date(from: "10000103T00:00:00.000Z")|

In Atlas it shows: 

|----| |10000108T00:00:00.000+00:00|

sync-by-unito[bot] commented 2 years ago

➤ Brian Munkholm commented:

[~lee.maguire] This doesn't seem to be a bug in the SDK? Should this be reassigned to another team?