jmettraux/rufus-scheduler

[Question] Does scheduler runs at the specified time irrespective of day light savings for the provided timezone?

Closed this issue · 5 comments

Does below code trigger job at the specified time irrespective of daylight saving i.e at 12:05 am?

scheduler.cron '5 0 * * * America/Chicago' do

Hello,

if you look at https://www.timeanddate.com/time/change/usa/chicago the DST changes occur at 2 in the morning, so your schedule should trigger without interruption.

Just to be sure:

require 'rufus-scheduler'

# fugit is the library behind rufus-scheduler parsing
# https://github.com/floraison/fugit

# https://www.timeanddate.com/time/zone/usa/chicago
# https://www.timeanddate.com/time/change/usa/chicago

ENV['TZ'] = 'America/Chicago' # so that Time#to_s below stays in Chicago

cron = Fugit.parse_cron('5 0 * * * America/Chicago')

# CST to CDT

puts

t = Time.parse('2021-03-10')
10.times do
  t = cron.next_time(t)
  p t.to_s
end

# CDT to CST

puts

t = Time.parse('2021-11-05')
10.times do
  t = cron.next_time(t)
  p t.to_s
end

outputs:


"2021-03-10 00:05:00 -0600"
"2021-03-11 00:05:00 -0600"
"2021-03-12 00:05:00 -0600"
"2021-03-13 00:05:00 -0600"
"2021-03-14 00:05:00 -0600"
"2021-03-15 00:05:00 -0500"
"2021-03-16 00:05:00 -0500"
"2021-03-17 00:05:00 -0500"
"2021-03-18 00:05:00 -0500"
"2021-03-19 00:05:00 -0500"

"2021-11-05 00:05:00 -0500"
"2021-11-06 00:05:00 -0500"
"2021-11-07 00:05:00 -0500"
"2021-11-08 00:05:00 -0600"
"2021-11-09 00:05:00 -0600"
"2021-11-10 00:05:00 -0600"
"2021-11-11 00:05:00 -0600"
"2021-11-12 00:05:00 -0600"
"2021-11-13 00:05:00 -0600"
"2021-11-14 00:05:00 -0600"

Best regards.

@jmettraux I was running the above script with 'America/New_York' timezone instead of 'America/Chicago'.

"2021-03-10 04:30:00 -0500"
"2021-03-11 04:30:00 -0500"
"2021-03-12 04:30:00 -0500"
"2021-03-13 04:30:00 -0500"
"2021-03-14 03:30:00 -0500"    # Expected this to 04:30:00 -0400
"2021-03-15 03:30:00 -0500"
"2021-03-16 03:30:00 -0500"
"2021-03-17 03:30:00 -0500"
"2021-03-18 03:30:00 -0500"
"2021-03-19 03:30:00 -0500"

"2021-11-05 04:30:00 -0400"
"2021-11-06 04:30:00 -0400"
"2021-11-07 04:30:00 -0500"
"2021-11-08 04:30:00 -0500"
"2021-11-09 04:30:00 -0500"
"2021-11-10 04:30:00 -0500"
"2021-11-11 04:30:00 -0500"
"2021-11-12 04:30:00 -0500"
"2021-11-13 04:30:00 -0500"
"2021-11-14 04:30:00 -0500"

Everything else looks good except that in the first scenario hours changed. Does this look like a bug?

@harsha-flipp please give me the exact script you were running in a new issue. You seem to imply you have two scenarios, what are they? Please remember that I cannot read your mind.

@harsha-flipp no need to open another issue, I'll open it myself. Thanks for pointing at that issue.

Upgrade et-orbi gem to 1.2.6 to avoid the issue.