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-7011] Fatal Error when Using Calendar.current.dateComponents(_, from: , to: ): Linux #4256

Closed
swift-ci opened this issue Feb 15, 2018 · 2 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-7011
Radar None
Original Reporter ajedwards (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Swift Version

Swift version 4.0 (swift-4.0-RELEASE)
Target: x86_64-unknown-linux-gnu

Linux Version

Distributor ID: Ubuntu
 Description: Ubuntu 16.04.3 LTS
 Release: 16.04
 Codename: xenial
Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug, Calendar, DateComponents, Linux
Assignee @spevans
Priority Medium

md5: e21aefe09a7e60f420e5013977160531

Issue Description:

When attempting to determine the difference between two dates using, I am experiencing the following fatal error:

fatal error: file Foundation/NSCalendar.swift, line 613

The following line of code causes the crash:

var difference = Calendar.current.dateComponents([.month, .year, .day], from: date1, to: date2)
@spevans
Copy link
Collaborator

spevans commented Aug 10, 2018

#1658

@spevans
Copy link
Collaborator

spevans commented Aug 16, 2018

This is fixed in the master branch:

$ cat sr_7011.swift 
import Foundation

let date1 = Date(timeIntervalSince1970: 0)
let date2 = Date()
var difference = Calendar.current.dateComponents([.month, .year, .day], from: date1, to: date2)
print("Difference between", date1, "and", date2, ":")
print("Year:", difference.year!, "Month:", difference.month!, "Day:", difference.day!)

$ ~/swift-DEVELOPMENT-SNAPSHOT-2018-08-15-a-ubuntu16.04/usr/bin/swift sr_7011.swift 
Difference between 1970-01-01 00:00:00 +0000 and 2018-08-16 19:32:41 +0000 :
Year: 48 Month: 7 Day: 15 

@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