volkanunsal / postgres-rrule

Recurring dates in Postgres.
MIT License
109 stars 25 forks source link

Daylight savings support #18

Open davidpanic opened 2 years ago

davidpanic commented 2 years ago

Currently the occurrences() function (and possibly others) does not respect daylight savings. This means that a recurrence rule that crosses daylight savings will report wrong times for occurrences in the new time zone.

iCAL uses the VTIMEZONE field to specify the event creation timezone, it should be handled and report the correct times.

As an example run this query:

SELECT _rrule.occurrences(
    _rrule.rrule('RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE;UNTIL=20221105T000000Z'),
    '2022-10-26T05:00:00'::timestamp,
    '[2022-10-24, 2022-11-04]'::tsrange
);

This is the current transition from CEST to CET in europe, canonically this is the Europe/Belgrade time zone. There is currently no way to pass that information to the function. It should return the following occurrences: 2022-10-26T05:00:00+02:00, 2022-10-26T05:00:00+01:00 if we assume the returned time zone is UTC (currently it returns the time without time zone).

erkstruwe commented 1 year ago

Please see my comment at https://github.com/volkanunsal/postgres-rrule/issues/3#issuecomment-1342746149 for a workaround.