RRule Repeating monthly calendar event on weekday only - calendar

I have an recurring event on the 7th of each month but am struggling to find an RRule that I can put into a text editor and import into google calendar. I need the rule to put the event on the last week day if the 7th falls on a weekend. Thanks in advance.

Due to the fallback condition, I don't think you can achieve this only defining a RRULE, unfortunately.
RRULE in Google Calendar follows RFC 5545 specification.
With RFC 5545, regarding monthly recurrences, you can either set the recurring rule for a specific day of the month (e.g. always on the 7th of the month would be RRULE:FREQ=MONTHLY;BYMONTHDAY=7) or a specific offset of day of the week within a month (e.g. second to last weekday of the month would be RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2).
Only using this specification, I don't believe there is a way to select the previous (or next) weekday in reference to the 7th day of the month.
However you can always achieve this by using a script to generate the dates or interpret an existing list you already have before insert them on Google Calendar.

Related

How to get first of week based calendar in nodatime?

I want to get first day of week for specificid ZonedDateTime in NodaTime.
But week starts Saturday in Persian calendar and Monday in Gregorian calendar.
How can I get first day of week based on calendar of ZonedDateTime?
We don't expose that information, because it's not as cut and dried as you expect it to be. Different cultures and contexts use different week rules - for example, while you've stated that the week starts on Monday in the Gregorian calendar, that's context specific. In many contexts Sunday is used as the first day of the week instead.
See the week numbering part of the Wikipedia article on weeks for examples of this.
It sounds like you'll probably want a Dictionary<CalendarSystem, IsoDayOfWeek> or possibly a Dictionary<CalendarSystem, IWeekYearRule> in your application, depending on what you're trying to achieve.

Event every 5th day of mont (or 4th/3rd if it's weekend or holiday) using iCal

In Brazil my payday happen on every 5th day of month.
But if the 5th day is a saturday/sunday, then the payment will happen on the 4th day.
Same if 4th is saturday/sunday: then the payment will happen on 3rd day. And so on.
Is there any way to create a event that will work with Google Calendar and iCal?
You can achieve that with iCalendar, at least as far as it concerns weekends.
Consider the following rule:
DTSTART;TZID=US-Eastern:20160505T000000
RRULE:FREQ=MONTHLY;BYMONTHDAY=1,2,3,4,5;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
The rule is evaluated as follows:
FREQ=MONTHLY;BYMONTHDAY=1,2,3,4,5: expand to the 1st, 2nd, 3rd, 4th and 5th day of each month
BYDAY=MO,TU,WE,TH,FR: filter by week day, retain only work days/remove weekend days
BYSETPOS=-1: retain only the last day of the set
You can verify the result at http://recurrence-expansion-service.appspot.com/
Here are the first 100 instances.
It's not possible to achieve that for holidays though.
Update:
It's actually sufficient to specify
RRULE:FREQ=MONTHLY;BYMONTHDAY=3,4,5;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
Since the weekend is at most 2 days long, payday must fall on one of the 3rd, 4th or 5th day of the month. Again, this does not take holidays into account.
Holidays always need special consideration. Not only does RRULE not support this kind of logic for arbitrary days, sometimes it's difficult or even impossible to express holidays by an RRULE themselves. In some countries certain holidays are always on a specific day, except when the days falls on a weekend, in which case the holiday is on the Friday before or the Monday after the weekend. Or consider the Easter date and holidays relative to the Easter date, they can't be expressed by an RRULE at all.
Not to forget that some holidays may change every now and then (like "King's days" or "Queen's days" in certain countries).
The best you can do is to manage these manually and add an RDATE and an EXDATE if payday would fall on a holiday according to the RRULE above.

Codename One - days of month

I am trying to build a week view of the month with customized cells, so the Calendar class won't work for me.
I am having trouble knowing on which day the month starts. For example, January 1st was a Friday. Also, I need to know how many days a given month has.
Without telling me the exact code, can you tell me the variables or methods I could use for this?
Look at the actual code for the Calendar class here: http://github.com/codenameone/CodenameOne/
Just set java.util.Calendar to the right date then use the get method to get the day of the week.

ExtJS 4.2 DatePicker get the first day and last day in the calendar

I have an ExtJS datepicker where I disable some dates so the user can't select them.
After the calendar is renderer I send to the server the current date and the server sends back an array of days to disable, so the visual result is the following:
The problem I have is that I don't know the first and last day showed in the datepicker.
In this image the first day is 08/31/2014 and the last day is 09/11/2014. How can I get those dates, so I can tell my server to check if within that range I have to disable any date.
In the calendar example the "yellow marked dates" have to been disabled.
Any clue? Appreciate in advance.
Check this fiddle: https://fiddle.sencha.com/#fiddle/8ms
this uses minDate, maxDate with disabledDates, disabledDays combination..to enable particular days and disable all other days.
You could arbitrarily set the minValue to this month's first day and maxValueto this month's last day and then assume this on the backend side.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Date-cfg-minValue
Here's how to get current month's first and last day
Get first and last date of current month with javascript or jquery

Can iCal schedule an event for the first weekday after BYMONTHDAY if BYMONTHDAY is a weekend?

If I have a recurring event on a given day of the month (i.e. the 15th) and that day falls on a Saturday or a Sunday, is it possible for iCal to instead schedule the event to occur on the next available week day?
you cannot set exception but you can use a combination of byday and bymonthday:
something like will give you the monday after a week-end which had either on saturday or sunday a 15th.
RRULE:FREQ=MONTHLY;BYDAY=MO;BYMONTHDAY=16,17
By combining with another event:
RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=15
you'll be there
Using the BYSETPOS=1 rule part, you can accomplish this in a single event:
RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYMONTHDAY=15,16,17;BYSETPOS=1
This tells iCal to repeat the event monthly; to repeat it only Monday-Friday; to repeat it only on the 15th-17th; and to repeat it only on the first day (per month) that matches the previous rule parts.
BYSETPOS just tells iCal to choose the Nth occurrence of the set of occurrences matched by the other rule parts. It can be set to a comma separated list of values from 1 to 366 or -366 to -1.
For example, modifying the above rule to have BYMONTHDAY=15,16,17,29,29,30,31 and BYSETPOS=1,-1 will cause the event to repeat on the first weekday on or after the 15th, and the last weekday in the month.
Source: RFC 2445

Resources