Permalink
Browse files

Focus on ENV['TZ'] if available, gh-228

  • Loading branch information...
1 parent 4b0b23d commit c46b12e0980767eb94c584ad5c34d13c6b9f111c @jmettraux committed Jan 4, 2017
Showing with 42 additions and 2 deletions.
  1. +1 −1 lib/rufus/scheduler/zotime.rb
  2. +41 −1 spec/zotime_spec.rb
@@ -285,7 +285,7 @@ def self.get_tzone(str)
# ok, it's a timezone then
ostr = str
- str = Time.now.zone if str == :current || str == :local
+ str = ENV['TZ'] || Time.now.zone if str == :current || str == :local
# utc_offset
View
@@ -96,6 +96,46 @@ def zone; _original_zone; end
current
)
end
+
+ [ # for gh-228
+
+ [ 'Asia/Tokyo', 'Asia/Tokyo' ],
+ [ 'Asia/Shanghai', 'Asia/Shanghai' ],
+ [ 'Europe/Zurich', 'Europe/Zurich' ],
+ [ 'Europe/London', 'Europe/London' ]
+
+ ].each do |zone, target|
+
+ it "returns the current timezone for :current in #{zone}" do
+
+ in_zone(zone) do
+
+ expect(
+ Rufus::Scheduler::ZoTime.get_tzone(:current)
+ ).to eq(
+ Rufus::Scheduler::ZoTime.get_tzone(target)
+ )
+ end
+ end
+ end
+
+
+# it 'flips burgers' do
+# p Rufus::Scheduler::CronLine.new('* * * * *').to_a
+# p Rufus::Scheduler::ZoTime.get_tzone(:current)
+# in_zone 'Asia/Shanghai' do
+# p ENV['TZ']
+# p Rufus::Scheduler::CronLine.new('* * * * *').to_a
+# p Rufus::Scheduler::ZoTime.get_tzone(:current)
+# end
+# ENV['TZ'] = 'Asia/Shanghai'
+# p Rufus::Scheduler::CronLine.new('* * * * *').to_a
+# #p Rufus::Scheduler::ZoTime.get_tzone('Asia/Shanghai')
+# #p Rufus::Scheduler::ZoTime.get_tzone('America/Bahia_Banderas')
+# #p Rufus::Scheduler::ZoTime.get_tzone('Asia/Shanghai').now
+# #p Rufus::Scheduler::ZoTime.get_tzone('America/Bahia_Banderas').now
+# p Rufus::Scheduler::ZoTime.get_tzone(:current)
+# end
end
describe '.new' do
@@ -202,7 +242,7 @@ def zone; _original_zone; end
zt = Rufus::Scheduler::ZoTime.parse('2015/03/08 01:59:59 Nada/Nada')
- expect(zt.zone.name).to eq('Europe/Minsk')
+ expect(zt.zone.name).to eq('Europe/Moscow')
end
end

0 comments on commit c46b12e

Please sign in to comment.