File tree 1 file changed +4
-6
lines changed
darwin-integration/nativeMain/src
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,10 @@ import platform.Foundation.*
14
14
* resolution.
15
15
*/
16
16
public fun Instant.toNSDate (): NSDate {
17
- // TODO: support nanosecond precision.
18
- // This is not urgent, as Darwin itself only uses millisecond precision.
19
- // However, we could at least round to the nearest millisecond so that it would be true that
20
- // Instant.parse(...).toNSDate() == [formatter dateFromString: ...],
21
- // as Darwin does perform rounding.
22
- val secs = toEpochMilliseconds() / 1000.0
17
+ val secs = epochSeconds * 1.0 + nanosecondsOfSecond / 1 .0e9
18
+ if (secs < NSDate .distantPast.timeIntervalSince1970 || secs > NSDate .distantFuture.timeIntervalSince1970) {
19
+ throw DateTimeException (" Boundaries of NSDate exceeded" )
20
+ }
23
21
return NSDate .dateWithTimeIntervalSince1970(secs)
24
22
}
25
23
You can’t perform that action at this time.
0 commit comments