'RRULE UNTIL values must be specified in UTC when DTSTART is timezone-aware'
, but here the UNTIL
value is in UTC, while DTSTART
is tz-naive.
Was hoping to get a bit of feedback on designing a rrule
. I'm wondering what the best way to create a minutely rule is but omit entire days. So for example get 5 minute intervals every weekday between some time but omit certain holidays. I thought of using something like
INTERVAL = 5
BUCKETS = int(60 / INTERVAL * 24)
WEEKDAYS = (MO, TU, WE, TH, FR)
nyd = rrule(MONTHLY, dtstart=datetime(2019, 1, 1, 0, 0), bymonth=1, byminute=range(0, 59, INTERVAL), byhour=range(0,24), bysetpos=range(1, BUCKETS + 1), byweekday=WEEKDAYS, count=300)
which works, but I'm wondering if this is some non recommended hackery. The reason I ask is because bysetpos
only supports values up until 366. For minutely and secondly data you could have situations where you want to use bysetpos
up to 1440 and 86400 respectively, so I'm wondering if bysetpos
is not intended for this use?
rruleset
with an exrule
.
INTERVAL = 5
BUCKETS = int(60 / INTERVAL * 24)
WEEKDAYS = (MO, TU, WE, TH, FR)
rrule_base = rrule(MINUTELY, dtstart=datetime(2019, 1, 1, 0, 0), count=300, byweekday=WEEKDAYS)
rrset = rruleset()
rrset.rrule(rrule_base)
for dt in holidays:
rrset.exrule(rrule_base.replace(dtstart=dt, until=(dt + timedelta(days=1)), count=None))
for dt in holidays:
for inst in rrule_base.between(dt, dt + timedelta(days=1)):
rrset.exdate(inst)
dateutil
a few times: https://ganssle.io/talks/#python-dateutil-talk
Following up on your comments about bysetpos
and the RFC, I don't see any mention of restricting this. My guess is that it was implemented with DAILY frequency in mind? The docstrings also don't mention anything
If given, it must be either an integer, or a sequence of integers,
positive or negative. Each given integer will specify an occurrence
number, corresponding to the nth occurrence of the rule inside the
frequency period. For example, a bysetpos of -1 if combined with a
MONTHLY frequency, and a byweekday of (MO, TU, WE, TH, FR), will
result in the last work day of every month.
list(rrule(MINUTELY, dtstart=datetime(2019, 1, 1, 0, 0), bysetpos=367, count=3, byweekday=MO))