Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9439] Error retrieving nanoseconds from Calendar on linux #3578

Closed
swift-ci opened this issue Dec 7, 2018 · 1 comment
Closed

[SR-9439] Error retrieving nanoseconds from Calendar on linux #3578

swift-ci opened this issue Dec 7, 2018 · 1 comment

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Dec 7, 2018

Previous ID SR-9439
Radar None
Original Reporter wonderboyfrommars (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, Linux, RunTimeCrash
Assignee None
Priority Medium

md5: 6233259148dc92d048f460a092c115ad

Issue Description:

I am trying to get the elapsed nanosecods via the Calendar API like this

let elapsedNano = Calendar.current.dateComponents([.nanosecond], from: self.startTime, to: now).nanosecond

This fails on Ubuntu 18.04 with the following error

Fatal error: : file Foundation/NSCalendar.swift, line 617

Using .second in the given call seems to work. The same code on MacOS works fine.

@spevans
Copy link
Collaborator

spevans commented Oct 27, 2019

This was fixed in swift-5.0 to return the correct nanosecond component

$ cat sr-9439.swift
import Foundation

let now = Date()
let then = Date(timeIntervalSince1970: now.timeIntervalSince1970 - 1.2345678)
let elapsedNano = Calendar.current.dateComponents([.nanosecond], from: then, to: now).nanosecond
print(elapsedNano ?? "nil")

$ ~/swift-5.0.3-RELEASE-ubuntu14.04/usr/bin/swift sr-9439.swift
1234567871
 

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants