rufus-scheduler 3.0.9 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -102,5 +102,27 @@ describe Rufus::Scheduler::CronJob do
102
102
  end
103
103
  end
104
104
  end
105
+
106
+ describe '.next_time' do
107
+
108
+ it 'returns the next trigger time' do
109
+
110
+ n = Time.now
111
+ nt = Time.parse("#{n.year}-#{n.month + 1}-01")
112
+
113
+ expect(
114
+ @scheduler.schedule_cron('* * 1 * *', lambda {}).next_time
115
+ ).to eq(nt)
116
+ end
117
+
118
+ it 'returns the next trigger time (first_at => Time)' do
119
+
120
+ ft = Time.parse('2100-12-31')
121
+
122
+ job = @scheduler.schedule_cron('* * 1 * *', :first_at => ft) {}
123
+
124
+ expect(job.next_time).to eq(ft)
125
+ end
126
+ end
105
127
  end
106
128
 
@@ -49,6 +49,20 @@ describe Rufus::Scheduler::EveryJob do
49
49
  expect(times[2] - times[1]).to be < 3.4
50
50
  end
51
51
 
52
+ context 'summer time' do
53
+
54
+ it 'triggers correctly through a DST transition' do
55
+
56
+ job = Rufus::Scheduler::EveryJob.new(@scheduler, '1m', {}, lambda {})
57
+ t1 = ltz('America/Los_Angeles', 2015, 3, 8, 1, 55)
58
+ t2 = ltz('America/Los_Angeles', 2015, 3, 8, 3, 05)
59
+ job.next_time = t1
60
+ occurrences = job.occurrences(t1, t2)
61
+
62
+ expect(occurrences.length).to eq(11)
63
+ end
64
+ end
65
+
52
66
  context 'first_at/in' do
53
67
 
54
68
  it 'triggers for the first time at first_at' do
@@ -189,6 +189,7 @@ describe Rufus::Scheduler::RepeatJob do
189
189
 
190
190
  sleep 0.7
191
191
 
192
+ #p Time.now.to_f
192
193
  #p n.to_f
193
194
  #p job.first_at.to_f
194
195
  #p ft.to_f
@@ -12,53 +12,51 @@ describe Rufus::Scheduler do
12
12
 
13
13
  describe '.parse' do
14
14
 
15
- def parse(s, opts={})
16
- Rufus::Scheduler.parse(s, opts)
17
- end
15
+ def pa(s, opts={}); Rufus::Scheduler.parse(s, opts); end
18
16
 
19
17
  it 'parses duration strings' do
20
18
 
21
- expect(parse('1.0d1.0w1.0d')).to eq(777600.0)
19
+ expect(pa('1.0d1.0w1.0d')).to eq(777600.0)
22
20
  end
23
21
 
24
22
  it 'parses datetimes' do
25
23
 
26
24
  # local
27
25
 
