Comments (3)
Hi, I spent some time today figuring this out. I have a fix working locally but it's not super great.
I think this has to do with func NewRRule
and the way it pre-calculates the timeset
on creation, and then when DtStart is set, it does not effect those pre-calculated values.
I have a unit test locally to reproduce the issue:
func TestSetTimezonesDtStartSticky(t *testing.T) {
set := &Set{}
rule, err := StrToRRule("FREQ=DAILY;COUNT=10;WKST=MO;BYHOUR=10;BYMINUTE=0;BYSECOND=0")
if err != nil {
panic(err)
}
set.RRule(rule)
dt := time.Date(2019, 3, 6, 0, 0, 0, 0, time.UTC)
set.DTStart(dt)
// set.All() returns events in my local timezone instead of UTC
for _, event := range set.All() {
if event.Location().String() != time.UTC.String() {
t.Errorf("Timezone set incorrectly on recurrence after DtStart set: [%s]", event.String())
}
}
}
But the way I fixed it was to recreate all the rrules and exrules when the DtStart is set:
// DTStart sets dtstart property for all rules in set
func (set *Set) DTStart(dtstart time.Time) {
var newrruleset []*RRule
var newexruleset []*RRule
set.dtstart = dtstart
for _, r := range set.rrule {
r.dtstart = dtstart
r.OrigOptions.Dtstart = dtstart
nr, err := NewRRule(r.OrigOptions)
if err != nil {
return
}
newrruleset = append(newrruleset, nr)
}
for _, xr := range set.exrule {
xr.dtstart = dtstart
xr.OrigOptions.Dtstart = dtstart
nxr, err := NewRRule(xr.OrigOptions)
if err != nil {
return
}
newexruleset = append(newexruleset, nxr)
}
set.rrule = newrruleset
set.exrule = newexruleset
}
I don't particularly like that fix, so if you have some ideas I'd love to hear them :).
from rrule-go.
@rickywiens thank you for your quick response!
I will see what I can cook up and create a pull request if I think it's good enough. 😄
from rrule-go.
@rickywiens @damoye I've created a pull request with a fix.
Thank you.
from rrule-go.
Related Issues (20)
- rrule.DTStart() not working as expected
- How to check if two RRules overlapping HOT 1
- UNTIL function is not working
- RRule.DTStart 函数实现有bug
- StrToRule doesn't follow RFC5545 HOT 1
- StrToRRule Does Not Apply Timezone to UNTIL and treats it as UTC HOT 1
- After generating a rule from a string, rule.DTStart does not work as expected [has workaround]
- set.After() works incorrect if timestamp has milliseconds HOT 3
- ExRule removed - but still shown in README HOT 1
- Behavior change in rrule.Set.Between from v1.5.0 to v1.6.0 HOT 2
- rruleset.After(time.Now()) with count 1 returns zero time value HOT 1
- Get last event time HOT 1
- Validating rrule HOT 1
- Is there anyway to see the `Before` relative to the `DTStart` HOT 1
- Wrong time for events far into the future HOT 2
- Nanoseconds in DTSTART breaks between method HOT 6
- 2.29 Not present HOT 3
- rrrule#All() generates wrong recurrences around DST HOT 3
- Question: Timezone conversion HOT 1
- Invalid timestamps for `HOURLY` interval RRULEs when DST change occurs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rrule-go.