Comments (5)
Basically this library is full of footguns because it tries to rely on bare Date
object and stores everything in utc. If it use moment
or analog it would be like 4x smaller and cleaner. So this is it. Number of issues says it all.
from rrule.
@Reeywhaar general criticism is not helpful. you are welcome to show your talent and provide a better solution. I don't have time or the inclination
our app uses an ICS parser that uses this library. and I support the calendar component, so I'm sorta stuck.
from rrule.
In my case what I've done is stopped using tzid
parameter in rrule completely. What I do now is I receive dtstart, assign it local timezone (in case of moment
library this is moment(dtstart).local(true)
) so 05:00 in some dtstart timezone
becomes 05:00 in whatever local time it is
. Then I find occurences and reassign original timezone to received results: results.map((d: Date) => moment(d).tzid(dtstartTimezone, true) )
.
So basically I don't use anything tz related in rrule because this is unreliable as hell. All incoming parameters in rrule are in local timezone.
Local timezone is treated by rrule as timezone without offset, i.e literal time. So 09:00 remains 09:00 no matter what dst mark it passes.
Also in case of finding occurences you have to convert incoming parameters (after and before). First to timezone of dtstart, and then assign local timezone.
from rrule.
here is my fix :
`
from dateutil.rrule import rrulestr
from datetime import datetime
import sys
inputtime = sys.argv[1]
rules = sys.argv[2].split("RRULE:")[1] #
start = datetime.fromtimestamp(float(inputtime)/1000)
ruleObj = rrulestr(rules, dtstart=start)
next = ruleObj.after(datetime.now())
print(next.isoformat())
const response = spawnSync(python
, [join(__dirname, "rrule.py"), ${+date}
, rule], { encoding: "utf8" })
return new Date(response.stdout.trim())
`
works liek a charm 🤣 (sry i just spent half a day on this )
from rrule.
I'm sure this library can do a lot of things. Creating date recurrences that respect timezones and daylight saving times unfortunately isn't one of them. If you want to do this, you've picked the wrong tool.
Anyone who ends up here, might want to check out rschedule. It comes with adapters for many popular date libraries, such as moment.js and Luxon, as well as vanilla JS Date. It doesn't see much activity and documentation isn't exactly exhaustive, but from the few usage examples and the codesandbox one will quickly figure out how to use it. It sports a modular approach and pluggable features, such as JSON and iCal support.
Hope this helps.
from rrule.
Related Issues (20)
- byweekday undefined has different behavior than empty array
- Broken the link HOT 2
- Combining MINUTELY with BYHOUR and BYDAY misses out days when used with just one BYHOUR value
- Possible solution for "Invalid UNTIL value"
- [bug] Decimal interval creates an infinite loop HOT 2
- Using RRule.after and RRule.between with Hermes JS Engine HOT 1
- RRrule timezone issue
- Exdates returning UTC date without TZID offset HOT 3
- rrule.after method doesn't work if there is a TZID in the dtstart HOT 1
- Occurences are wrong when DTStart includes timezone
- rrulestr constructor with options doesn't flow through DTStart or TZID
- Is this still being actively maintained?
- working with Evolution Mail and web calendar using RRULE fail because of X-EVOLUTION-ENDDATE in rrule HOT 2
- Timezone issue
- How can we define a repeating rule that occurs Yearly and spans for a month - ex) Black History Month HOT 1
- Given an RRuleSet, how can we modify a single event in a recurrence HOT 1
- RRule is missing next occurrence HOT 1
- Invalid rrule string generated for single-digit year dtstart dates (ex: "0002-01-01") HOT 1
- Bower install rrule does not seem to generate a dist/es5/rrule.js 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.