jazzband / django-recurrence

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

EXRULE not working... #37

Open msander opened 9 years ago

msander commented 9 years ago

I have created a rule that should occur every year from 1st to 10th of december.

Rule definition:

RRULE:FREQ=MONTHLY;BYMONTHDAY=1,2,3,4,5,6,7,8,9,10 EXRULE:FREQ=YEARLY;BYMONTH=1,2,3,4,5,6,7,8,9,10,11

In [100]: robj = recurrence.deserialize(rule) In [102]: robj.occurrences().after(datetime.datetime.utcnow()) Out[102]: datetime.datetime(2015, 3, 5, 18, 8, 40)

any ideas?

msander commented 9 years ago

I think the problem was that I have no reference date in my application; only rules from which I want to generate dates.

I solved this by monkey-patching the widget:

var old_set_by_month = recurrence.widget.RuleYearlyForm.prototype.set_bymonth;

recurrence.widget.RuleYearlyForm.prototype.set_bymonth = function() {
    var monthdays=[];
    for(var i=1; i<=31; i++) monthdays.push(i);
    this.rule.bymonthday = monthdays;

    old_set_by_month.apply(this);
};

I'm not sure whether this is only useful for my application or in general?

dominicrodger commented 9 years ago

I'm a little confused - you posted this on 4th March, so the next date in your recurrence set looks to me like it should be 5th March. What were you expecting to get?

msander commented 9 years ago

My goal was to set "Every month except 1-11 on every day 1-10", i.e. 1.-10. december every year. I guess it is not supposed to work without a first date.

dominicrodger commented 9 years ago

Apologies @msander - I entirely missed the point of this bug report - that you were talking about exclusion rules rather than inclusion rules.

Annual rules (whether inclusion or exclusion rules) use the day of the month provided in dtstart. So, if I set dtstart to (say) 4th March 2015, I'll get every day 1-3, 5-10 in January to November, and 1-10 in December. In other words, your exclusion just excludes whichever day of the month dtsart is set to (4th of the month, in this example).

Does that make sense?

I agree that this behaviour is probably not useful, not least because it makes what you're trying to do impossible to accomplish, as far as I can see. I'll see if I can think of a way to fix this.