jazzband / django-recurrence

Utility for working with recurring dates in Django.
https://django-recurrence.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
491 stars 190 forks source link

Generating Recurrence Programmatically or Via Field #171

Open bobozar opened 4 years ago

bobozar commented 4 years ago

From the API, the frontend will send me, start_date, end_date and time with each having a datetime obj. The interval should be rrule text. example, FREQ=DAILY;INTERVAL=2;COUNT=4 . Now, how do I pass the interval text value, alongside the start and end datetime to get the recurrence between the two dates?

Something like below example.

    start_rdt = utc_start_date_time
    end_rde = utc_end_date_time
    interval =  "FREQ=DAILY;INTERVAL=2;COUNT=4"
    mypattern = recurrence.Recurrence(rrules=[recurrence.Rule(interval)])]).between(start_rdt, end_rde,
    dtstart=start_rdt, inc=True)
    return mypattern

Or can I merge the interval text string with start and end datetime as value to the RecurrenceField?