Post

Replies

Boosts

Views

Activity

Core Date get time in milliseconds
I created an entity TrackPointCD, which has a date property. When reading an entity, I can't get a timestamp with milliseconds, I get only seconds without a fractional part. When creating an object, I see that the date has milliseconds: let point = TrackPointCD(context: context ) point.id = UUID() point.lat = pointSave.cllocation2D.latitude point.lng = pointSave.cllocation2D.longitude point.elevation = pointSave.elevation point.date = pointSave.date point.distance = pointSave.distance point.speed = pointSave.speed point.track = trackCD print(point.date?.timeIntervalSinceReferenceDate) Optional(694475604.977305) Optional(694475605.371098) Optional(694475615.984135) ......................... When reading data written in the same way, there are no milliseconds. By sorting, I see that the sorting is always correct, as if there are milliseconds, but I can’t get them. What am I doing wrong? guard let track = track else { return } let decriptor = NSSortDescriptor(key: "date", ascending: true) guard let points = track.trackpoint?.sortedArray(using: [decriptor]) as? [TrackPointCD] else { return } points.forEach { point in print(point.date?.timeIntervalSinceReferenceDate) } Optional(693467599.0) Optional(693467601.0) Optional(693467602.0) Optional(693467603.0) Optional(693467604.0) ....................
0
0
526
Jan ’23