breejs / later

*Maintained fork of Later.* A javascript library for defining recurring schedules and calculating future (or past) occurrences for them. Includes support for using English phrases and Cron schedules. Works in Node and in the browser.
https://breejs.github.io/later/
MIT License
134 stars 13 forks source link

[discussion] multiple time zone support #28

Open eavdmeer opened 1 year ago

eavdmeer commented 1 year ago

This library cannot be effectively used over multiple time zones

Currently, later supports only two possible time zone: localTime and UTC. For most use cases, this is likely enough, but I ran into a case where it is basically mostly useless. This is the situation:

I want to run later in the client's browser to expand a full time line of all jobs that will be run in that particular day in Europe/Amsterdam. Now this presents a huge problem. I cannot use localTime, as that varies, depending on the user. I also can't use UTC as that will completely break crontab entries that run on specific week days like this :

30 0 * * 6

This is supposed to run at 00:30 every Saturday. However, 0:30 on Saturday in UTC+2 will be 22:30 on Friday in UTC, so evaluating that crontab entry in a later schedule will not run it at 0:30 UTC+2 on Saturday.

I've been trying to work around this issue. Bottom line is that you cannot evaluate crontab entries in a different time zone and get proper results. So a UTC+2 schedule cannot be evaluated in either UTC or UTC+3 successfully without breaking day-of-week support.

I believe later would benefit from an extension so it supports any time zone through something like later.date.timeZone('Europe/Amsterdam') to make sure the crontab entry gets evaluated in the correct time zone.

Edit: I am aware that expanding the crontab entries on the server would work in this case. However, this crontab has several hundred entries. This would result in many thousands of entries, thus increasing the traffic by quite a bit.

Checklist