#require 'rufus-scheduler'
require 'fugit'
# https://www.timeanddate.com/time/zone/usa/chicago
# https://www.timeanddate.com/time/change/usa/chicago
# https://www.timeanddate.com/time/zone/usa/newyork
# https://www.timeanddate.com/time/change/usa/newyork
#ENV['TZ'] = 'America/Chicago' # so that Time#to_s below stays in Chicago
ENV['TZ'] = 'America/New_York' # so that Time#to_s below stays in New York
c = Fugit.parse_cron('5 0 * * *')
#c = Fugit.parse_cron('30 4 * * *')
p [ :tz, ENV['TZ'] ]
p [ :ruby, RUBY_VERSION, RUBY_PLATFORM ]
p [ :tzinfo, TZInfo::VERSION ]
p [ :fugit, Fugit::VERSION ]
# into daylight saving time
puts
t = Time.parse('2021-03-10')
10.times do
t = c.next_time(t)
p t.to_s
end
# out of daylight saving time
puts
t = Time.parse('2021-11-05')
10.times do
t = c.next_time(t)
p t.to_s
end
America/Chicago yields the result below, which correctly goes into DST and out of it.
As pointed at by @harsha-flipp in https://github.com/jmettraux/rufus-scheduler/issues/329
Given the script
America/Chicago
yields the result below, which correctly goes into DST and out of it.But for
America/New_York
Also have to try with
"30 4 * * *"
as OP did.