EzDevInfo.com

rrule

JavaScript library for working with recurrence rules for calendar dates. rrule.js demo

Python dateutils print recurrence rule according to iCalendar format (see RFC 5545)

I am trying to print a recurrence rule as a string specified by iCalendar format (see RFC 5545). Im using python dateutils, in particular dateutil.rrule to create the recurrence rule and I want to print this as a string like:

    "RRULE:FREQ=DAILY;COUNT=5"

Can anyone tell me if there is a method to achieve this?

I think I'm using the labix dateutils btw.

Many thanks!


Source: (StackOverflow)

Looking for JavaScript lib that implements RRULE (iCalendar RFC 5545) [closed]

I am looking for a good iCalendar RFC 5545 processing library (open source / GPL compatible) that has been implemented in JaavScript. My current interest is a js library that fully implements the RRULE so that we can use our calendar web app offline with HTML5 compatible browsers.

We have our UI so just a usable library that can generate the RRULE and the event dates is what we need. I've even give some thought to contacting the guy that created the python dateutil to see if we could port his library to js.

Examples of our needs include:

  1. Given raw data (provided by our existing UI), construct iCalendar VEVENT information including RRULEs.
  2. Given a VCALENDAR / VEVENT object, generate the appropriate iCalendar text string that I can store locally using HTML5 until the client connects to the server.
  3. Given a VCALENDAR / VEVENT object with RRULEs in it, be able to say "give me the start/end dates of the next X occurrences from some date" or "give me all the start/end dates of occurrences until date Y".

Any leads, thoughts or suggestions are greatly appreciated.


Source: (StackOverflow)

Advertisements

How to handle DST and TZ in recurring events?

Does dateutil rrule support DST and TZ? Need something similar to iCalendar RRULE.

If not - how to tackle this problem (scheduling recurring events & DST offset change)

Imports

>>> from django.utils import timezone
>>> import pytz
>>> from datetime import timedelta
>>> from dateutil import rrule
>>> now = timezone.now()
>>> pl = pytz.timezone("Europe/Warsaw")

Issue with timedelta (need to have the same local hours, but different DST offsets):

>>> pl.normalize(now)
datetime.datetime(2012, 9, 20, 1, 16, 58, 226000, tzinfo=<DstTzInfo 'Europe/Warsaw' CEST+2:00:00 DST>)    
>>> pl.normalize(now+timedelta(days=180))
datetime.datetime(2013, 3, 19, 0, 16, 58, 226000, tzinfo=<DstTzInfo 'Europe/Warsaw' CET+1:00:00 STD>)

Issue with rrule (need to have the same every local hour of each occurrence):

>>> r = rrule.rrule(3,dtstart=now,interval=180,count=2)
>>> pl.normalize(r[0])
datetime.datetime(2012, 9, 20, 1, 16, 58, tzinfo=<DstTzInfo 'Europe/Warsaw' CEST+2:00:00 DST>)
>>> pl.normalize(r[1])
datetime.datetime(2013, 3, 19, 0, 16, 58, tzinfo=<DstTzInfo 'Europe/Warsaw' CET+1:00:00 STD>)

Source: (StackOverflow)

dateutil.rrule.rrule.between() gives only dates after now

From the IPython console:

In [16]: b
Out[16]: datetime.datetime(2008, 3, 1, 0, 0)

In [17]: e
Out[17]: datetime.datetime(2010, 5, 2, 0, 0)

In [18]: rrule(MONTHLY).between(b, e, inc=True)
Out[18]:
[datetime.datetime(2009, 3, 6, 14, 42, 1),
 datetime.datetime(2009, 4, 6, 14, 42, 1),
 datetime.datetime(2009, 5, 6, 14, 42, 1),
 datetime.datetime(2009, 6, 6, 14, 42, 1),
 datetime.datetime(2009, 7, 6, 14, 42, 1),
 datetime.datetime(2009, 8, 6, 14, 42, 1),
 datetime.datetime(2009, 9, 6, 14, 42, 1),
 datetime.datetime(2009, 10, 6, 14, 42, 1),
 datetime.datetime(2009, 11, 6, 14, 42, 1),
 datetime.datetime(2009, 12, 6, 14, 42, 1),
 datetime.datetime(2010, 1, 6, 14, 42, 1),
 datetime.datetime(2010, 2, 6, 14, 42, 1),
 datetime.datetime(2010, 3, 6, 14, 42, 1),
 datetime.datetime(2010, 4, 6, 14, 42, 1)]

How do I make between() return dates starting from the begining (b) date?


Source: (StackOverflow)

Exclude calendar holidays from rrule before processing

I am using the rrule method from python-dateutil package. I would like to create a rule that can ignore dates that are within a holiday calendar. I know about the exdate() method but this seems to filter the date from the output list only it has been generated.

from dateutil.rrule import *
from datetime import datetime

