GithubHelp home page GithubHelp logo

Comments (5)

Reeywhaar avatar Reeywhaar commented on June 12, 2024

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.

sdetweil avatar sdetweil commented on June 12, 2024

@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.

Reeywhaar avatar Reeywhaar commented on June 12, 2024

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.

jonnytest1 avatar jonnytest1 commented on June 12, 2024

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.

juni0r avatar juni0r commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.