Closed squirtle1990 closed 6 years ago
Because Realm famously rounds off date milliseconds
Realm stores miliseconds properly since... well a very long time ago actually, afaik.
But maybe this is something I'm just not aware of?
However, I don't think this is caused by anything I'm doing. It could be a timezone question, Realm Studio afaik shows dates in GMT.
I checked the raw values in Logcat and Realm Studio. The GMT time zones are both set to the same on both platforms.
Does it work properly if you use Realm directly instead of Monarchy?
Hmm no, it doesn't seem to work with Realm directly either. It might be an issue with the large double values - perhaps a catastrophic overflow. I'm going to replace the time representation with a Date object instead and try again.
You might be hit by https://github.com/realm/realm-core/issues/3076
Switching to Date fields in Realm solved the problem.
I am attempting to query all ClassName objects with a particular symbol, type, and time. Because Realm famously rounds off date milliseconds, I opted to store dates as doubles with the time in milliseconds. In the query below, I am attempting to get all objects from the past 24 hours, so I query for objects with time greaterThanOrEqualTo the millisecond time from a date 24 hours in the past. Only problem is, I receive zero objects in the result query, unless I lower the time to some ridiculously low value, like 0.
I have verified client side through LogCat the time object is in milliseconds, and server side through Realm Studio that the time fields are in milliseconds as well.
It seems strange to say the least.