set = rruleset()
set.rrule(rrule(MONTHLY, count=4, bysetpos=-1, byweekday=(MO, TU, WE, TH, FR), dtstart=datetime(2013,1,1)))
list(set)
# outputs 4 dates without an exdate() call
> [datetime.datetime(2013, 1, 31, 0, 0), datetime.datetime(2013, 2, 28, 0, 0), datetime.datetime(2013, 3, 29, 0, 0), datetime.datetime(2013, 4, 30, 0, 0)]

set.exdate(datetime.datetime(2013, 2, 28, 0, 0))
list(set)
# only outputs 3 dates, ignoring the date provided in exdate()
> [datetime.datetime(2013, 1, 31, 0, 0), datetime.datetime(2013, 3, 29, 0, 0), datetime.datetime(2013, 4, 30, 0, 0)]

What I would like rrule to do is not omit the datetime(2013, 2, 28, 0, 0) but instead seek back to find the next best date according to the original rules, i.e. in this case datetime(2013, 2, 27, 0, 0). Any ideas how I could achieve this?


Source: (StackOverflow)

iCalendar (RFC5545) recurrence rule multiple times a day

How can I make an event occur multiple times a day using the RRULE specified in RFC5545?

Lets say I would like an event to happen every other week on Monday and Friday at 11AM and 18PM. Is it possible to format the RRULE like something as the following:

RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,FR;[TIMES=110000,180000]

Thanks


Source: (StackOverflow)

Recurring events on a calendar : RFC 5545 Javascript parsing

I need to integrate recurring events into an adapted version of full-calendar that has an added javascript module which allows offline event browsing.

I'm looking for a javascript library that can parse recurring events according to RFC 5545.

I need to be able to list all recurring events that occur between 2 dates (start date and end date), using RRULE and EXDATE and interpreting daily, weekly, monthly and yearly recurrences.

I've spent hours searching for something to no aval, and I don't want to reinvent the wheel....Can anyone please point me in the right direction for an existing javascript parser?


Source: (StackOverflow)

How to match dateuilts.rrule and python icalendar daylightsavingtime aware

I'm dealing with some ical problems.

I have an ical event.

BEGIN:VEVENT
UID:Event/termine/gps/akt@portal.augusta.de 
DTSTART;TZID=CET:20150529T190000
DTEND;TZID=CET:20150529T220000
CATEGORIES:Arbeitsgruppe
DTSTAMP:20110620T075538Z
EXDATE;TZID=CET:20151225T190000
LAST-MODIFIED:20150424T201707Z
LOCATION:Vereinsräume des Augsburger Computer Forum e.V.
PRIORITY:5
RRULE:FREQ=MONTHLY;BYDAY=-1FR
SUMMARY:GPS-Arbeitsgruppe
URL:https://www.augusta.de/termine/gps
END:VEVENT

As you can see there is an RRule repeating this event every last friday of the month.

I parsed this ical with icalendar.

I'm using:

start = iobj.get( 'DTSTART' ).dt
rrset = rruleset()
rrule = iobj.get( 'RRULE' )
exdate = iobj.get( 'EXDATE' )
rrset.rrule( rrule.rrulestr( rule.to_ical(), dtstart = start ) )
for edate in exdate.dts : 
    rrset.exdate( edate.dt )

Everything so far works just fine.

When I Try to get the next say 10 dates with:

list(rrset)[:10] 

I get:

[datetime.datetime(2015, 5, 29, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2015, 6, 26, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2015, 7, 31, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2015, 8, 28, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2015, 9, 25, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2015, 10, 30, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2015, 11, 27, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2015, 12, 25, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2016, 1, 29, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>),
 datetime.datetime(2016, 2, 26, 19, 0, tzinfo=<DstTzInfo 'CET' CEST+2:00:00 DST>)]

Which seems okay on the first glance, but on deeper inspection there is a problem starting with October 30th, daylight saving time ends October 25th but tzinfo info of the datetime object is still "DstTzInfo 'CET' CEST+2:00:00 DST"

The second problem is that the 25th of December is in this list instead of being skipped a specified in the EXDATE. The Problem seams to be tat while parsing the exdate rule daylight saving time is calculated correctly and therefore the exdate 19:00:00+01:00 didn't match the calculated repeat time of 19:00:00+02:00.

Am I doing something wrong there?

Converting everything to UTC and processing there doesn't help because 17:00:00 UTC don't match 18:00:00 UTC either.


Source: (StackOverflow)

Create a repeating event with reminder until specific day without Intent in Android?

I have an android app that downloads with a service some drugs info.

For example (fludex white round 2 24-02-2012),means a drug named fludex ,white and round,must be given 2 times per day from today untill 24-01-2012.

