teambition / rrule-go

Go library for working with recurrence rules for calendar dates.
MIT License
310 stars 57 forks source link

set.After() works incorrect if timestamp has milliseconds #40

Closed irlndts closed 4 years ago

irlndts commented 4 years ago

Hello, thank you for your lib, I found it very useful. I use it on one of my projects and found a small incorrect behaviour (as I can see it).

if I have a rule something like that

    rule := rrule.ROption{
        Freq:     rrule.Frequency(recurrence.Frequency_MINUTELY),
        Count:    1,
        Bysecond: []int{10, 20, 30, 40, 59},
    }
   // RRULE:FREQ=MINUTELY;COUNT=1;BYSECOND=10,20,30,40,59

and from-time has milliseconds

from := time.Now() // 2020-07-08 17:43:20.42899 +0300 MSK m=+0.001564527

and the seconds are equal to any of the Bysecond array (20 as in the example) so set.After() will return nil value

t := set.After(from, true)
// t == nil

I expect an event at 17:43:30.

Works correctly if I truncate milliseconds from the timestamp.

zensh commented 4 years ago

Hi, remove Count option and try it again

irlndts commented 4 years ago

Hi, it helps, yes. But the Count option is infinite now.

zensh commented 4 years ago

@irlndts The default DTSTART is time.Now, and your option Count: 1 is too few to get the expected value.