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

Calendar.dateComponents was not zeroing unset components fields #23

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

marcprux
Copy link
Contributor

@marcprux marcprux commented Oct 4, 2024

This bug could lead to the following code returning inconsistent dates between Foundation and SkipFoundation:

let date = Date(timeIntervalSince1970: 1728038797.580)
let calendar = Calendar.current
calendar.timeZone = TimeZone(identifier: "Europe/Zurich")!

let components = calendar.dateComponents([.year, .month, .day], from: date)
let date2 = calendar.date(from: components)!

The problem is that on Foundation, the DateComponents zeros out all the un-set fields for the Date is that is returned, whereas we were not.

@cla-bot cla-bot bot added the cla-signed label Oct 4, 2024
@marcprux marcprux merged commit 0385dd1 into main Oct 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant