.offset(.day, value: d) does not work for all days of the week
Opened this issue · 1 comments
vince-marco commented
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 commented
This is possibly an issue with Apple's Date class, as it produces the same results with .addingTimeInterval(606024).