teambition / rrule-go

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

rrule.DTStart() not working as expected #30

Closed 0xfirefist closed 5 years ago

0xfirefist commented 5 years ago

I ran into an issue I was trying to set Rrule Dtstart, after generating Rrule from a string, but only date is set and not time. The program I was running :

func main() {
    rule := "FREQ=DAILY;DTSTART=19970902T010000Z;COUNT=10"
    r, _ := rrule.StrToRRule(rule)
    for _, i := range r.All() {
        fmt.Println(i)
    }
    fmt.Println()
    testrule := "FREQ=DAILY;COUNT=10"
    testr, _ := rrule.StrToRRule(testrule)
    testr.DTStart(time.Date(1997, 9, 2, 9, 1, 0, 0, time.UTC))
    for _, i := range testr.All() {
        fmt.Println(i)
    }
}

The output for the first and second rule is

1997-09-02 01:00:00 +0000 UTC
1997-09-03 01:00:00 +0000 UTC
1997-09-04 01:00:00 +0000 UTC
1997-09-05 01:00:00 +0000 UTC
1997-09-06 01:00:00 +0000 UTC
1997-09-07 01:00:00 +0000 UTC
1997-09-08 01:00:00 +0000 UTC
1997-09-09 01:00:00 +0000 UTC
1997-09-10 01:00:00 +0000 UTC
1997-09-11 01:00:00 +0000 UTC
1997-09-02 12:20:57 +0000 UTC
1997-09-03 12:20:57 +0000 UTC
1997-09-04 12:20:57 +0000 UTC
1997-09-05 12:20:57 +0000 UTC
1997-09-06 12:20:57 +0000 UTC
1997-09-07 12:20:57 +0000 UTC
1997-09-08 12:20:57 +0000 UTC
1997-09-09 12:20:57 +0000 UTC
1997-09-10 12:20:57 +0000 UTC
1997-09-11 12:20:57 +0000 UTC

I think the issue is when you generate rrule without DTStart , time.Now() is set as DTStart, and when you are setting DTStart only Date is set and not time