28
- expect(parse('Sun Nov 18 16:01:00 2012').strftime('%c')).to eq(
26
+ expect(pa('Sun Nov 18 16:01:00 2012').strftime('%c')).to eq(
29
27
  'Sun Nov 18 16:01:00 2012'
30
28
  )
31
29
  end
32
30
 
33
31
  it 'parses datetimes with timezones' do
34
32
 
35
- expect(parse('Sun Nov 18 16:01:00 2012 Japan').getutc.strftime('%c')).to eq(
36
- 'Sun Nov 18 07:01:00 2012'
37
- )
33
+ expect(
34
+ pa('Sun Nov 18 16:01:00 2012 Asia/Singapore').getutc.strftime('%c %z')
35
+ ).to eq('Sun Nov 18 08:01:00 2012 +0000')
38
36
 
39
- expect(parse('Sun Nov 18 16:01:00 2012 Zulu').getutc.strftime('%c')).to eq(
37
+ expect(pa('Sun Nov 18 16:01:00 2012 Zulu').getutc.strftime('%c')).to eq(
40
38
  'Sun Nov 18 16:01:00 2012'
41
39
  )
42
40
 
43
- expect(parse('Sun Nov 18 16:01:00 Japan 2012').getutc.strftime('%c')).to eq(
44
- 'Sun Nov 18 07:01:00 2012'
45
- )
41
+ expect(
42
+ pa('Sun Nov 18 16:01:00 Asia/Singapore 2012').getutc.strftime('%c %z')
43
+ ).to eq('Sun Nov 18 08:01:00 2012 +0000')
46
44
 
47
- expect(parse('Japan Sun Nov 18 16:01:00 2012').getutc.strftime('%c')).to eq(
48
- 'Sun Nov 18 07:01:00 2012'
49
- )
45
+ expect(
46
+ pa('Asia/Singapore Sun Nov 18 16:01:00 2012').getutc.strftime('%c %z')
47
+ ).to eq('Sun Nov 18 08:01:00 2012 +0000')
50
48
 
51
- expect(parse('Sun Nov 18 16:01:00 2012 America/New_York').getutc.strftime('%c')).to eq(
52
- 'Sun Nov 18 21:01:00 2012'
53
- )
49
+ expect(
50
+ pa('Sun Nov 18 16:01:00 2012 America/New_York').getutc.strftime('%c %z')
51
+ ).to eq('Sun Nov 18 21:01:00 2012 +0000')
54
52
  end
55
53
 
56
54
  it 'parses datetimes with named timezones' do
57
55
 
58
- expect(parse(
56
+ expect(pa(
59
57
  'Sun Nov 18 16:01:00 2012 Europe/Berlin'
60
58
  ).strftime('%c %z')).to eq(
61
- 'Sun Nov 18 15:01:00 2012 +0000'
59
+ 'Sun Nov 18 16:01:00 2012 +0100'
62
60
  )
63
61
  end
64
62
 
@@ -66,32 +64,32 @@ describe Rufus::Scheduler do
66
64
 
67
65
  localzone = Time.now.strftime('%z')
68
66
 
69
- expect(parse('Sun Nov 18 16:01:00 2012').strftime('%c %z')).to eq(
70
- "Sun Nov 18 16:01:00 2012 #{localzone}"
71
- )
67
+ expect(
68
+ pa('Nov 18 16:01:00 2012').strftime('%c %z')
69
+ ).to eq("Sun Nov 18 16:01:00 2012 #{localzone}")
72
70
  end
73
71
 
74
72
  it 'parses cronlines' do
75
73
 
76
- out = parse('* * * * *')
74
+ out = pa('* * * * *')
77
75
 
78
76
  expect(out.class).to eq(Rufus::Scheduler::CronLine)
79
77
  expect(out.original).to eq('* * * * *')
80
78
 
81
- expect(parse('10 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
82
- expect(parse('* 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
79
+ expect(pa('10 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
80
+ expect(pa('* 23 * * *').class).to eq(Rufus::Scheduler::CronLine)
83
81
  end
84
82
 
85
83
  it 'raises on unparseable input' do
86
84
 
87
85
  expect {
88
- parse('nada')
86
+ pa('nada')
89
87
  }.to raise_error(ArgumentError, 'couldn\'t parse "nada"')
90
88
  end
91
89
 
92
90
  it 'does not use Chronic if not present' do
93
91
 
94
- t = parse('next monday 7 PM')
92
+ t = pa('next monday 7 PM')
95
93
 
96
94
  n = Time.now
97
95
 
@@ -104,7 +102,7 @@ describe Rufus::Scheduler do
104
102
 
105
103
  with_chronic do
106
104
 
107
- t = parse('next monday 7 PM')
105
+ t = pa('next monday 7 PM')
108
106
 
109
107
  expect(t.wday).to eq(1)
110
108
  expect(t.hour).to eq(19)
@@ -117,7 +115,7 @@ describe Rufus::Scheduler do
117
115
 
118
116
  with_chronic do
119
117
 
120
- t = parse('monday', :context => :past)
118
+ t = pa('monday', :context => :past)
121
119
 
122
120
  expect(t.wday).to eq(1)
123
121
  expect(t).to be < Time.now
@@ -107,7 +107,7 @@ describe Rufus::Scheduler do
107
107
 
108
108
  job = @scheduler.at('2050-12-12 20:30 Europe/Berlin', :job => true) {}
109
109
 
110
- expect(job.time.strftime('%c %z')).to eq('Mon Dec 12 19:30:00 2050 +0000')
110
+ expect(job.time.strftime('%c %z')).to eq('Mon Dec 12 20:30:00 2050 +0100')
111
111
  end
112
112
 
113
113
  it 'accepts a Chronic string (if Chronic is present)' do
@@ -602,7 +602,10 @@ describe Rufus::Scheduler do
602
602
 
603
603
  j0 = @scheduler.schedule_every '1m', :times => 10 do; end
604
604
 
605
- h = @scheduler.occurrences(Time.now + 4 * 60, Time.now + 16 * 60)
605
+ t0 = Time.parse((Time.now + 5 * 60).strftime('%Y-%m-%d %H:%M:01'))
606
+ t1 = t0 + 12 * 60 - 1
607
+
608
+ h = @scheduler.occurrences(t0, t1)
606
609
 
607
610
  expect(h[j0].size).to eq(6)
608
611
  end
@@ -107,7 +107,7 @@ RSpec::Matchers.define :be_within_1s_of do |expected|
107
107
  end
108
108
  end
109
109
 
110
- failure_message_for_should do |actual|
110
+ failure_message do |actual|
111
111
 
112
112
  if actual.respond_to?(:asctime)
113
113
  "expected #{actual.inspect} to be within 1 second of #{expected}"
@@ -0,0 +1,396 @@
1
+
2
+ #
3
+ # Specifying rufus-scheduler
4
+ #
5
+ # Wed Mar 11 21:17:36 JST 2015, quatre ans...
6
+ #
7
+
8
+ require 'spec_helper'
9
+
10
+
11
+ describe Rufus::Scheduler::ZoTime do
12
+
13
+ describe '.new' do
14
+
15
+ it 'accepts an integer' do
16
+
17
+ zt = Rufus::Scheduler::ZoTime.new(1234567890, 'America/Los_Angeles')
18
+
19
+ expect(zt.seconds.to_i).to eq(1234567890)
20
+ end
21
+
22
+ it 'accepts a float' do
23
+
24
+ zt = Rufus::Scheduler::ZoTime.new(1234567890.1234, 'America/Los_Angeles')
25
+
26
+ expect(zt.seconds.to_i).to eq(1234567890)
27
+ end
28
+
29
+ it 'accepts a Time instance' do
30
+
31
+ zt =
32
+ Rufus::Scheduler::ZoTime.new(
33
+ Time.utc(2007, 11, 1, 15, 25, 0),
34
+ 'America/Los_Angeles')
35
+
36
+ expect(zt.seconds.to_i).to eq(1193930700)
37
+ end
38
+ end
39
+
40
+ #it "flips burgers" do
41
+ # puts "---"
42
+ # t0 = ltz('America/New_York', 2004, 10, 31, 0, 30, 0)
43
+ # t1 = ltz('America/New_York', 2004, 10, 31, 1, 30, 0)
44
+ # p t0
45
+ # p t1
46
+ # puts "---"
47
+ # zt0 = Rufus::Scheduler::ZoTime.new(t0, 'America/New_York')
48
+ # zt1 = Rufus::Scheduler::ZoTime.new(t1, 'America/New_York')
49
+ # p zt0.time
50
+ # p zt1.time
51
+ # puts "---"
52
+ # zt0.add(3600)
53
+ # p [ zt0.time, zt0.time.zone ]
54
+ # p [ zt1.time, zt1.time.zone ]
55
+ # #puts "---"
56
+ # #zt0.add(3600)
57
+ # #zt1.add(3600)
58
+ # #p [ zt0.time, zt0.time.zone ]
59
+ # #p [ zt1.time, zt1.time.zone ]
60
+ #end
61
+
62
+ describe '#time' do
63
+
64
+ it 'returns a Time instance in with the right offset' do
65
+
66
+ zt = Rufus::Scheduler::ZoTime.new(1193898300, 'America/Los_Angeles')
67
+ t = zt.time
68
+
69
+ expect(t.strftime('%Y/%m/%d %H:%M:%S %Z')
70
+ ).to eq('2007/10/31 23:25:00 PDT')
71
+ end
72
+
73
+ # New York EST: UTC-5
74
+ # summer (dst) EDT: UTC-4
75
+
76
+ it 'chooses the non DST time when there is ambiguity' do
77
+
78
+ t = ltz('America/New_York', 2004, 10, 31, 0, 30, 0)
79
+ zt = Rufus::Scheduler::ZoTime.new(t, 'America/New_York')
80
+ zt.add(3600)
81
+ ztt = zt.time
82
+
83
+ expect(ztt.to_i).to eq(1099204200)
84
+
85
+ if ruby18?
86
+ expect(ztt.strftime('%Y/%m/%d %H:%M:%S %Z %z')
87
+ ).to eq('2004/10/31 01:30:00 EST -0500')
88
+ else
89
+ expect(ztt.strftime('%Y/%m/%d %H:%M:%S %Z %z')
90
+ ).to eq('2004/10/31 01:30:00 EST -0500')
91
+ end
92
+ end
93
+ end
94
+
95
+ describe '#utc' do
96
+
97
+ it 'returns an UTC Time instance' do
98
+
99
+ zt = Rufus::Scheduler::ZoTime.new(1193898300, 'America/Los_Angeles')
100
+ t = zt.utc
101
+
102
+ expect(t.to_i).to eq(1193898300)
103
+
104
+ if ruby18?
105
+ expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z')
106
+ ).to eq('2007/11/01 06:25:00 GMT +0000')
107
+ else
108
+ expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z')
109
+ ).to eq('2007/11/01 06:25:00 UTC +0000')
110
+ end
111
+ end
112
+ end
113
+
114
+ describe '#add' do
115
+
116
+ it 'adds seconds' do
117
+
118
+ zt = Rufus::Scheduler::ZoTime.new(1193898300, 'Europe/Paris')
119
+ zt.add(111)
120
+
121
+ expect(zt.seconds).to eq(1193898300 + 111)
122
+ end
123
+
124
+ it 'goes into DST' do
125
+
126
+ zt =
127
+ Rufus::Scheduler::ZoTime.new(
128
+ Time.gm(2015, 3, 8, 9, 59, 59),
129
+ 'America/Los_Angeles')
130
+
131
+ t0 = zt.time
132
+ zt.add(1)
133
+ t1 = zt.time
134
+
135
+ st0 = t0.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t0.isdst}"
136
+ st1 = t1.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t1.isdst}"
137
+
138
+ expect(t0.to_i).to eq(1425808799)
139
+ expect(t1.to_i).to eq(1425808800)
140
+ expect(st0).to eq('2015/03/08 01:59:59 PST false')
141
+ expect(st1).to eq('2015/03/08 03:00:00 PDT true')
142
+ end
143
+
144
+ it 'goes out of DST' do
145
+
146
+ zt =
147
+ Rufus::Scheduler::ZoTime.new(
148
+ ltz('Europe/Berlin', 2014, 10, 26, 01, 59, 59),
149
+ 'Europe/Berlin')
150
+
151
+ t0 = zt.time
152
+ zt.add(1)
153
+ t1 = zt.time
154
+ zt.add(3600)
155
+ t2 = zt.time
156
+ zt.add(1)
157
+ t3 = zt.time
158
+
159
+ st0 = t0.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t0.isdst}"
160
+ st1 = t1.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t1.isdst}"
161
+ st2 = t2.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t2.isdst}"
162
+ st3 = t3.strftime('%Y/%m/%d %H:%M:%S %Z') + " #{t3.isdst}"
163
+
164
+ expect(t0.to_i).to eq(1414281599)
165
+ expect(t1.to_i).to eq(1414285200)
166
+ expect(t2.to_i).to eq(1414285200)
167
+ expect(t3.to_i).to eq(1414285201)
168
+
169
+ expect(st0).to eq('2014/10/26 01:59:59 CEST true')
170
+ expect(st1).to eq('2014/10/26 02:00:00 CET false')
171
+ expect(st2).to eq('2014/10/26 02:00:00 CET false')
172
+ expect(st3).to eq('2014/10/26 02:00:01 CET false')
173
+
174
+ expect(t1 - t0).to eq(3601)
175
+ expect(t2 - t1).to eq(0)
176
+ expect(t3 - t2).to eq(1)
177
+ end
178
+ end
179
+
180
+ describe '#to_f' do
181
+
182
+ it 'returns the @seconds' do
183
+
184
+ zt = Rufus::Scheduler::ZoTime.new(1193898300, 'Europe/Paris')
185
+
186
+ expect(zt.to_f).to eq(1193898300)
187
+ end
188
+ end
189
+
190
+ describe '.envtzable?' do
191
+
192
+ def etza?(s); Rufus::Scheduler::ZoTime.envtzable?(s); end
193
+
194
+ it 'matches' do
195
+
196
+ expect(etza?('Asia/Tokyo')).to eq(true)
197
+ expect(etza?('America/Los_Angeles')).to eq(true)
198
+ expect(etza?('Europe/Paris')).to eq(true)
199
+ expect(etza?('UTC')).to eq(true)
200
+
201
+ expect(etza?('Japan')).to eq(true)
202
+ expect(etza?('Turkey')).to eq(true)
203
+ end
204
+
205
+ it 'does not match' do
206
+
207
+ expect(etza?('14:00')).to eq(false)
208
+ expect(etza?('14:00:14')).to eq(false)
209
+ expect(etza?('2014/12/11')).to eq(false)
210
+ expect(etza?('2014-12-11')).to eq(false)
211
+ expect(etza?('+25:00')).to eq(false)
212
+
213
+ expect(etza?('+09:00')).to eq(false)
214
+ expect(etza?('-01:30')).to eq(false)
215
+ expect(etza?('-0200')).to eq(false)
216
+
217
+ expect(etza?('Wed')).to eq(false)
218
+ expect(etza?('Sun')).to eq(false)
219
+ expect(etza?('Nov')).to eq(false)
220
+
221
+ expect(etza?('PST')).to eq(false)
222
+ expect(etza?('Z')).to eq(false)
223
+
224
+ expect(etza?('YTC')).to eq(false)
225
+ expect(etza?('Asia/Paris')).to eq(false)
226
+ expect(etza?('Nada/Nada')).to eq(false)
227
+ end
228
+
229
+ #it 'returns true for all entries in the tzinfo list' do
230
+ # File.readlines(
231
+ # File.join(File.dirname(__FILE__), '../misc/tz_all.txt')
232
+ # ).each do |tz|
233
+ # tz = tz.strip
234
+ # if tz.length > 0 && tz.match(/^[^#]/)
235
+ # p tz
236
+ # expect(llat?(tz)).to eq(true)
237
+ # end
238
+ # end
239
+ #end
240
+ end
241
+
242
+ describe '.is_timezone?' do
243
+
244
+ def is_timezone?(o); Rufus::Scheduler::ZoTime.is_timezone?(o); end
245
+
246
+ it 'returns true when passed a string describing a timezone' do
247
+
248
+ expect(is_timezone?('Asia/Tokyo')).to eq(true)
249
+ expect(is_timezone?('Europe/Paris')).to eq(true)
250
+ expect(is_timezone?('UTC')).to eq(true)
251
+ expect(is_timezone?('GMT')).to eq(true)
252
+ expect(is_timezone?('Z')).to eq(true)
253
+ expect(is_timezone?('Zulu')).to eq(true)
254
+ expect(is_timezone?('PST')).to eq(true)
255
+ expect(is_timezone?('+09:00')).to eq(true)
256
+ expect(is_timezone?('-01:30')).to eq(true)
257
+ expect(is_timezone?('Japan')).to eq(true)
258
+ expect(is_timezone?('Turkey')).to eq(true)
259
+ end
260
+
261
+ it 'returns false when it cannot make sense of the timezone' do
262
+
263
+ expect(is_timezone?('Asia/Paris')).to eq(false)
264
+ #expect(is_timezone?('YTC')).to eq(false)
265
+ expect(is_timezone?('Nada/Nada')).to eq(false)
266
+ expect(is_timezone?('7')).to eq(false)
267
+ expect(is_timezone?('06')).to eq(false)
268
+ expect(is_timezone?('sun#3')).to eq(false)
269
+ end
270
+
271
+ #it 'returns true for all entries in the tzinfo list' do
272
+ # File.readlines(
273
+ # File.join(File.dirname(__FILE__), '../misc/tz_all.txt')
274
+ # ).each do |tz|
275
+ # tz = tz.strip
276
+ # if tz.length > 0 && tz.match(/^[^#]/)
277
+ # #p tz
278
+ # expect(is_timezone?(tz)).to eq(true)
279
+ # end
280
+ # end
281
+ #end
282
+ end
283
+
284
+ describe '.parse' do
285
+
286
+ it 'parses a time string without a timezone' do
287
+
288
+ zt =
289
+ in_zone('Europe/Moscow') {
290
+ Rufus::Scheduler::ZoTime.parse('2015/03/08 01:59:59')
291
+ }
292
+
293
+ t = zt.time
294
+ u = zt.utc
295
+
296
+ expect(t.to_i).to eq(1425769199)
297
+ expect(u.to_i).to eq(1425769199)
298
+
299
+ expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{t.isdst}"
300
+ ).to eq('2015/03/08 01:59:59 MSK +0300 false')
301
+
302
+ if ruby18?
303
+ expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
304
+ ).to eq('2015/03/07 22:59:59 GMT +0000 false')
305
+ else
306
+ expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
307
+ ).to eq('2015/03/07 22:59:59 UTC +0000 false')
308
+ end
309
+ end
310
+
311
+ it 'parses a time string with a full name timezone' do
312
+
313
+ zt =
314
+ Rufus::Scheduler::ZoTime.parse(
315
+ '2015/03/08 01:59:59 America/Los_Angeles')
316
+
317
+ t = zt.time
318
+ u = zt.utc
319
+
320
+ expect(t.to_i).to eq(1425808799)
321
+ expect(u.to_i).to eq(1425808799)
322
+
323
+ expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{t.isdst}"
324
+ ).to eq('2015/03/08 01:59:59 PST -0800 false')
325
+
326
+ if ruby18?
327
+ expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
328
+ ).to eq('2015/03/08 09:59:59 GMT +0000 false')
329
+ else
330
+ expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
331
+ ).to eq('2015/03/08 09:59:59 UTC +0000 false')
332
+ end
333
+ end
334
+
335
+ it 'parses a time string with a delta timezone' do
336
+
337
+ zt =
338
+ in_zone('Europe/Berlin') {
339
+ Rufus::Scheduler::ZoTime.parse('2015-12-13 12:30 -0200')
340
+ }
341
+
342
+ t = zt.time
343
+ u = zt.utc
344
+
345
+ expect(t.to_i).to eq(1450017000)
346
+ expect(u.to_i).to eq(1450017000)
347
+
348
+ expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{t.isdst}"
349
+ ).to eq('2015/12/13 15:30:00 CET +0100 false')
350
+
351
+ if ruby18?
352
+ expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
353
+ ).to eq('2015/12/13 14:30:00 GMT +0000 false')
354
+ else
355
+ expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
356
+ ).to eq('2015/12/13 14:30:00 UTC +0000 false')
357
+ end
358
+ end
359
+
360
+ it 'parses a time string with a delta (:) timezone' do
361
+
362
+ zt =
363
+ in_zone('Europe/Berlin') {
364
+ Rufus::Scheduler::ZoTime.parse('2015-12-13 12:30 -02:00')
365
+ }
366
+
367
+ t = zt.time
368
+ u = zt.utc
369
+
370
+ expect(t.to_i).to eq(1450017000)
371
+ expect(u.to_i).to eq(1450017000)
372
+
373
+ expect(t.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{t.isdst}"
374
+ ).to eq('2015/12/13 15:30:00 CET +0100 false')
375
+
376
+ if ruby18?
377
+ expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
378
+ ).to eq('2015/12/13 14:30:00 GMT +0000 false')
379
+ else
380
+ expect(u.strftime('%Y/%m/%d %H:%M:%S %Z %z') + " #{u.isdst}"
381
+ ).to eq('2015/12/13 14:30:00 UTC +0000 false')
382
+ end
383
+ end
384
+
385
+ it 'takes the local TZ when it does not know the timezone' do
386
+
387
+ in_zone 'Europe/Moscow' do
388
+
389
+ zt = Rufus::Scheduler::ZoTime.parse('2015/03/08 01:59:59 Nada/Nada')
390
+
391
+ expect(zt.time.zone).to eq('MSK')
392
+ end
393
+ end
394
+ end
395
+ end
396
+