From f7832c963233d7b24e6d2deb7e251b8c706d3c00 Mon Sep 17 00:00:00 2001 From: "NARUSE, Yui" Date: Wed, 2 Dec 2015 18:52:32 +0900 Subject: [PATCH] Add a test case for timezone transition --- spec/perfect_sched_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/perfect_sched_spec.rb b/spec/perfect_sched_spec.rb index 6c27081..3a6811e 100644 --- a/spec/perfect_sched_spec.rb +++ b/spec/perfect_sched_spec.rb @@ -47,5 +47,20 @@ it do expect{PerfectSched.next_time('0 * * * *', 0, 'JST-9')}.to raise_error(ArgumentError) end + + context 'DST 2015' do + it 'can go through America/Los_Angeles transition' do + t0 = Time.new(2015, 3, 8, 1, 59, 59, -8*3600) + t1 = Time.new(2015, 3, 9, 2, 0, 0, -7*3600) # 2015-03-08T02:00:00 doesn't exist + ts = PerfectSched.next_time('* 2 * * *', t0.to_i, 'America/Los_Angeles') + expect(ts).to eq(t1.to_i) + end + it 'can go through America/Los_Angeles transition' do + t0 = Time.new(2015, 11, 1, 1, 0, 0, -7*3600) + t1 = Time.new(2015, 11, 1, 1, 0, 0, -8*3600) # 2015-11-01T01:00:00 exists twice + ts = PerfectSched.next_time('0 1 * * *', t0.to_i, 'America/Los_Angeles') + expect(ts).to eq(t1.to_i) + end + end end end