teambition / rrule-go

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

Timezones and daylight savings #9

Closed fallais closed 6 years ago

fallais commented 6 years ago

Hello,

Let's take the France for the example. I create a recurrent event that start the 19 March to the 2 April, every Monday and Wednesday, at 14h. But, in France, the 25 March, a daylight saving is observed.

And my rrule.All() is wrong.

How can I handle this case please ? Thanks a lot for this library !

damoye commented 6 years ago

Sorry, I am a little busy recently. I will check this case after work.

damoye commented 6 years ago

Please show my your code, output and your expected output.

fallais commented 6 years ago

My case is exactly this one : https://github.com/jakubroztocil/rrule/issues/157 My start and end date occurs between a daylight saving.

But the occurrences do not take this is in account.

damoye commented 6 years ago
package main

import (
    "fmt"
    "time"

    rrule "github.com/wangjohn/rrule-go"
)

func main() {
    r, err := rrule.NewRRule(rrule.ROption{
        Freq:      rrule.WEEKLY,
        Byweekday: []rrule.Weekday{rrule.SU},
        Byhour:    []int{16},
        Byminute:  []int{0},
        Dtstart:   time.Date(2016, 8, 1, 0, 0, 0, 0, time.Local),
    })
    if err != nil {
        panic(err)
    }
    for _, i := range r.Between(time.Date(2016, 8, 1, 0, 0, 0, 0, time.Local), time.Date(2016, 11, 1, 0, 0, 0, 0, time.Local), true) {
        fmt.Println(i)
    }
}
2016-08-07 16:00:00 +1000 AEST
2016-08-14 16:00:00 +1000 AEST
2016-08-21 16:00:00 +1000 AEST
2016-08-28 16:00:00 +1000 AEST
2016-09-04 16:00:00 +1000 AEST
2016-09-11 16:00:00 +1000 AEST
2016-09-18 16:00:00 +1000 AEST
2016-09-25 16:00:00 +1000 AEST
2016-10-02 16:00:00 +1100 AEDT
2016-10-09 16:00:00 +1100 AEDT
2016-10-16 16:00:00 +1100 AEDT
2016-10-23 16:00:00 +1100 AEDT
2016-10-30 16:00:00 +1100 AEDT

My output is right for that case.

fallais commented 6 years ago

Hello, is it working with the rrule.All() too ?

damoye commented 6 years ago

Yes.

damoye commented 6 years ago

If you really got a wrong output, please show me the code.

fallais commented 6 years ago

Ok, let me try. Another question : Why is the package name that you use not from teambition ?

damoye commented 6 years ago

Sorry. I use another contributor's code. It doesn't matter.

fallais commented 6 years ago

Thanks a lot !