5

I'm trying to use python-dateutil to create a rrule to schedule an event to run every day at exactly 6PM EST.

The current rrule I'm using is simply:

byhour:23;

this renders to 6PM during non-daylight savings time, but during daylight savings time it renders as 7PM.

How do I change this to take into account DST?

My server this is running on (Linux) is currently configured for EST and already takes into account DST, so it looks like python-dateutil ignores this and bases calculations on UTC.

Cerin
  • 60,957
  • 96
  • 316
  • 522
  • Have you tried the suggested answer in [Get timezone used by datetime.datetime.fromtimestamp()](http://stackoverflow.com/questions/18812638/get-timezone-used-by-datetime-datetime-fromtimestamp)? – Frangipanes Aug 04 '16 at 15:44

1 Answers1

5

You should not use BYHOUR for this.

All you need is an RRULE:FREQ=DAILY but your DTSTART needs to be in local time with timezone id, not in UTC, ie something like:

DTSTART;TZID=America/New_York:20160805T180000
RRULE:FREQ=DAILY
Arnaud Quillaud
  • 4,420
  • 1
  • 12
  • 8
  • Doesn't doing this just not take dst into account? The UTC offset stays the same throughout the whole year. – Yitzchak Blank Jul 19 '18 at 10:25
  • 1
    As long as you have a correct VTIMEZONE definition corresponding to America/New_York, this will take DST change into account – Arnaud Quillaud Jul 19 '18 at 14:18
  • Anyone knows if the answer is only correct for the Python implementation? I couldn't find this in the RFCs and I wonder if the answer is correct for every implementation. – Michael Käfer Nov 20 '22 at 15:23