Now i want after drug info downloading , to add repeated event with drug info to the calendar silently/programmatically(without user interaction). So that from today untill 24-01-2012 every 10 am and 10pm to have a reminder 10 minutes before to take his drug. My app will be for android 2-4. How can i do that,i'm confused from my searching so far.

Second question:How can i delete only the events(and their reminders) made from my application,so when i sync my drug therapy to delete all previous events and produce new events based on the new drug therapy i receive from my service?


Source: (StackOverflow)

Syncing EKRecurrenceRules with Cloud Service RFC 2445 iCalendar specification RRULE

I'm trying to create a cloud based service which stores recurring Events. I have chosen to do this using the icalendar RRULE standards (RFC2445) and use a database schema as below exposed via cloud based service.

EventID
EventName
EventDescripton
Start
End
RecurrenceRule  <-- Store RFC 2445 iCalendar specification RRULE (recurrence)
Active
Deleted
DateCreated
DateLastUpdated

I beleive that the EKRecurrenceRules are RFC 2445 compliant, however by storing the string representation of the RRULE or description of the EKRecurrenceRule makes for a more cross platform compliant architecture.

I am able to create a EKRecurrenceRule on the client side easily and extract the RRULE from the EKRecurrenceRule description property. However, my question is how to convert that description property back to an EKRecurrenceRule object on the client when extracted from the cloud service? It seems stupid Apple would expose a property to extract the compliant RRULE but not provide any way to convert an RRULE to a native object.

I'd like to avoid storing individual components of the EKRecurrence rule if possible.


Source: (StackOverflow)

How to recover python dateutil.rrule object from a dictionary string?

I want to store dateutil.rrule objects to a database and recreate them after reading from the database.

Given the following issue, I think I need to use a workaround. Python dateutils print recurrence rule according to iCalendar format (see RFC 5545)

I am thinking of storing the output of myrrule.dict to the database as a string and then recreate the rrule object when required.

This is how the dict looks like:

{'_cache_complete': False, '_byhour': (0,), '_wkst': 0,
'_timeset': (datetime.time(0, 10),), '_bysecond': (0,),
'_bymonthday': (), '_byweekno': None, '_bysetpos': None,
'_cache': None, '_bymonth': None, '_bynweekday': ((4, 3),),
'_tzinfo': None, '_byyearday': None, '_byweekday': None,
'_byminute': (10,), '_len': 10, '_until': None,
'_bynmonthday': (), '_dtstart': datetime.datetime(2012, 10, 13, 0, 10),
'_count': 10, '_freq': 1, '_interval': 1, '_byeaster': None}

Is it a good idea? Any other suggestions?

How do I recover the python object from the dictionary? Is python setattr() on my best bet or is there something easier?

Should I consider using something like this instead? http://stackoverflow.com/a/1305663/161628


Source: (StackOverflow)

Google Calendar API, RRULE and EXDATE

I'm trying to export some events to Google Calendar with the API, specifically the python library that wraps it. These events have recurrence, which is defined to Google Calendar with an RRULE string, and I'm trying to exclude certain dates with EXDATE strings.

Here's what I'm sending:

{
    "summary": "Test Event", 
    "description": "Event", 
    "location": "Home", 
    "start": {
        "timeZone": "America/New_York", 
        "dateTime": "2014-09-05T10:30:00"
    }, 
    "end": {
        "timeZone": "America/New_York", 
        "dateTime": "2014-09-05T11:35:00"
    }, 
    "recurrence": [
        "RRULE:FREQ=WEEKLY;WKST=SU;BYDAY=FR;UNTIL=20141203T173500Z", 
        "EXDATE:20141002"
    ], 
}

It exports all correctly, except the EXDATE isn't respected. Well, it's sort of respected. In the calendar, the event still exists, however it describes the repetition as "Weekly at 10:30am on Monday, Wednesday, Thursday from Wed Sep 3 to Wed Dec 3 except Thu Oct 2".

