Reputation: 121
Maybe I'm overthinking this. I want to send a local notification every Monday at 9am until some condition is met. I know this can be done by setting the weekday
and hour
components of a DateComponents
. The problem I'm having is the value would I pass to weekday
depends on the Calendar
the DateComponents
is using. Which if I understand correctly depends on the user's settings. For instance if the user's calendar week starts on a Sunday I would pass a 1 to weekday
but if the week starts on a Saturday I would pass 2.
My question is how do I account for things like timezone, daylight savings, and week start day?
Upvotes: 0
Views: 139
Reputation: 339
Weekday units are the number go 1 through 7, where 1 is Sunday, 2 is Monday... And this won't never change.
When user changes setting, only the calendar.firstWeekday
will change.
E.g. if the user's calendar week starts on Sunday, firstWeekday = 1
else if start on Monday, firstWeekday = 2
Upvotes: 3