Closed Grayda closed 6 years ago
For anyone reading this who may have this issue (and other issues with timezones using the library), my workaround was to use moment.js, get the UTC offset (in my case, 600 minutes, or 10 hours), and add that to all my times.
A somewhat-acceptable workaround, but not having to do this would be wonderful.
EDIT: I'm now using https://github.com/grayda/later (which is fork of https://github.com/mansami/later) which lets me set a tz
in my schedule. Everything then runs without me needing to do any addition or subtraction:
var sched = {
"schedules": [{/* Schedule goes in here as normal */}],
"exceptions": [],
"tz": "Australia/Melbourne" /* Or America/New_York, or whatever */
}
I'll close this issue, but I wouldn't mind knowing why the original bug occurs. I suspect it's an issue with a rollover function, but I can't seem to work it out, so I found a workaround.
I guess that this project isn't maintained anymore, so it's more of a question to anyone reading it, but:
My timezone is Australia/Melbourne and I'm passing in a schedule object (because the schedule is loaded via a user-editable JSON file). When I use UTC time, I can calculate ranges from January 1st through to December 31st, but if I switch to
localTime()
using the same schedule, it completely skips DST (the last instance occurs just before the start of April (when DST ends), and the next instance after that doesn't happen until October (when DST starts again)Here's some sample code:
This schedule should ring at 9:08am every weekday EXCEPT for a "Special Thursday", when it'll run at 9:28am.
(this schedule is part of a school bell system. The "Special Thursday" is determined by the school, so I have to set weeks manually)
Anyway, when I run the above code, I get the output listed in this pastebin
As you can see, the UTC times give 200 results, but the exact same schedule gives only 95, with the entirety of April through to September missing
If I remove the
wy
from the schedule, it calculates correctly, and I get the same amount of instances for both.Anyone have any ideas what's going on here? I had a look at the
weekOfYear
function, but my brain isn't in the right place to work out what's going on.