-
-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't seem to follow RFC 5545 with timezones #501
Comments
In the README https://github.com/jakubroztocil/rrule#timezone-support
So did you provide Luxon in your project? |
@sunshineo including Luxon doesn't seem to make a difference for this. See the following REPL: |
According to #427 |
Using 2.6.4 makes the The issue has to do with the "UTC" dates that are used to represent local time, as mentioned in the README:
It's confusing to use dates in UTC format that aren't intended to represent UTC time. Ideally, dates in local time would be represented with their respective timezone. |
So the project does not strictly follow the RFC 5545 spec. The README.md explained that it is a conscious choice because it's hard to deal with timezone in JS and don't want to introduce "large required 3rd party dependencies" @tmshkr , are you suggesting to follow the spec by writing timezone support code without using a 3rd party lib? |
@sunshineo it would probably help to add a required dependency, to deal with timezones and clear up any confusion. Day.js has pretty good timezone support and is only 2kb. |
I agree @tmshkr that it would be better if the timezone support is built in rather than the optional luxon lib which is 3.74 MB according to https://www.npmjs.com/package/luxon . The size could be why luxon wasn't baked in from the beginning |
I would like to take a stab at this but given my past experience of trying to contribute to open source project but get rejected/dismissed and even worse ignored, I prefer the owner @jakubroztocil to give a green light first for this direction. I see @KrisLau put this project on https://github.com/pickhardt/maintainers-wanted and I want to be a maintainer. I messaged @jakubroztocil on Twitter a few days ago but have not received any reply yet. |
Hello @sunshineo, I've just taken a swing at this with #508. Please review and test, and if this goes well I think I can add you as a maintainer. |
Yes, 100% agree. Would it be better to not use date objects at all, but rather parseable date strings perhaps? At the end of the day, we have the limitation that JS Date objects cannot carry timezone information. |
@davidgoli Day.js date objects seem to use a similar approach internally, with pseudo "UTC" dates, but they have the timezone attached to the object:
Day.js also has some useful methods for formatting display strings and converting back to actual UTC JavaScript Dates, which you can see in this REPL. I've attempted to start integrating Day.js into #502 but it seems that much of the codebase depends on the pseudo "UTC" dates, so a lot of the tests are failing now. |
Hi @tmshkr , you may take a look at @davidgoli 's PR at #508 which does not use Day.js and have all the tests still passing. However after read RFC 5545 for like an hour, I believe even with @davidgoli 's change, we are only supporting 2 of 3 formats specified in the spec: Timezone only matters when the type is date-time and in the spec there are 3 allowed formats:
We are still not support We can try to support |
I'm not too concerned with incomplete spec implementation at this point, but I would be alarmed about incorrect spec implementation. Still, the pseudo-UTC dates are fully convertible into local datetimes using the instructions in the README. It is necessary when using this library to ignore any JS Date builtin "timezone" concept, including UTC; they are not useful for you. Instead, you can use a 3rd party library (like day.js or luxon) to convert the output of RRule to the expected local timezone. If you follow those instructions, you should receive the correct dates. However, I believe it would be less correct for Rrule to return local Date objects. Rrule returns year, month, day, hour, minute, second and timezone - and all of these should be correct in combination; the "timezone" in the JS Date object does not carry necessary information here. |
An alternative I might propose is ditching the JS builtin |
@davidgoli I agree with your on the severity of incomplete vs incorrect. But would you call the library's current behavior of treating
If we actually throw error because But I don't think we should start rejecting input like ==Edit== |
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. |
It seems that in the RFC 5545 spec, when the
TZID
parameter is provided,DTSTART
should be specified in that timezone (i.e., not UTC, note that there is noZ
at the end). For example:rrule
seems to just pass the UTC time along, without converting it to the specified timezone:The text was updated successfully, but these errors were encountered: