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-8655] DateFormatter uses different referenceDate than Date #3640

Open
swift-ci opened this issue Aug 28, 2018 · 0 comments
Open

[SR-8655] DateFormatter uses different referenceDate than Date #3640

swift-ci opened this issue Aug 28, 2018 · 0 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-8655
Radar None
Original Reporter Schmid (JIRA User)
Type Bug
Environment

Found on OSX in Xcode 10.13.6

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: c91faf5e17cca5c5a5642e12413ef7b9

Issue Description:

The Date referenceDate is 2001.01.01 00:00 UTC. However if you create a DateFormatter without a year, the effective referenceDate is 2000.01.01 00:00 UTC.

Given that the Date object allows for timeIntervals from both 1970 and 2001 it would more consistent if the DateFormatter used one of the expected epochs instead of using it's own.

To replicate;

import Foundation{{ }}

let d = DateFormatter()

d.dateFormat = "mm:ss"
d.timeZone = TimeZone(abbreviation: "UTC"){{ }}

let date = d.date(from: "10:00")

let timeInterval = date?.timeIntervalSinceReferenceDate{{ }}

let zero = Date(timeIntervalSinceReferenceDate: 0)

print ("(zero)")

@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
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

1 participant