You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>>list(rrule(MONTHLY, byweekday= [SU(1)],dtstart=parse("23rd May 2019"), until=parse('30th Jun 2019')))
[datetime.datetime(2019, 6, 2, 0, 0)]
In fact, it skips to the next month and gives first Sunday of next month. It seems its due to MONTHLY freq, but then how to handle this type of scenarios?
The text was updated successfully, but these errors were encountered:
byweekday refers to the nth occurrence in the frequency, not the nth occurrence in the rule. The above rule therefore matches the first Sunday of each month. The only match in your period is therefore the first Sunday of June.
I am not sure why they are not in the current documentation, but I think what you should use in this case are the after(dt, inc=False) and xafter(dt, n, inc=Flase) methods. They return the first occurrence and the first n occurrences respectively. If you want dt to be included if it matches the rule you have to specify inc=True.
fromdateutil.parserimportparsefromdateutil.rruleimport*dtstart=parse("23rd May 2019")
rr=rrule(WEEKLY, byweekday=SU, dtstart=dtstart)
print(rr.after(dtstart, inc=True))
A query to print all occurrence of a particular weekday in a specified period works.
Ex: - Get all Sundays between 23rd May 2019 and 30th June 2019.
But if you want specific occurrence, it fails.
Ex:- Get 1st Sunday in the same period
In fact, it skips to the next month and gives first Sunday of next month. It seems its due to MONTHLY freq, but then how to handle this type of scenarios?
The text was updated successfully, but these errors were encountered: