tzinfo 2.0.2 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +105 -0
- data/LICENSE +1 -1
- data/README.md +4 -4
- data/lib/tzinfo/annual_rules.rb +71 -0
- data/lib/tzinfo/data_source.rb +11 -0
- data/lib/tzinfo/data_sources/posix_time_zone_parser.rb +181 -0
- data/lib/tzinfo/data_sources/ruby_data_source.rb +2 -2
- data/lib/tzinfo/data_sources/zoneinfo_data_source.rb +29 -10
- data/lib/tzinfo/data_sources/zoneinfo_reader.rb +205 -7
- data/lib/tzinfo/time_with_offset.rb +26 -0
- data/lib/tzinfo/timestamp.rb +18 -14
- data/lib/tzinfo/transition_rule.rb +455 -0
- data/lib/tzinfo/version.rb +1 -1
- data/lib/tzinfo.rb +15 -0
- data.tar.gz.sig +0 -0
- metadata +12 -4
- metadata.gz.sig +0 -0
@@ -0,0 +1,455 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module TZInfo
|
5
|
+
# Base class for rules definining the transition between standard and daylight
|
6
|
+
# savings time.
|
7
|
+
#
|
8
|
+
# @abstract
|
9
|
+
# @private
|
10
|
+
class TransitionRule #:nodoc:
|
11
|
+
# Returns the number of seconds after midnight local time on the day
|
12
|
+
# identified by the rule at which the transition occurs. Can be negative to
|
13
|
+
# denote a time on the prior day. Can be greater than or equal to 86,400 to
|
14
|
+
# denote a time of the following day.
|
15
|
+
#
|
16
|
+
# @return [Integer] the time in seconds after midnight local time at which
|
17
|
+
# the transition occurs.
|
18
|
+
attr_reader :transition_at
|
19
|
+
|
20
|
+
# Initializes a new {TransitionRule}.
|
21
|
+
#
|
22
|
+
# @param transition_at [Integer] the time in seconds after midnight local
|
23
|
+
# time at which the transition occurs.
|
24
|
+
# @raise [ArgumentError] if `transition_at` is not an `Integer`.
|
25
|
+
def initialize(transition_at)
|
26
|
+
raise ArgumentError, 'Invalid transition_at' unless transition_at.kind_of?(Integer)
|
27
|
+
@transition_at = transition_at
|
28
|
+
end
|
29
|
+
|
30
|
+
# Calculates the time of the transition from a given offset on a given year.
|
31
|
+
#
|
32
|
+
# @param offset [TimezoneOffset] the current offset at the time the rule
|
33
|
+
# will transition.
|
34
|
+
# @param year [Integer] the year in which the transition occurs (local
|
35
|
+
# time).
|
36
|
+
# @return [TimestampWithOffset] the time at which the transition occurs.
|
37
|
+
def at(offset, year)
|
38
|
+
day = get_day(offset, year)
|
39
|
+
TimestampWithOffset.set_timezone_offset(Timestamp.for(day + @transition_at), offset)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Determines if this {TransitionRule} is equal to another instance.
|
43
|
+
#
|
44
|
+
# @param r [Object] the instance to test for equality.
|
45
|
+
# @return [Boolean] `true` if `r` is a {TransitionRule} with the same
|
46
|
+
# {transition_at} as this {TransitionRule}, otherwise `false`.
|
47
|
+
def ==(r)
|
48
|
+
r.kind_of?(TransitionRule) && @transition_at == r.transition_at
|
49
|
+
end
|
50
|
+
alias eql? ==
|
51
|
+
|
52
|
+
# @return [Integer] a hash based on {hash_args} (defaulting to
|
53
|
+
# {transition_at}).
|
54
|
+
def hash
|
55
|
+
hash_args.hash
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
# @return [Array] an `Array` of parameters that will influence the output of
|
61
|
+
# {hash}.
|
62
|
+
def hash_args
|
63
|
+
[@transition_at]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
private_constant :TransitionRule
|
67
|
+
|
68
|
+
# A base class for transition rules that activate based on an integer day of
|
69
|
+
# the year.
|
70
|
+
#
|
71
|
+
# @abstract
|
72
|
+
# @private
|
73
|
+
class DayOfYearTransitionRule < TransitionRule #:nodoc:
|
74
|
+
# Initializes a new {DayOfYearTransitionRule}.
|
75
|
+
#
|
76
|
+
# @param day [Integer] the day of the year on which the transition occurs.
|
77
|
+
# The precise meaning is defined by subclasses.
|
78
|
+
# @param transition_at [Integer] the time in seconds after midnight local
|
79
|
+
# time at which the transition occurs.
|
80
|
+
# @raise [ArgumentError] if `transition_at` is not an `Integer`.
|
81
|
+
# @raise [ArgumentError] if `day` is not an `Integer`.
|
82
|
+
def initialize(day, transition_at)
|
83
|
+
super(transition_at)
|
84
|
+
raise ArgumentError, 'Invalid day' unless day.kind_of?(Integer)
|
85
|
+
@seconds = day * 86400
|
86
|
+
end
|
87
|
+
|
88
|
+
# Determines if this {DayOfYearTransitionRule} is equal to another instance.
|
89
|
+
#
|
90
|
+
# @param r [Object] the instance to test for equality.
|
91
|
+
# @return [Boolean] `true` if `r` is a {DayOfYearTransitionRule} with the
|
92
|
+
# same {transition_at} and day as this {DayOfYearTransitionRule},
|
93
|
+
# otherwise `false`.
|
94
|
+
def ==(r)
|
95
|
+
super(r) && r.kind_of?(DayOfYearTransitionRule) && @seconds == r.seconds
|
96
|
+
end
|
97
|
+
alias eql? ==
|
98
|
+
|
99
|
+
protected
|
100
|
+
|
101
|
+
# @return [Integer] the day multipled by the number of seconds in a day.
|
102
|
+
attr_reader :seconds
|
103
|
+
|
104
|
+
# (see TransitionRule#hash_args)
|
105
|
+
def hash_args
|
106
|
+
[@seconds] + super
|
107
|
+
end
|
108
|
+
end
|
109
|
+
private_constant :DayOfYearTransitionRule
|
110
|
+
|
111
|
+
# Defines transitions that occur on the zero-based nth day of the year.
|
112
|
+
#
|
113
|
+
# Day 0 is 1 January.
|
114
|
+
#
|
115
|
+
# Leap days are counted. Day 59 will be 29 February on a leap year and 1 March
|
116
|
+
# on a non-leap year. Day 365 will be 31 December on a leap year and 1 January
|
117
|
+
# the following year on a non-leap year.
|
118
|
+
#
|
119
|
+
# @private
|
120
|
+
class AbsoluteDayOfYearTransitionRule < DayOfYearTransitionRule #:nodoc:
|
121
|
+
# Initializes a new {AbsoluteDayOfYearTransitionRule}.
|
122
|
+
#
|
123
|
+
# @param day [Integer] the zero-based day of the year on which the
|
124
|
+
# transition occurs (0 to 365 inclusive).
|
125
|
+
# @param transition_at [Integer] the time in seconds after midnight local
|
126
|
+
# time at which the transition occurs.
|
127
|
+
# @raise [ArgumentError] if `transition_at` is not an `Integer`.
|
128
|
+
# @raise [ArgumentError] if `day` is not an `Integer`.
|
129
|
+
# @raise [ArgumentError] if `day` is less than 0 or greater than 365.
|
130
|
+
def initialize(day, transition_at = 0)
|
131
|
+
super(day, transition_at)
|
132
|
+
raise ArgumentError, 'Invalid day' unless day >= 0 && day <= 365
|
133
|
+
end
|
134
|
+
|
135
|
+
# @return [Boolean] `true` if the day specified by this transition is the
|
136
|
+
# first in the year (a day number of 0), otherwise `false`.
|
137
|
+
def is_always_first_day_of_year?
|
138
|
+
seconds == 0
|
139
|
+
end
|
140
|
+
|
141
|
+
# @return [Boolean] `false`.
|
142
|
+
def is_always_last_day_of_year?
|
143
|
+
false
|
144
|
+
end
|
145
|
+
|
146
|
+
# Determines if this {AbsoluteDayOfYearTransitionRule} is equal to another
|
147
|
+
# instance.
|
148
|
+
#
|
149
|
+
# @param r [Object] the instance to test for equality.
|
150
|
+
# @return [Boolean] `true` if `r` is a {AbsoluteDayOfYearTransitionRule}
|
151
|
+
# with the same {transition_at} and day as this
|
152
|
+
# {AbsoluteDayOfYearTransitionRule}, otherwise `false`.
|
153
|
+
def ==(r)
|
154
|
+
super(r) && r.kind_of?(AbsoluteDayOfYearTransitionRule)
|
155
|
+
end
|
156
|
+
alias eql? ==
|
157
|
+
|
158
|
+
protected
|
159
|
+
|
160
|
+
# Returns a `Time` representing midnight local time on the day specified by
|
161
|
+
# the rule for the given offset and year.
|
162
|
+
#
|
163
|
+
# @param offset [TimezoneOffset] the current offset at the time of the
|
164
|
+
# transition.
|
165
|
+
# @param year [Integer] the year in which the transition occurs.
|
166
|
+
# @return [Time] midnight local time on the day specified by the rule for
|
167
|
+
# the given offset and year.
|
168
|
+
def get_day(offset, year)
|
169
|
+
Time.new(year, 1, 1, 0, 0, 0, offset.observed_utc_offset) + seconds
|
170
|
+
end
|
171
|
+
|
172
|
+
# (see TransitionRule#hash_args)
|
173
|
+
def hash_args
|
174
|
+
[AbsoluteDayOfYearTransitionRule] + super
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# Defines transitions that occur on the one-based nth Julian day of the year.
|
179
|
+
#
|
180
|
+
# Leap days are not counted. Day 1 is 1 January. Day 60 is always 1 March.
|
181
|
+
# Day 365 is always 31 December.
|
182
|
+
#
|
183
|
+
# @private
|
184
|
+
class JulianDayOfYearTransitionRule < DayOfYearTransitionRule #:nodoc:
|
185
|
+
# The 60 days in seconds.
|
186
|
+
LEAP = 60 * 86400
|
187
|
+
private_constant :LEAP
|
188
|
+
|
189
|
+
# The length of a non-leap year in seconds.
|
190
|
+
YEAR = 365 * 86400
|
191
|
+
private_constant :YEAR
|
192
|
+
|
193
|
+
# Initializes a new {JulianDayOfYearTransitionRule}.
|
194
|
+
#
|
195
|
+
# @param day [Integer] the one-based Julian day of the year on which the
|
196
|
+
# transition occurs (1 to 365 inclusive).
|
197
|
+
# @param transition_at [Integer] the time in seconds after midnight local
|
198
|
+
# time at which the transition occurs.
|
199
|
+
# @raise [ArgumentError] if `transition_at` is not an `Integer`.
|
200
|
+
# @raise [ArgumentError] if `day` is not an `Integer`.
|
201
|
+
# @raise [ArgumentError] if `day` is less than 1 or greater than 365.
|
202
|
+
def initialize(day, transition_at = 0)
|
203
|
+
super(day, transition_at)
|
204
|
+
raise ArgumentError, 'Invalid day' unless day >= 1 && day <= 365
|
205
|
+
end
|
206
|
+
|
207
|
+
# @return [Boolean] `true` if the day specified by this transition is the
|
208
|
+
# first in the year (a day number of 1), otherwise `false`.
|
209
|
+
def is_always_first_day_of_year?
|
210
|
+
seconds == 86400
|
211
|
+
end
|
212
|
+
|
213
|
+
# @return [Boolean] `true` if the day specified by this transition is the
|
214
|
+
# last in the year (a day number of 365), otherwise `false`.
|
215
|
+
def is_always_last_day_of_year?
|
216
|
+
seconds == YEAR
|
217
|
+
end
|
218
|
+
|
219
|
+
# Determines if this {JulianDayOfYearTransitionRule} is equal to another
|
220
|
+
# instance.
|
221
|
+
#
|
222
|
+
# @param r [Object] the instance to test for equality.
|
223
|
+
# @return [Boolean] `true` if `r` is a {JulianDayOfYearTransitionRule} with
|
224
|
+
# the same {transition_at} and day as this
|
225
|
+
# {JulianDayOfYearTransitionRule}, otherwise `false`.
|
226
|
+
def ==(r)
|
227
|
+
super(r) && r.kind_of?(JulianDayOfYearTransitionRule)
|
228
|
+
end
|
229
|
+
alias eql? ==
|
230
|
+
|
231
|
+
protected
|
232
|
+
|
233
|
+
# Returns a `Time` representing midnight local time on the day specified by
|
234
|
+
# the rule for the given offset and year.
|
235
|
+
#
|
236
|
+
# @param offset [TimezoneOffset] the current offset at the time of the
|
237
|
+
# transition.
|
238
|
+
# @param year [Integer] the year in which the transition occurs.
|
239
|
+
# @return [Time] midnight local time on the day specified by the rule for
|
240
|
+
# the given offset and year.
|
241
|
+
def get_day(offset, year)
|
242
|
+
# Returns 1 March on non-leap years.
|
243
|
+
leap = Time.new(year, 2, 29, 0, 0, 0, offset.observed_utc_offset)
|
244
|
+
diff = seconds - LEAP
|
245
|
+
diff += 86400 if diff >= 0 && leap.mday == 29
|
246
|
+
leap + diff
|
247
|
+
end
|
248
|
+
|
249
|
+
# (see TransitionRule#hash_args)
|
250
|
+
def hash_args
|
251
|
+
[JulianDayOfYearTransitionRule] + super
|
252
|
+
end
|
253
|
+
end
|
254
|
+
private_constant :JulianDayOfYearTransitionRule
|
255
|
+
|
256
|
+
# A base class for rules that transition on a particular day of week of a
|
257
|
+
# given week (subclasses specify which week of the month).
|
258
|
+
#
|
259
|
+
# @abstract
|
260
|
+
# @private
|
261
|
+
class DayOfWeekTransitionRule < TransitionRule #:nodoc:
|
262
|
+
# Initializes a new {DayOfWeekTransitionRule}.
|
263
|
+
#
|
264
|
+
# @param month [Integer] the month of the year when the transition occurs.
|
265
|
+
# @param day_of_week [Integer] the day of the week when the transition
|
266
|
+
# occurs. 0 is Sunday, 6 is Saturday.
|
267
|
+
# @param transition_at [Integer] the time in seconds after midnight local
|
268
|
+
# time at which the transition occurs.
|
269
|
+
# @raise [ArgumentError] if `transition_at` is not an `Integer`.
|
270
|
+
# @raise [ArgumentError] if `month` is not an `Integer`.
|
271
|
+
# @raise [ArgumentError] if `month` is less than 1 or greater than 12.
|
272
|
+
# @raise [ArgumentError] if `day_of_week` is not an `Integer`.
|
273
|
+
# @raise [ArgumentError] if `day_of_week` is less than 0 or greater than 6.
|
274
|
+
def initialize(month, day_of_week, transition_at)
|
275
|
+
super(transition_at)
|
276
|
+
raise ArgumentError, 'Invalid month' unless month.kind_of?(Integer) && month >= 1 && month <= 12
|
277
|
+
raise ArgumentError, 'Invalid day_of_week' unless day_of_week.kind_of?(Integer) && day_of_week >= 0 && day_of_week <= 6
|
278
|
+
@month = month
|
279
|
+
@day_of_week = day_of_week
|
280
|
+
end
|
281
|
+
|
282
|
+
# @return [Boolean] `false`.
|
283
|
+
def is_always_first_day_of_year?
|
284
|
+
false
|
285
|
+
end
|
286
|
+
|
287
|
+
# @return [Boolean] `false`.
|
288
|
+
def is_always_last_day_of_year?
|
289
|
+
false
|
290
|
+
end
|
291
|
+
|
292
|
+
# Determines if this {DayOfWeekTransitionRule} is equal to another
|
293
|
+
# instance.
|
294
|
+
#
|
295
|
+
# @param r [Object] the instance to test for equality.
|
296
|
+
# @return [Boolean] `true` if `r` is a {DayOfWeekTransitionRule} with the
|
297
|
+
# same {transition_at}, month and day of week as this
|
298
|
+
# {DayOfWeekTransitionRule}, otherwise `false`.
|
299
|
+
def ==(r)
|
300
|
+
super(r) && r.kind_of?(DayOfWeekTransitionRule) && @month == r.month && @day_of_week == r.day_of_week
|
301
|
+
end
|
302
|
+
alias eql? ==
|
303
|
+
|
304
|
+
protected
|
305
|
+
|
306
|
+
# @return [Integer] the month of the year (1 to 12).
|
307
|
+
attr_reader :month
|
308
|
+
|
309
|
+
# @return [Integer] the day of the week (0 to 6 for Sunday to Monday).
|
310
|
+
attr_reader :day_of_week
|
311
|
+
|
312
|
+
# (see TransitionRule#hash_args)
|
313
|
+
def hash_args
|
314
|
+
[@month, @day_of_week] + super
|
315
|
+
end
|
316
|
+
end
|
317
|
+
private_constant :DayOfWeekTransitionRule
|
318
|
+
|
319
|
+
# A rule that transitions on the nth occurrence of a particular day of week
|
320
|
+
# of a calendar month.
|
321
|
+
#
|
322
|
+
# @private
|
323
|
+
class DayOfMonthTransitionRule < DayOfWeekTransitionRule #:nodoc:
|
324
|
+
# Initializes a new {DayOfMonthTransitionRule}.
|
325
|
+
#
|
326
|
+
# @param month [Integer] the month of the year when the transition occurs.
|
327
|
+
# @param week [Integer] the week of the month when the transition occurs (1
|
328
|
+
# to 4).
|
329
|
+
# @param day_of_week [Integer] the day of the week when the transition
|
330
|
+
# occurs. 0 is Sunday, 6 is Saturday.
|
331
|
+
# @param transition_at [Integer] the time in seconds after midnight local
|
332
|
+
# time at which the transition occurs.
|
333
|
+
# @raise [ArgumentError] if `transition_at` is not an `Integer`.
|
334
|
+
# @raise [ArgumentError] if `month` is not an `Integer`.
|
335
|
+
# @raise [ArgumentError] if `month` is less than 1 or greater than 12.
|
336
|
+
# @raise [ArgumentError] if `week` is not an `Integer`.
|
337
|
+
# @raise [ArgumentError] if `week` is less than 1 or greater than 4.
|
338
|
+
# @raise [ArgumentError] if `day_of_week` is not an `Integer`.
|
339
|
+
# @raise [ArgumentError] if `day_of_week` is less than 0 or greater than 6.
|
340
|
+
def initialize(month, week, day_of_week, transition_at = 0)
|
341
|
+
super(month, day_of_week, transition_at)
|
342
|
+
raise ArgumentError, 'Invalid week' unless week.kind_of?(Integer) && week >= 1 && week <= 4
|
343
|
+
@offset_start = (week - 1) * 7 + 1
|
344
|
+
end
|
345
|
+
|
346
|
+
# Determines if this {DayOfMonthTransitionRule} is equal to another
|
347
|
+
# instance.
|
348
|
+
#
|
349
|
+
# @param r [Object] the instance to test for equality.
|
350
|
+
# @return [Boolean] `true` if `r` is a {DayOfMonthTransitionRule} with the
|
351
|
+
# same {transition_at}, month, week and day of week as this
|
352
|
+
# {DayOfMonthTransitionRule}, otherwise `false`.
|
353
|
+
def ==(r)
|
354
|
+
super(r) && r.kind_of?(DayOfMonthTransitionRule) && @offset_start == r.offset_start
|
355
|
+
end
|
356
|
+
alias eql? ==
|
357
|
+
|
358
|
+
protected
|
359
|
+
|
360
|
+
# @return [Integer] the day the week starts on for a month starting on a
|
361
|
+
# Sunday.
|
362
|
+
attr_reader :offset_start
|
363
|
+
|
364
|
+
# Returns a `Time` representing midnight local time on the day specified by
|
365
|
+
# the rule for the given offset and year.
|
366
|
+
#
|
367
|
+
# @param offset [TimezoneOffset] the current offset at the time of the
|
368
|
+
# transition.
|
369
|
+
# @param year [Integer] the year in which the transition occurs.
|
370
|
+
# @return [Time] midnight local time on the day specified by the rule for
|
371
|
+
# the given offset and year.
|
372
|
+
def get_day(offset, year)
|
373
|
+
candidate = Time.new(year, month, @offset_start, 0, 0, 0, offset.observed_utc_offset)
|
374
|
+
diff = day_of_week - candidate.wday
|
375
|
+
|
376
|
+
if diff < 0
|
377
|
+
candidate + (7 + diff) * 86400
|
378
|
+
elsif diff > 0
|
379
|
+
candidate + diff * 86400
|
380
|
+
else
|
381
|
+
candidate
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
# (see TransitionRule#hash_args)
|
386
|
+
def hash_args
|
387
|
+
[@offset_start] + super
|
388
|
+
end
|
389
|
+
end
|
390
|
+
private_constant :DayOfMonthTransitionRule
|
391
|
+
|
392
|
+
# A rule that transitions on the last occurrence of a particular day of week
|
393
|
+
# of a calendar month.
|
394
|
+
#
|
395
|
+
# @private
|
396
|
+
class LastDayOfMonthTransitionRule < DayOfWeekTransitionRule #:nodoc:
|
397
|
+
# Initializes a new {LastDayOfMonthTransitionRule}.
|
398
|
+
#
|
399
|
+
# @param month [Integer] the month of the year when the transition occurs.
|
400
|
+
# @param day_of_week [Integer] the day of the week when the transition
|
401
|
+
# occurs. 0 is Sunday, 6 is Saturday.
|
402
|
+
# @param transition_at [Integer] the time in seconds after midnight local
|
403
|
+
# time at which the transition occurs.
|
404
|
+
# @raise [ArgumentError] if `transition_at` is not an `Integer`.
|
405
|
+
# @raise [ArgumentError] if `month` is not an `Integer`.
|
406
|
+
# @raise [ArgumentError] if `month` is less than 1 or greater than 12.
|
407
|
+
# @raise [ArgumentError] if `day_of_week` is not an `Integer`.
|
408
|
+
# @raise [ArgumentError] if `day_of_week` is less than 0 or greater than 6.
|
409
|
+
def initialize(month, day_of_week, transition_at = 0)
|
410
|
+
super(month, day_of_week, transition_at)
|
411
|
+
end
|
412
|
+
|
413
|
+
# Determines if this {LastDayOfMonthTransitionRule} is equal to another
|
414
|
+
# instance.
|
415
|
+
#
|
416
|
+
# @param r [Object] the instance to test for equality.
|
417
|
+
# @return [Boolean] `true` if `r` is a {LastDayOfMonthTransitionRule} with
|
418
|
+
# the same {transition_at}, month and day of week as this
|
419
|
+
# {LastDayOfMonthTransitionRule}, otherwise `false`.
|
420
|
+
def ==(r)
|
421
|
+
super(r) && r.kind_of?(LastDayOfMonthTransitionRule)
|
422
|
+
end
|
423
|
+
alias eql? ==
|
424
|
+
|
425
|
+
protected
|
426
|
+
|
427
|
+
# Returns a `Time` representing midnight local time on the day specified by
|
428
|
+
# the rule for the given offset and year.
|
429
|
+
#
|
430
|
+
# @param offset [TimezoneOffset] the current offset at the time of the
|
431
|
+
# transition.
|
432
|
+
# @param year [Integer] the year in which the transition occurs.
|
433
|
+
# @return [Time] midnight local time on the day specified by the rule for
|
434
|
+
# the given offset and year.
|
435
|
+
def get_day(offset, year)
|
436
|
+
next_month = month + 1
|
437
|
+
if next_month == 13
|
438
|
+
year += 1
|
439
|
+
next_month = 1
|
440
|
+
end
|
441
|
+
|
442
|
+
candidate = Time.new(year, next_month, 1, 0, 0, 0, offset.observed_utc_offset) - 86400
|
443
|
+
diff = candidate.wday - day_of_week
|
444
|
+
|
445
|
+
if diff < 0
|
446
|
+
candidate - (diff + 7) * 86400
|
447
|
+
elsif diff > 0
|
448
|
+
candidate - diff * 86400
|
449
|
+
else
|
450
|
+
candidate
|
451
|
+
end
|
452
|
+
end
|
453
|
+
end
|
454
|
+
private_constant :LastDayOfMonthTransitionRule
|
455
|
+
end
|
data/lib/tzinfo/version.rb
CHANGED
data/lib/tzinfo.rb
CHANGED
@@ -3,6 +3,18 @@
|
|
3
3
|
|
4
4
|
# The top level module for TZInfo.
|
5
5
|
module TZInfo
|
6
|
+
class << self
|
7
|
+
# Instructs the current {DataSource} to load all timezone and country data
|
8
|
+
# into memory (initializing the {DataSource} first if not previously
|
9
|
+
# accessed or set).
|
10
|
+
#
|
11
|
+
# This may be desirable in production environments to improve copy-on-write
|
12
|
+
# performance and to avoid flushing the constant cache every time a new
|
13
|
+
# timezone or country is loaded from {DataSources::RubyDataSource}.
|
14
|
+
def eager_load!
|
15
|
+
DataSource.get.eager_load!
|
16
|
+
end
|
17
|
+
end
|
6
18
|
end
|
7
19
|
|
8
20
|
# Object#untaint is a deprecated no-op in Ruby >= 2.7 and will be removed in
|
@@ -25,6 +37,8 @@ require_relative 'tzinfo/timestamp_with_offset'
|
|
25
37
|
|
26
38
|
require_relative 'tzinfo/timezone_offset'
|
27
39
|
require_relative 'tzinfo/timezone_transition'
|
40
|
+
require_relative 'tzinfo/transition_rule'
|
41
|
+
require_relative 'tzinfo/annual_rules'
|
28
42
|
|
29
43
|
require_relative 'tzinfo/data_sources'
|
30
44
|
require_relative 'tzinfo/data_sources/timezone_info'
|
@@ -35,6 +49,7 @@ require_relative 'tzinfo/data_sources/transitions_data_timezone_info'
|
|
35
49
|
|
36
50
|
require_relative 'tzinfo/data_sources/country_info'
|
37
51
|
|
52
|
+
require_relative 'tzinfo/data_sources/posix_time_zone_parser'
|
38
53
|
require_relative 'tzinfo/data_sources/zoneinfo_reader'
|
39
54
|
|
40
55
|
require_relative 'tzinfo/data_source'
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Ross
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
J3Zn/kSTjTekiaspyGbczC3PUaeJNxr+yCvR4sk71Xmk/GaKKGOHedJ1uj/LAXrA
|
30
30
|
MR0mpl7b8zCg0PFC1J73uw==
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2022-07-19 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: concurrent-ruby
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- LICENSE
|
61
61
|
- README.md
|
62
62
|
- lib/tzinfo.rb
|
63
|
+
- lib/tzinfo/annual_rules.rb
|
63
64
|
- lib/tzinfo/country.rb
|
64
65
|
- lib/tzinfo/country_timezone.rb
|
65
66
|
- lib/tzinfo/data_source.rb
|
@@ -68,6 +69,7 @@ files:
|
|
68
69
|
- lib/tzinfo/data_sources/country_info.rb
|
69
70
|
- lib/tzinfo/data_sources/data_timezone_info.rb
|
70
71
|
- lib/tzinfo/data_sources/linked_timezone_info.rb
|
72
|
+
- lib/tzinfo/data_sources/posix_time_zone_parser.rb
|
71
73
|
- lib/tzinfo/data_sources/ruby_data_source.rb
|
72
74
|
- lib/tzinfo/data_sources/timezone_info.rb
|
73
75
|
- lib/tzinfo/data_sources/transitions_data_timezone_info.rb
|
@@ -101,6 +103,7 @@ files:
|
|
101
103
|
- lib/tzinfo/timezone_period.rb
|
102
104
|
- lib/tzinfo/timezone_proxy.rb
|
103
105
|
- lib/tzinfo/timezone_transition.rb
|
106
|
+
- lib/tzinfo/transition_rule.rb
|
104
107
|
- lib/tzinfo/transitions_timezone_period.rb
|
105
108
|
- lib/tzinfo/untaint_ext.rb
|
106
109
|
- lib/tzinfo/version.rb
|
@@ -108,7 +111,12 @@ files:
|
|
108
111
|
homepage: https://tzinfo.github.io
|
109
112
|
licenses:
|
110
113
|
- MIT
|
111
|
-
metadata:
|
114
|
+
metadata:
|
115
|
+
bug_tracker_uri: https://github.com/tzinfo/tzinfo/issues
|
116
|
+
changelog_uri: https://github.com/tzinfo/tzinfo/blob/master/CHANGES.md
|
117
|
+
documentation_uri: https://rubydoc.info/gems/tzinfo/2.0.5
|
118
|
+
homepage_uri: https://tzinfo.github.io
|
119
|
+
source_code_uri: https://github.com/tzinfo/tzinfo/tree/v2.0.5
|
112
120
|
post_install_message:
|
113
121
|
rdoc_options:
|
114
122
|
- "--title"
|
@@ -128,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
136
|
- !ruby/object:Gem::Version
|
129
137
|
version: '0'
|
130
138
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.3.7
|
132
140
|
signing_key:
|
133
141
|
specification_version: 4
|
134
142
|
summary: Time Zone Library
|
metadata.gz.sig
CHANGED
Binary file
|