I've been cracking my head on this one for weeks now.
What happens if I set the repeatInterval property of a UILocalNotification to be a non-fixed interval? (by non-fixed I mean units such as NSWeekdayCalendarUnit and NSWeekdayOrdinalCalendarUnit).
So say I have UILocalNotification with its fireDate set to the Wednesday in the current week, and I set the repeatInterval to be NSWeekdayCalendarUnit. Will it repeat every Wednesday?
Is the same true for NSWeekdayOrdinalCalendarUnit? So if I have a notification with the fireDate set to be the 4th Wednesday of the month, and I set the repeatInterval to be NSWeekdayOrdinalCalendarUnit, will it repeat every 4th Wednesday of every month?
Thank you in advance.
OK, for the benefit of everyone, here's what I found:
Setting the repeat interval to NSWeekdayCalendarUnit doesn't work how I expected, instead, I suppose it looks for every occurrence of that weekday inside a week, and because there is only one, it then schedules the notification for the end of that week (the default is Saturday)
In a similar way, setting it to NSWeekdayOrdinalCalendarUnit creates a similar behavior, in that, seeing that there is no more occurrences of X ordinal of X day, it resorts to scheduling to the las ordinal for that weekday in a month.
Related
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?
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
Using rfc5545 is there a way to represent an event that starts on the first day of each month and ends on the last day of each month and repeats every month?
It's slightly different than a daily repeating event which is not ideal for my use case.
short answer: No
This is driven by the fact that the RFC5545 clearly states that an event cannot have a month duration, only days, weeks or seconds.
3.3.6. Duration
[...] Note that unlike
[ISO.8601.2004], this value type doesn't support the "Y" and "M"
designators to specify durations in terms of years and months.
(emphasis mine)
I created event in iCalendar. Its start date is today and end date is next month 15th. and this is recurrence type of event . so if set event as recurrence event then changed end date as same as recurrence end date. I want to give time duration of event,like 3.30P.M to 6.30P.M. How to i set event duration ....
"DTSTART;TZID=US-Eastern:19970105T083000
RRULE:FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9; BYMINUTE=30
First, the "INTERVAL=2" would be applied to "FREQ=YEARLY" to arrive at "every other year".
Then, "BYMONTH=1" would be applied to arrive at "every January, every other year".
Then, "BYDAY=SU" would be applied to arrive at "every Sunday in January, every other year".
Then, "BYHOUR=8,9" would be applied to arrive at "every Sunday in January at 8 AM and 9 AM, every other year".
Then, "BYMINUTE=30" would be applied to arrive at "every Sunday in January at 8:30 AM and 9:30 AM, every other year".
Then, lacking information from RRULE, the second is derived from DTSTART, to end up in "every Sunday in January at 8:30:00 AM and 9:30:00 AM, every other year".
Similarly, if the BYMINUTE, BYHOUR, BYDAY, BYMONTHDAY or BYMONTH rule part were missing, the appropriate minute, hour, day or month would have been retrieved from the "DTSTART" property."
Please any one guide me how to set ...
I know how to recurrence rule is working but my question is how to set event duration.
No client that I know of support BYMINUTE and BYHOUR so unless this event is for your own application consumption, you are asking for trouble. IN any case, the very first instance will use the DTSTART value as the beginning, regardless of what you may have put in BYMINUTE and BYHOUR (see https://www.rfc-editor.org/rfc/rfc5545#section-3.8.5.3)
Then you can use DTEND or DURATION:
DTSTART;TZID=US-Eastern:19970105T083000
DTEND;TZID=US-Eastern:19970105T153000
or
DTSTART;TZID=US-Eastern:19970105T083000
DURATION:PT7H
I am setting a repeating local notification to fire the next Tuesday at 10:00 and then repeat every week (NSWeekCalendarUnit) . My problem is that when the local time changes (2 times per year) the notification will fire at 11:00 or 9:00 o clock. The reason is that NSWeekCalendarUnit is calculated in seconds (7days/week*24hours/day*60seconds/hour). I want the alarm to fire only at 10:00 even if the local time has changed.
Is there any way to accomplish that?
Do you set the timeZone property of UILocalNotification? From the documentation:
... If you assign a valid NSTimeZone object to this
property, the fire date is interpreted as a wall-clock time that is
automatically adjusted when there are changes in time zones; an
example suitable for this case is an an alarm clock.
I've already got this data, which was pretty simple:
NSInteger numWeeks = ...;
NSInteger weekdayOfDateA = ...; // i.e. 1 for Sunday
NSInteger weekdayOfDateB = ...; // i.e. 6 for Friday
Just from the logical point of view, I could safely assume that every week in numWeeks has got one Sunday, right?
So numWeeks represents already my number of Sundays. Almost.
But how would I handle the edge cases? i.e. if dateA starts on a Wednesday, and dateB ends on a Monday, that must not neccessarily be a complete set of weeks. It may be like 10 and a half week or something. The problem is: Which part of the interval can be safely ignored since it's "sucked in" already by numWeeks?
I guess NSCalendar & Co. start looking at the first date and simply count up 7 days for each week. So is the only thing I must care of the last tail of that interval?
Think of your weeks as starting e.g. on Monday and ending on Sunday. Determine the number of these weeks you have - you'll have one Sunday for each - in determining this (which you'll probably want to do by rolling e.g. the start forward to the first Monday), if you pass by a Sunday add 1 to the result.