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

.offset(.day, value: d) does not work for all days of the week #127

Open
vince-marco opened this issue Jun 8, 2024 · 1 comment
Open

Comments

@vince-marco
Copy link

My code:

var weekdays: [Date] {
var days = Date
let sunday = Date.now.adjust(for: .startOfWeek)!
for d in 0...6 {
let day = sunday.offset(.day, value: d)!
days.append(day)
}
return days
}

Results in:

Sun - 6/2/24, 12:00 AM
Mon - 6/3/24, 12:00 AM
Tue - 6/4/24, 12:00 AM
Wed - 6/5/24, 12:00 AM
Tue - 6/4/24, 12:00 AM
Fri - 6/7/24, 12:00 AM
Sun - 6/2/24, 12:00 AM

Thursday Saturday are wrong!

@vince-marco
Copy link
Author

This is possibly an issue with Apple's Date class, as it produces the same results with .addingTimeInterval(606024).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant