parse-cron
parse-cron copied to clipboard
Preserve the timezone of the source when returning the time object
Thanks for this handy gem.
For my use case, I needed to be able to support a source time with a time zone that is different from the local one. This change preserves the time zone on the returned time object.
This breaks the use case where an alternate time_source
class is passed in that does not support the new
method with the same signature as the one for Time.new
.
AFAICT this PR also fixes a major bug: the cron parser skips the "fallback" hour of DST because the next
method jumps from "00:59:00 PDT" to "01:00:00 PST" as it does not track the timezone. With this PR:
2021-11-07 00:55:00 -0700
2021-11-07 00:56:00 -0700
2021-11-07 00:57:00 -0700
2021-11-07 00:58:00 -0700
2021-11-07 00:59:00 -0700
2021-11-07 01:00:00 -0700
2021-11-07 01:01:00 -0700
2021-11-07 01:02:00 -0700
2021-11-07 01:03:00 -0700
...snip...
2021-11-07 01:55:00 -0700
2021-11-07 01:56:00 -0700
2021-11-07 01:57:00 -0700
2021-11-07 01:58:00 -0700
2021-11-07 01:59:00 -0700
2021-11-07 02:00:00 -0700
2021-11-07 01:01:00 -0800
2021-11-07 01:02:00 -0800
2021-11-07 01:03:00 -0800
2021-11-07 01:04:00 -0800
Without the PR:
2021-11-07 00:55:00 -0700
2021-11-07 00:56:00 -0700
2021-11-07 00:57:00 -0700
2021-11-07 00:58:00 -0700
2021-11-07 00:59:00 -0700
2021-11-07 01:00:00 -0800
2021-11-07 01:01:00 -0800
2021-11-07 01:02:00 -0800
2021-11-07 01:03:00 -0800
...snip...
2021-11-07 01:57:00 -0800
2021-11-07 01:58:00 -0800
2021-11-07 01:59:00 -0800
2021-11-07 02:00:00 -0800
2021-11-07 01:01:00 -0800
2021-11-07 01:02:00 -0800
2021-11-07 01:03:00 -0800
2021-11-07 01:04:00 -0800
Awesome. Glad to hear that the timezone addition fixes DST issues.