Calendar.create#

classmethod Calendar.create(freq='D', *, starting=None, ending=None, rrule=None, dtype=None, **kwargs)#

Create a new calendar, wrapping dateutil.rrule

Parameters:
  • freq (str, int) –

    The calendar frequency; one of:

    • Y for yearly

    • M for monthly

    • W for weekly (or any dayised variant, e.g. W-MON)

    • D for daily

    • B for daily except for Saturday and Sunday

    • H for hourly

    • MIN for minutely

    • S for secondly

    or any dateutil.rrule constant (e.g. dateutil.rrule.MONTHLY)

  • starting (datetime) – The starting date in the calendar. Alias for dstart in dateutil.rrule.rrule.

  • ending (datetime) – The last date in the calendar. Alias for until in dateutil.rrule.rrule.

  • rrule (str, dateutil.rrule.rrule) – A recurrence rule. If given a str, this will be evaluated as a dateutil.rrule.rrulestr with the dstart

  • dtype (None, type) – The datetime type (e.g. pd.Timestamp). If None is provided, defaults to datetime.datetime, which is the default of the :dateutil.rrule` library.

  • **kwargs (dict) – additional arguments to pass to dateutil.rrule.rrule

Examples

>>> import doubledate as dtwo

# every day in 2023
>>> dtwo.Calendar.create(
...     "D",
...     starting=dtwo.date(2023, 1, 1),
...     until=dtwo.date(2023, 12, 31)
... )
<doubledate.calendar.Calendar at 0x17045b0f430>

# the first day each month in 2018-2023
>>> dtwo.Calendar.create(
...     "M",
...     starting=dtwo.date(2018, 1, 1),
...     until=dtwo.date(2023, 12, 31)
... )
<doubledate.calendar.Calendar at 0x17045b0f430>

# the first Monday each month in 2018-2023
>>> dtwo.Calendar.create(
...     "M",
...     starting=dtwo.date(2018, 1, 1),
...     until=dtwo.date(2023, 12, 31),
...     byweekday=dtwo.MO
... )
<doubledate.calendar.Calendar at 0x17045b0f430>