The "except Thu Oct 2" part implies it is parsing the EXDATE correctly (and if I send garbage in the EXDATE, it won't run, so it is parsing it), but the event still occurs.


Source: (StackOverflow)

RECURRENCE-ID in iCalendar (RFC 5545)

I'm a little bit confused about the Property RECURRENCE-ID in the iCalendar specification RFC 5545 and the RANGE parameter in this property.

Assume a calendar component containing a recurring event called "Meeting" which shall be scheduled each monday 10 to 12 o'clock starting on August 6th 2012. The recurrence end shall be the October 29th 2012. The "Meeting" is rescheduled from 12 to 15 o'clock each monday by September 3rd 2012 with RANGE set to THISANDFUTURE to inidcate that all subsequent events will also be scheduled from 12 to 15 o'clock. By October 1st 2012 the "Meeting" shall be rescheduled again from 10 to 13 o'clock every tuesday (instead of monday) also with RANGE set to THISANDFUTURE. Additionally the single event on September 17th 2012 will be rescheduled from 8 to 10 o'clock.

The event in iCalendar-format will look like this:

BEGIN:VCALENDAR
...
BEGIN:VEVENT
DTSTART:20120806T100000Z
DTEND:20120806T120000Z
UID:atgbutj8md5v35fuguni1of4b9o@google.com
SEQUENCE:1
SUMMARY:Meeting
RRULE:FREQ=WEEKLY;UNTIL=20121029T100000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20120903T120000Z
DTEND:20120903T150000Z
UID:atgbutj8md5v35fuguni1of4b9o@google.com
SEQUENCE:1
SUMMARY:Meeting
RRULE:FREQ=WEEKLY;UNTIL=20121029T100000Z
RECURRENCE-ID;RANGE=THISANDFUTURE:20120903T100000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20121002T100000Z
DTEND:20121002T130000Z
UID:atgbutj8md5v35fuguni1of4b9o@google.com
SEQUENCE:1
SUMMARY:Meeting
RRULE:FREQ=WEEKLY;UNTIL=20121029T100000Z
RECURRENCE-ID;RANGE=THISANDFUTURE:20121001T100000Z or 20121002T120000Z???????????
END:VEVENT
BEGIN:VEVENT
DTSTART:20120917T080000Z
DTEND:20120917T100000Z
UID:atgbutj8md5v35fuguni1of4b9o@google.com
SEQUENCE:1
SUMMARY:Meeting
RRULE:FREQ=WEEKLY;UNTIL=20121029T100000Z
RECURRENCE-ID:20120917T100000Z or 20120917T120000Z?????????
END:VEVENT
END:VCALENDAR

The values I'm unsure are the values of the RECURRENCE-IDs and the RRULES.

-) Which of the dates shall be used in the third and fourth event? Shall they reference to the main event (very first event) or to the event the second event, because this is the "nearest" event, which is rescheduled?

-) If my interpretation of RFC5545 is right, the RRULE may not be changed or rescheduled. This means that the rrule will be the same also in the subevents. What happens to the very last event, which is scheduled from 10 to 12 o'clock on October 29th 2012 but rescheduled to 10 o'clock of the following day by the third event. Is this last event in the recurrence set of the calendar component or has the UNTIL value to be changed at all events so that that the October 30th 10 o'clock is included?

Thanks in Advance! :-)


Source: (StackOverflow)

Determining occurrences from iCalendar RRule that expands

I'm reading through RFC 5545 and trying to determine how to correctly find a set of occurrences. Let's say I have a WEEKLY rrule = 2 (every other week). I also have specified a BYDAY rule part for Tue, Wed, Thu. Let's assume my start date is 2011-04-07 (Thu) and my end date is 2011-04-27 (Wed). Obviously ignoring less significant than date, I would think my occurrence set would contain: 2011-04-07, 2011-04-12, 2011-04-13, 2011-04-21, 2011-04-26, 2011-04-27.

What is throwing me off is this statement from the RFC: "The WKST rule part specifies the day on which the workweek starts. Valid values are MO, TU, WE, TH, FR, SA, and SU. This is significant when a WEEKLY "RRULE" has an interval greater than 1, and a BYDAY rule part is specified."

So, if my WKST=MO, I'm seeing an implication from the above statement that the week does not start from the start date, but from the WKST. Which means that instead of using a week based off of the start date, in this case, Thu-Wed, I need to actually start with WKST and determine which occurrences fall within THAT week (Mon-Sun) and every other week from THAT WKST. So, for calculation purposes, my starting date would actually be 2011-04-04. That falls before the start date so I jump ahead TO the start date but I stick with a Mon-Sun week. Which means my occurrence set is actually: 2011-04-07, 2011-04-19, 2011-04-20, 2011-04-21. That is vastly different than my original set.

Additionally, IF this is the proper way to calculate, does that also mean in expanding rrule situations for other frequencies with >1 intervals I must "start" at the beginning of that period instead of the start date. Does MONTHLY encompass the 1st - last day of the month of the start date. Does YEARLY encompass Jan 1 - Dec 31 of the year of the start date?

I hope there's an iCalendar guru out there...I can't wrap my head around the logic here. Thanks.

UPDATE: I did create a few .ics files and import into google calendar. Assuming google is interpreting these correctly, I can confirm that having an expanding MONTHLY with INTERVAL>1 will use the 1st to last day of the month, NOT a month starting from the start date from the event. YEARLY rules work in the same manner, the year goes from Jan 1st-Dec 31st. Not what I originally expected but hopefully this can help someone else out.


Source: (StackOverflow)

Create recurrence rule for event (RRULE) in Android programatically

Is there a way of programmatically generating a rrule string for an event in Android?

I found the RecurrenceEvent class in the Android source that generates a String from its fields. However, it does not seem to be accessible.


Source: (StackOverflow)