danger-packwerk 0.14.0 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/lib/danger-packwerk/danger_package_todo_yml_changes.rb +21 -118
  3. data/lib/danger-packwerk/danger_packwerk.rb +12 -7
  4. data/lib/danger-packwerk/private/git.rb +65 -0
  5. data/lib/danger-packwerk/private/todo_yml_changes.rb +135 -0
  6. data/lib/danger-packwerk/private.rb +1 -0
  7. data/lib/danger-packwerk/version.rb +1 -1
  8. metadata +4 -88
  9. data/sorbet/config +0 -4
  10. data/sorbet/rbi/gems/actionview@7.0.4.rbi +0 -11543
  11. data/sorbet/rbi/gems/activesupport@7.0.4.rbi +0 -12959
  12. data/sorbet/rbi/gems/addressable@2.8.1.rbi +0 -1505
  13. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -522
  14. data/sorbet/rbi/gems/better_html@2.0.1.rbi +0 -286
  15. data/sorbet/rbi/gems/builder@3.2.4.rbi +0 -8
  16. data/sorbet/rbi/gems/claide-plugins@0.9.2.rbi +0 -791
  17. data/sorbet/rbi/gems/claide@1.1.0.rbi +0 -1132
  18. data/sorbet/rbi/gems/code_ownership@1.29.2.rbi +0 -525
  19. data/sorbet/rbi/gems/code_teams@1.0.0.rbi +0 -120
  20. data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -2256
  21. data/sorbet/rbi/gems/colored2@3.1.2.rbi +0 -130
  22. data/sorbet/rbi/gems/concurrent-ruby@1.1.10.rbi +0 -8695
  23. data/sorbet/rbi/gems/constant_resolver@0.2.0.rbi +0 -30
  24. data/sorbet/rbi/gems/cork@0.3.0.rbi +0 -248
  25. data/sorbet/rbi/gems/crass@1.0.6.rbi +0 -436
  26. data/sorbet/rbi/gems/danger-plugin-api@1.0.0.rbi +0 -8
  27. data/sorbet/rbi/gems/danger@9.0.0.rbi +0 -4722
  28. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +0 -862
  29. data/sorbet/rbi/gems/erubi@1.11.0.rbi +0 -102
  30. data/sorbet/rbi/gems/faraday-em_http@1.0.0.rbi +0 -266
  31. data/sorbet/rbi/gems/faraday-em_synchrony@1.0.0.rbi +0 -209
  32. data/sorbet/rbi/gems/faraday-excon@1.1.0.rbi +0 -212
  33. data/sorbet/rbi/gems/faraday-http-cache@2.4.1.rbi +0 -805
  34. data/sorbet/rbi/gems/faraday-httpclient@1.0.1.rbi +0 -221
  35. data/sorbet/rbi/gems/faraday-multipart@1.0.4.rbi +0 -266
  36. data/sorbet/rbi/gems/faraday-net_http@1.0.1.rbi +0 -216
  37. data/sorbet/rbi/gems/faraday-net_http_persistent@1.2.0.rbi +0 -206
  38. data/sorbet/rbi/gems/faraday-patron@1.0.0.rbi +0 -212
  39. data/sorbet/rbi/gems/faraday-rack@1.0.0.rbi +0 -225
  40. data/sorbet/rbi/gems/faraday-retry@1.0.3.rbi +0 -222
  41. data/sorbet/rbi/gems/faraday@1.10.2.rbi +0 -1862
  42. data/sorbet/rbi/gems/git@1.12.0.rbi +0 -1936
  43. data/sorbet/rbi/gems/i18n@1.12.0.rbi +0 -1643
  44. data/sorbet/rbi/gems/kramdown-parser-gfm@1.1.0.rbi +0 -8
  45. data/sorbet/rbi/gems/kramdown@2.4.0.rbi +0 -2168
  46. data/sorbet/rbi/gems/loofah@2.19.0.rbi +0 -646
  47. data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -199
  48. data/sorbet/rbi/gems/minitest@5.16.3.rbi +0 -997
  49. data/sorbet/rbi/gems/multipart-post@2.2.3.rbi +0 -165
  50. data/sorbet/rbi/gems/nap@1.1.0.rbi +0 -351
  51. data/sorbet/rbi/gems/no_proxy_fix@0.1.2.rbi +0 -8
  52. data/sorbet/rbi/gems/nokogiri@1.13.8.rbi +0 -4916
  53. data/sorbet/rbi/gems/octokit@5.6.1.rbi +0 -8939
  54. data/sorbet/rbi/gems/open4@1.3.4.rbi +0 -8
  55. data/sorbet/rbi/gems/packs@0.0.5.rbi +0 -111
  56. data/sorbet/rbi/gems/packwerk@2.2.1-e998ef65194de398f0baaf03a0ba33390b30351e.rbi +0 -2161
  57. data/sorbet/rbi/gems/parallel@1.22.1.rbi +0 -163
  58. data/sorbet/rbi/gems/parse_packwerk@0.18.0.rbi +0 -225
  59. data/sorbet/rbi/gems/parser@3.1.2.1.rbi +0 -5988
  60. data/sorbet/rbi/gems/pry@0.14.1.rbi +0 -6969
  61. data/sorbet/rbi/gems/public_suffix@5.0.0.rbi +0 -779
  62. data/sorbet/rbi/gems/racc@1.6.0.rbi +0 -92
  63. data/sorbet/rbi/gems/rails-dom-testing@2.0.3.rbi +0 -8
  64. data/sorbet/rbi/gems/rails-html-sanitizer@1.4.3.rbi +0 -493
  65. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +0 -227
  66. data/sorbet/rbi/gems/rake@13.0.6.rbi +0 -1865
  67. data/sorbet/rbi/gems/rbi@0.0.14.rbi +0 -2337
  68. data/sorbet/rbi/gems/rchardet@1.8.0.rbi +0 -587
  69. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +0 -1851
  70. data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -3852
  71. data/sorbet/rbi/gems/rspec-core@3.11.0.rbi +0 -7725
  72. data/sorbet/rbi/gems/rspec-expectations@3.11.0.rbi +0 -6201
  73. data/sorbet/rbi/gems/rspec-mocks@3.11.1.rbi +0 -3625
  74. data/sorbet/rbi/gems/rspec-support@3.11.0.rbi +0 -1176
  75. data/sorbet/rbi/gems/rspec@3.11.0.rbi +0 -40
  76. data/sorbet/rbi/gems/rubocop-ast@1.21.0.rbi +0 -4193
  77. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +0 -677
  78. data/sorbet/rbi/gems/rubocop@1.36.0.rbi +0 -37914
  79. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -732
  80. data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +0 -8
  81. data/sorbet/rbi/gems/sawyer@0.9.2.rbi +0 -513
  82. data/sorbet/rbi/gems/smart_properties@1.17.0.rbi +0 -326
  83. data/sorbet/rbi/gems/spoom@1.1.11.rbi +0 -1600
  84. data/sorbet/rbi/gems/tapioca@0.8.0.rbi +0 -1959
  85. data/sorbet/rbi/gems/terminal-table@3.0.2.rbi +0 -438
  86. data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -2921
  87. data/sorbet/rbi/gems/tzinfo@2.0.5.rbi +0 -4879
  88. data/sorbet/rbi/gems/unicode-display_width@2.3.0.rbi +0 -27
  89. data/sorbet/rbi/gems/unparser@0.6.5.rbi +0 -2789
  90. data/sorbet/rbi/gems/webrick@1.7.0.rbi +0 -1802
  91. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +0 -288
  92. data/sorbet/rbi/gems/yard@0.9.27.rbi +0 -12668
  93. data/sorbet/rbi/todo.rbi +0 -125
  94. data/sorbet/tapioca/require.rb +0 -4
@@ -1,4879 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `tzinfo` gem.
5
- # Please instead update this file by running `bin/tapioca gem tzinfo`.
6
-
7
- # The top level module for TZInfo.
8
- module TZInfo
9
- class << self
10
- # Instructs the current {DataSource} to load all timezone and country data
11
- # into memory (initializing the {DataSource} first if not previously
12
- # accessed or set).
13
- #
14
- # This may be desirable in production environments to improve copy-on-write
15
- # performance and to avoid flushing the constant cache every time a new
16
- # timezone or country is loaded from {DataSources::RubyDataSource}.
17
- def eager_load!; end
18
- end
19
- end
20
-
21
- # Defines transitions that occur on the zero-based nth day of the year.
22
- #
23
- # Day 0 is 1 January.
24
- #
25
- # Leap days are counted. Day 59 will be 29 February on a leap year and 1 March
26
- # on a non-leap year. Day 365 will be 31 December on a leap year and 1 January
27
- # the following year on a non-leap year.
28
- #
29
- # @private
30
- class TZInfo::AbsoluteDayOfYearTransitionRule < ::TZInfo::DayOfYearTransitionRule
31
- # Initializes a new {AbsoluteDayOfYearTransitionRule}.
32
- #
33
- # @param day [Integer] the zero-based day of the year on which the
34
- # transition occurs (0 to 365 inclusive).
35
- # @param transition_at [Integer] the time in seconds after midnight local
36
- # time at which the transition occurs.
37
- # @raise [ArgumentError] if `transition_at` is not an `Integer`.
38
- # @raise [ArgumentError] if `day` is not an `Integer`.
39
- # @raise [ArgumentError] if `day` is less than 0 or greater than 365.
40
- # @return [AbsoluteDayOfYearTransitionRule] a new instance of AbsoluteDayOfYearTransitionRule
41
- def initialize(day, transition_at = T.unsafe(nil)); end
42
-
43
- # Determines if this {AbsoluteDayOfYearTransitionRule} is equal to another
44
- # instance.
45
- #
46
- # @param r [Object] the instance to test for equality.
47
- # @return [Boolean] `true` if `r` is a {AbsoluteDayOfYearTransitionRule}
48
- # with the same {transition_at} and day as this
49
- # {AbsoluteDayOfYearTransitionRule}, otherwise `false`.
50
- def ==(r); end
51
-
52
- # Determines if this {AbsoluteDayOfYearTransitionRule} is equal to another
53
- # instance.
54
- #
55
- # @param r [Object] the instance to test for equality.
56
- # @return [Boolean] `true` if `r` is a {AbsoluteDayOfYearTransitionRule}
57
- # with the same {transition_at} and day as this
58
- # {AbsoluteDayOfYearTransitionRule}, otherwise `false`.
59
- def eql?(r); end
60
-
61
- # @return [Boolean] `true` if the day specified by this transition is the
62
- # first in the year (a day number of 0), otherwise `false`.
63
- def is_always_first_day_of_year?; end
64
-
65
- # @return [Boolean] `false`.
66
- def is_always_last_day_of_year?; end
67
-
68
- protected
69
-
70
- # Returns a `Time` representing midnight local time on the day specified by
71
- # the rule for the given offset and year.
72
- #
73
- # @param offset [TimezoneOffset] the current offset at the time of the
74
- # transition.
75
- # @param year [Integer] the year in which the transition occurs.
76
- # @return [Time] midnight local time on the day specified by the rule for
77
- # the given offset and year.
78
- def get_day(offset, year); end
79
-
80
- # @return [Array] an `Array` of parameters that will influence the output of
81
- # {hash}.
82
- def hash_args; end
83
- end
84
-
85
- # {AmbiguousTime} is raised to indicate that a specified local time has more
86
- # than one possible equivalent UTC time. Such ambiguities arise when the
87
- # clocks are set back in a time zone, most commonly during the repeated hour
88
- # when transitioning from daylight savings time to standard time.
89
- #
90
- # {AmbiguousTime} is raised by {Timezone#local_datetime},
91
- # {Timezone#local_time}, {Timezone#local_timestamp}, {Timezone#local_to_utc}
92
- # and {Timezone#period_for_local} when using an ambiguous time and not
93
- # specifying how to resolve the ambiguity.
94
- class TZInfo::AmbiguousTime < ::StandardError; end
95
-
96
- # A set of rules that define when transitions occur in time zones with
97
- # annually occurring daylight savings time.
98
- #
99
- # @private
100
- class TZInfo::AnnualRules
101
- # Initializes a new {AnnualRules} instance.
102
- #
103
- # @param std_offset [TimezoneOffset] the standard offset that applies when
104
- # daylight savings time is not in force.
105
- # @param dst_offset [TimezoneOffset] the offset that applies when daylight
106
- # savings time is in force.
107
- # @param dst_start_rule [TransitionRule] the rule that determines when
108
- # daylight savings time starts.
109
- # @param dst_end_rule [TransitionRule] the rule that determines when daylight
110
- # savings time ends.
111
- # @return [AnnualRules] a new instance of AnnualRules
112
- def initialize(std_offset, dst_offset, dst_start_rule, dst_end_rule); end
113
-
114
- # @return [TransitionRule] the rule that determines when daylight savings
115
- # time ends.
116
- def dst_end_rule; end
117
-
118
- # @return [TimezoneOffset] the offset that applies when daylight savings
119
- # time is in force.
120
- def dst_offset; end
121
-
122
- # @return [TransitionRule] the rule that determines when daylight savings
123
- # time starts.
124
- def dst_start_rule; end
125
-
126
- # @return [TimezoneOffset] the standard offset that applies when daylight
127
- # savings time is not in force.
128
- def std_offset; end
129
-
130
- # Returns the transitions between standard and daylight savings time for a
131
- # given year. The results are ordered by time of occurrence (earliest to
132
- # latest).
133
- #
134
- # @param year [Integer] the year to calculate transitions for.
135
- # @return [Array<TimezoneTransition>] the transitions for the year.
136
- def transitions(year); end
137
-
138
- private
139
-
140
- # Applies a given rule between offsets on a year.
141
- #
142
- # @param rule [TransitionRule] the rule to apply.
143
- # @param from_offset [TimezoneOffset] the offset the rule transitions from.
144
- # @param to_offset [TimezoneOffset] the offset the rule transitions to.
145
- # @param year [Integer] the year when the transition occurs.
146
- # @return [TimezoneTransition] the transition determined by the rule.
147
- def apply_rule(rule, from_offset, to_offset, year); end
148
- end
149
-
150
- # A thread-safe version of {StringDeduper}.
151
- #
152
- # @private
153
- class TZInfo::ConcurrentStringDeduper < ::TZInfo::StringDeduper
154
- protected
155
-
156
- def create_hash(&block); end
157
- end
158
-
159
- # The {Country} class represents an ISO 3166-1 country. It can be used to
160
- # obtain a list of time zones observed by a country. For example:
161
- #
162
- # united_states = Country.get('US')
163
- # united_states.zone_identifiers
164
- # united_states.zones
165
- # united_states.zone_info
166
- #
167
- # The {Country} class is thread-safe. It is safe to use class and instance
168
- # methods of {Country} in concurrently executing threads. Instances of
169
- # {Country} can be shared across thread boundaries.
170
- #
171
- # Country information available through TZInfo is intended as an aid for
172
- # users, to help them select time zone data appropriate for their practical
173
- # needs. It is not intended to take or endorse any position on legal or
174
- # territorial claims.
175
- class TZInfo::Country
176
- include ::Comparable
177
-
178
- # Initializes a new {Country} based upon a {DataSources::CountryInfo}
179
- # instance.
180
- #
181
- # {Country} instances should not normally be constructed directly. Use
182
- # the {Country.get} method to obtain instances instead.
183
- #
184
- # @param info [DataSources::CountryInfo] the data to base the new {Country}
185
- # instance upon.
186
- # @return [Country] a new instance of Country
187
- def initialize(info); end
188
-
189
- # Compares this {Country} with another based on their {code}.
190
- #
191
- # @param c [Object] an `Object` to compare this {Country} with.
192
- # @return [Integer] -1 if `c` is less than `self`, 0 if `c` is equal to
193
- # `self` and +1 if `c` is greater than `self`, or `nil` if `c` is not an
194
- # instance of {Country}.
195
- def <=>(c); end
196
-
197
- # Matches `regexp` against the {code} of this {Country}.
198
- #
199
- # @param regexp [Regexp] a `Regexp` to match against the {code} of
200
- # this {Country}.
201
- # @return [Integer] the position the match starts, or `nil` if there is no
202
- # match.
203
- def =~(regexp); end
204
-
205
- # Returns a serialized representation of this {Country}. This method is
206
- # called when using `Marshal.dump` with an instance of {Country}.
207
- #
208
- # @param limit [Integer] the maximum depth to dump - ignored.
209
- # @return [String] a serialized representation of this {Country}.
210
- def _dump(limit); end
211
-
212
- # @return [String] the ISO 3166-1 alpha-2 country code.
213
- def code; end
214
-
215
- # @param c [Object] an `Object` to compare this {Country} with.
216
- # @return [Boolean] `true` if `c` is an instance of {Country} and has the
217
- # same code as `self`, otherwise `false`.
218
- def eql?(c); end
219
-
220
- # @return [Integer] a hash based on the {code}.
221
- def hash; end
222
-
223
- # @return [String] the internal object state as a programmer-readable
224
- # `String`.
225
- def inspect; end
226
-
227
- # @return [String] the name of the country.
228
- def name; end
229
-
230
- # @return [String] a `String` representation of this {Country} (the name of
231
- # the country).
232
- def to_s; end
233
-
234
- # Returns an `Array` containing the identifier for each time zone observed
235
- # by the country. These are in an order that
236
- #
237
- # 1. makes some geographical sense, and
238
- # 2. puts the most populous zones first, where that does not contradict 1.
239
- #
240
- # Returned zone identifiers may refer to cities and regions outside of the
241
- # country. This will occur if the zone covers multiple countries. Any zones
242
- # referring to a city or region in a different country will be listed after
243
- # those relating to this country.
244
- #
245
- # @return [Array<String>] an `Array` containing the identifier for each time
246
- # zone observed by the country
247
- def zone_identifiers; end
248
-
249
- # Returns a frozen `Array` containing a {CountryTimezone} instance for each
250
- # time zone observed by the country. These are in an order that
251
- #
252
- # 1. makes some geographical sense, and
253
- # 2. puts the most populous zones first, where that does not contradict 1.
254
- #
255
- # The {CountryTimezone} instances can be used to obtain the location and
256
- # descriptions of the observed time zones.
257
- #
258
- # Identifiers and descriptions of the time zones returned may refer to
259
- # cities and regions outside of the country. This will occur if the time
260
- # zone covers multiple countries. Any zones referring to a city or region in
261
- # a different country will be listed after those relating to this country.
262
- #
263
- # @return [Array<CountryTimezone>] a frozen `Array` containing a
264
- # {CountryTimezone} instance for each time zone observed by the country.
265
- def zone_info; end
266
-
267
- # Returns an `Array` containing the identifier for each time zone observed
268
- # by the country. These are in an order that
269
- #
270
- # 1. makes some geographical sense, and
271
- # 2. puts the most populous zones first, where that does not contradict 1.
272
- #
273
- # Returned zone identifiers may refer to cities and regions outside of the
274
- # country. This will occur if the zone covers multiple countries. Any zones
275
- # referring to a city or region in a different country will be listed after
276
- # those relating to this country.
277
- #
278
- # @return [Array<String>] an `Array` containing the identifier for each time
279
- # zone observed by the country
280
- def zone_names; end
281
-
282
- # Returns An `Array` containing a {Timezone} instance for each time zone
283
- # observed by the country. These are in an order that
284
- #
285
- # 1. makes some geographical sense, and
286
- # 2. puts the most populous zones first, where that does not contradict 1.
287
- #
288
- # The identifiers of the time zones returned may refer to cities and regions
289
- # outside of the country. This will occur if the time zone covers multiple
290
- # countries. Any zones referring to a city or region in a different country
291
- # will be listed after those relating to this country.
292
- #
293
- # The results are actually instances of {TimezoneProxy} in order to defer
294
- # loading of the time zone transition data until it is first needed.
295
- #
296
- # @return [Array<Timezone>] an `Array` containing a {Timezone} instance for
297
- # each time zone observed by the country.
298
- def zones; end
299
-
300
- class << self
301
- # Loads a {Country} from the serialized representation returned by {_dump}.
302
- # This is method is called when using `Marshal.load` or `Marshal.restore`
303
- # to restore a serialized {Country}.
304
- #
305
- # @param data [String] a serialized representation of a {Country}.
306
- # @return [Country] the result of converting `data` back into a {Country}.
307
- def _load(data); end
308
-
309
- # @return [Array<Country>] an `Array` containing one {Country} instance
310
- # for each defined country.
311
- def all; end
312
-
313
- # @return [Array<String>] an `Array` containing all the valid ISO 3166-1
314
- # alpha-2 country codes.
315
- def all_codes; end
316
-
317
- # Gets a {Country} by its ISO 3166-1 alpha-2 code.
318
- #
319
- # The {Country.all_codes} method can be used to obtain a list of valid ISO
320
- # 3166-1 alpha-2 codes.
321
- #
322
- # @param code [String] An ISO 3166-1 alpha-2 code.
323
- # @raise [InvalidCountryCode] If {code} is not a valid ISO 3166-1 alpha-2
324
- # code it couldn't be found.
325
- # @return [Country] a {Country} instance representing the ISO-3166-1
326
- # country identified by the `code` parameter.
327
- def get(code); end
328
-
329
- private
330
-
331
- # @return [DataSource] the current DataSource.
332
- def data_source; end
333
- end
334
- end
335
-
336
- # Alias used by TZInfo::Data format1 releases.
337
- #
338
- # @private
339
- TZInfo::CountryIndexDefinition = TZInfo::Format1::CountryIndexDefinition
340
-
341
- # Information about a time zone used by a {Country}.
342
- class TZInfo::CountryTimezone
343
- # Creates a new {CountryTimezone}.
344
- #
345
- # The passed in identifier and description instances will be frozen.
346
- #
347
- # {CountryTimezone} instances should normally only be constructed
348
- # by implementations of {DataSource}.
349
- #
350
- # @param identifier [String] the {Timezone} identifier.
351
- # @param latitude [Rational] the latitude of the time zone.
352
- # @param longitude [Rational] the longitude of the time zone.
353
- # @param description [String] an optional description of the time zone.
354
- # @return [CountryTimezone] a new instance of CountryTimezone
355
- def initialize(identifier, latitude, longitude, description = T.unsafe(nil)); end
356
-
357
- # Tests if the given object is equal to the current instance (has the same
358
- # identifier, latitude, longitude and description).
359
- #
360
- # @param ct [Object] the object to be compared.
361
- # @return [TrueClass] `true` if `ct` is equal to the current instance.
362
- def ==(ct); end
363
-
364
- # A description of this time zone in relation to the country, e.g. "Eastern
365
- # Time". This is usually `nil` for countries that have a single time zone.
366
- #
367
- # @return [String] an optional description of the time zone.
368
- def description; end
369
-
370
- # @return [String] the {description} if present, otherwise a human-readable
371
- # representation of the identifier (using {Timezone#friendly_identifier}).
372
- def description_or_friendly_identifier; end
373
-
374
- # Tests if the given object is equal to the current instance (has the same
375
- # identifier, latitude, longitude and description).
376
- #
377
- # @param ct [Object] the object to be compared.
378
- # @return [Boolean] `true` if `ct` is equal to the current instance.
379
- def eql?(ct); end
380
-
381
- # {longitude} and {description}.
382
- #
383
- # @return [Integer] a hash based on the {identifier}, {latitude},
384
- def hash; end
385
-
386
- # @return [String] the identifier of the {Timezone} being described.
387
- def identifier; end
388
-
389
- # The latitude of this time zone in degrees. Positive numbers are degrees
390
- # north and negative numbers are degrees south.
391
- #
392
- # Note that depending on the data source, the position given by {#latitude}
393
- # and {#longitude} may not be within the country.
394
- #
395
- # @return [Rational] the latitude in degrees.
396
- def latitude; end
397
-
398
- # The longitude of this time zone in degrees. Positive numbers are degrees
399
- # east and negative numbers are degrees west.
400
- #
401
- # Note that depending on the data source, the position given by {#latitude}
402
- # and {#longitude} may not be within the country.
403
- #
404
- # @return [Rational] the longitude in degrees.
405
- def longitude; end
406
-
407
- # Returns the associated {Timezone}.
408
- #
409
- # The result is actually an instance of {TimezoneProxy} in order to defer
410
- # loading of the time zone transition data until it is first needed.
411
- #
412
- # @return [Timezone] the associated {Timezone}.
413
- def timezone; end
414
- end
415
-
416
- # TZInfo can be used with different data sources for time zone and country
417
- # data. Each source of data is implemented as a subclass of {DataSource}.
418
- #
419
- # To choose a data source and override the default selection, use the
420
- # {DataSource.set} method.
421
- #
422
- # @abstract To create a custom data source, create a subclass of {DataSource}
423
- # and implement the {load_timezone_info}, {data_timezone_identifiers},
424
- # {linked_timezone_identifiers}, {load_country_info} and {country_codes}
425
- # methods.
426
- class TZInfo::DataSource
427
- # Initializes a new {DataSource} instance. Typically only called via
428
- # subclasses of {DataSource}.
429
- #
430
- # @return [DataSource] a new instance of DataSource
431
- def initialize; end
432
-
433
- # Returns a frozen `Array` of all the available ISO 3166-1 alpha-2 country
434
- # codes. The identifiers are sorted according to `String#<=>`.
435
- #
436
- # @return [Array<String>] a frozen `Array` of all the available ISO 3166-1
437
- # alpha-2 country codes.
438
- def country_codes; end
439
-
440
- # Returns a frozen `Array` of all the available time zone identifiers for
441
- # data time zones (i.e. those that actually contain definitions). The
442
- # identifiers are sorted according to `String#<=>`.
443
- #
444
- # @return [Array<String>] a frozen `Array` of all the available time zone
445
- # identifiers for data time zones.
446
- def data_timezone_identifiers; end
447
-
448
- # Loads all timezone and country data into memory.
449
- #
450
- # This may be desirable in production environments to improve copy-on-write
451
- # performance and to avoid flushing the constant cache every time a new
452
- # timezone or country is loaded from {DataSources::RubyDataSource}.
453
- def eager_load!; end
454
-
455
- # @param code [String] an ISO 3166-1 alpha-2 country code.
456
- # @raise [InvalidCountryCode] if the country could not be found or the code
457
- # is invalid.
458
- # @return [DataSources::CountryInfo] a {DataSources::CountryInfo} instance
459
- # for the given ISO 3166-1 alpha-2 country code.
460
- def get_country_info(code); end
461
-
462
- # Returns a {DataSources::TimezoneInfo} instance for the given identifier.
463
- # The result will derive from either {DataSources::DataTimezoneInfo} for
464
- # time zones that define their own data or {DataSources::LinkedTimezoneInfo}
465
- # for links or aliases to other time zones.
466
- #
467
- # {get_timezone_info} calls {load_timezone_info} to create the
468
- # {DataSources::TimezoneInfo} instance. The returned instance is cached and
469
- # returned in subsequent calls to {get_timezone_info} for the identifier.
470
- #
471
- # @param identifier [String] A time zone identifier.
472
- # @raise [InvalidTimezoneIdentifier] if the time zone is not found or the
473
- # identifier is invalid.
474
- # @return [DataSources::TimezoneInfo] a {DataSources::TimezoneInfo} instance
475
- # for a given identifier.
476
- def get_timezone_info(identifier); end
477
-
478
- # @return [String] the internal object state as a programmer-readable
479
- # `String`.
480
- def inspect; end
481
-
482
- # Returns a frozen `Array` of all the available time zone identifiers that
483
- # are links to other time zones. The identifiers are sorted according to
484
- # `String#<=>`.
485
- #
486
- # @return [Array<String>] a frozen `Array` of all the available time zone
487
- # identifiers that are links to other time zones.
488
- def linked_timezone_identifiers; end
489
-
490
- # @return [Array<String>] a frozen `Array`` of all the available time zone
491
- # identifiers. The identifiers are sorted according to `String#<=>`.
492
- def timezone_identifiers; end
493
-
494
- # @return [String] a description of the {DataSource}.
495
- def to_s; end
496
-
497
- protected
498
-
499
- # @param code [String] an ISO 3166-1 alpha-2 country code.
500
- # @raise [InvalidCountryCode] if the country could not be found or the code
501
- # is invalid.
502
- # @return [DataSources::CountryInfo] a {DataSources::CountryInfo} instance
503
- # for the given ISO 3166-1 alpha-2 country code.
504
- def load_country_info(code); end
505
-
506
- # Returns a {DataSources::TimezoneInfo} instance for the given time zone
507
- # identifier. The result should derive from either
508
- # {DataSources::DataTimezoneInfo} for time zones that define their own data
509
- # or {DataSources::LinkedTimezoneInfo} for links to or aliases for other
510
- # time zones.
511
- #
512
- # @param identifier [String] A time zone identifier.
513
- # @raise [InvalidTimezoneIdentifier] if the time zone is not found or the
514
- # identifier is invalid.
515
- # @return [DataSources::TimezoneInfo] a {DataSources::TimezoneInfo} instance
516
- # for the given time zone identifier.
517
- def load_timezone_info(identifier); end
518
-
519
- # Looks up a given code in the given hash of code to
520
- # {DataSources::CountryInfo} mappings. If the code is found the
521
- # {DataSources::CountryInfo} is returned. Otherwise an {InvalidCountryCode}
522
- # exception is raised.
523
- #
524
- # @param hash [String, DataSources::CountryInfo] a mapping from ISO 3166-1
525
- # alpha-2 country codes to {DataSources::CountryInfo} instances.
526
- # @param code [String] a country code to lookup.
527
- # @param encoding [Encoding] the encoding used for the country codes in
528
- # `hash`.
529
- # @raise [InvalidCountryCode] if `code` was not found in `hash`.
530
- # @return [DataSources::CountryInfo] the {DataSources::CountryInfo} instance
531
- # corresponding to `code`.
532
- def lookup_country_info(hash, code, encoding = T.unsafe(nil)); end
533
-
534
- # @return [Encoding] the `Encoding` used by the `String` instances returned
535
- # by {data_timezone_identifiers} and {linked_timezone_identifiers}.
536
- def timezone_identifier_encoding; end
537
-
538
- # Checks that the given identifier is a valid time zone identifier (can be
539
- # found in the {timezone_identifiers} `Array`). If the identifier is valid,
540
- # the `String` instance representing that identifier from
541
- # `timezone_identifiers` is returned. Otherwise an
542
- # {InvalidTimezoneIdentifier} exception is raised.
543
- #
544
- # @param identifier [String] a time zone identifier to be validated.
545
- # @raise [InvalidTimezoneIdentifier] if `identifier` was not found in
546
- # {timezone_identifiers}.
547
- # @return [String] the `String` instance equivalent to `identifier` from
548
- # {timezone_identifiers}.
549
- def validate_timezone_identifier(identifier); end
550
-
551
- private
552
-
553
- # Combines {data_timezone_identifiers} and {linked_timezone_identifiers}
554
- # to create an `Array` containing all valid time zone identifiers. If
555
- # {linked_timezone_identifiers} is empty, the {data_timezone_identifiers}
556
- # instance is returned.
557
- #
558
- # The returned `Array` is frozen. The identifiers are sorted according to
559
- # `String#<=>`.
560
- #
561
- # @return [Array<String>] an `Array` containing all valid time zone
562
- # identifiers.
563
- def build_timezone_identifiers; end
564
-
565
- # If the given `identifier` is contained within the {timezone_identifiers}
566
- # `Array`, the `String` instance representing that identifier from
567
- # {timezone_identifiers} is returned. Otherwise, `nil` is returned.
568
- #
569
- # :nocov_array_bsearch:
570
- #
571
- # @param identifier [String] A time zone identifier to search for.
572
- # @return [String] the `String` instance representing `identifier` from
573
- # {timezone_identifiers} if found, or `nil` if not found.
574
- def find_timezone_identifier(identifier); end
575
-
576
- # Raises {InvalidDataSource} to indicate that a method has not been
577
- # overridden by a particular data source implementation.
578
- #
579
- # @raise [InvalidDataSource] always.
580
- def raise_invalid_data_source(method_name); end
581
-
582
- # Tries an operation using `string` directly. If the operation fails, the
583
- # string is copied and encoded with `encoding` and the operation is tried
584
- # again.
585
- #
586
- # fails and `string` is already encoded with `encoding`.
587
- #
588
- # @param string [String] The `String` to perform the operation on.
589
- # @param encoding [Encoding] The `Encoding` to use if the initial attempt
590
- # fails.
591
- # @return [Object] the result of the operation or `nil` if the first attempt
592
- # @yield [s] the caller will be yielded to once or twice to attempt the
593
- # operation.
594
- # @yieldparam s [String] either `string` or an encoded copy of `string`.
595
- # @yieldreturn [Object] The result of the operation. Must be truthy if
596
- # successful.
597
- def try_with_encoding(string, encoding); end
598
-
599
- class << self
600
- # @return [DataSource] the currently selected source of data.
601
- def get; end
602
-
603
- # Sets the currently selected data source for time zone and country data.
604
- #
605
- # This should usually be set to one of the two standard data source types:
606
- #
607
- # * `:ruby` - read data from the Ruby modules included in the TZInfo::Data
608
- # library (tzinfo-data gem).
609
- # * `:zoneinfo` - read data from the zoneinfo files included with most
610
- # Unix-like operating systems (e.g. in /usr/share/zoneinfo).
611
- #
612
- # To set TZInfo to use one of the standard data source types, call
613
- # `TZInfo::DataSource.set`` in one of the following ways:
614
- #
615
- # TZInfo::DataSource.set(:ruby)
616
- # TZInfo::DataSource.set(:zoneinfo)
617
- # TZInfo::DataSource.set(:zoneinfo, zoneinfo_dir)
618
- # TZInfo::DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_tab_file)
619
- #
620
- # `DataSource.set(:zoneinfo)` will automatically search for the zoneinfo
621
- # directory by checking the paths specified in
622
- # {DataSources::ZoneinfoDataSource.search_path}.
623
- # {DataSources::ZoneinfoDirectoryNotFound} will be raised if no valid
624
- # zoneinfo directory could be found.
625
- #
626
- # `DataSource.set(:zoneinfo, zoneinfo_dir)` uses the specified
627
- # `zoneinfo_dir` directory as the data source. If the directory is not a
628
- # valid zoneinfo directory, a {DataSources::InvalidZoneinfoDirectory}
629
- # exception will be raised.
630
- #
631
- # `DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_tab_file)` uses the
632
- # specified `zoneinfo_dir` directory as the data source, but loads the
633
- # `iso3166.tab` file from the path given by `iso3166_tab_file`. If the
634
- # directory is not a valid zoneinfo directory, a
635
- # {DataSources::InvalidZoneinfoDirectory} exception will be raised.
636
- #
637
- # Custom data sources can be created by subclassing TZInfo::DataSource and
638
- # implementing the following methods:
639
- #
640
- # * {load_timezone_info}
641
- # * {data_timezone_identifiers}
642
- # * {linked_timezone_identifiers}
643
- # * {load_country_info}
644
- # * {country_codes}
645
- #
646
- # To have TZInfo use the custom data source, call {DataSource.set},
647
- # passing an instance of the custom data source implementation as follows:
648
- #
649
- # TZInfo::DataSource.set(CustomDataSource.new)
650
- #
651
- # Calling {DataSource.set} will only affect instances of {Timezone} and
652
- # {Country} obtained with {Timezone.get} and {Country.get} subsequent to
653
- # the {DataSource.set} call. Existing {Timezone} and {Country} instances
654
- # will be unaffected.
655
- #
656
- # If {DataSource.set} is not called, TZInfo will by default attempt to use
657
- # TZInfo::Data as the data source. If TZInfo::Data is not available (i.e.
658
- # if `require 'tzinfo/data'` fails), then TZInfo will search for a
659
- # zoneinfo directory instead (using the search path specified by
660
- # {DataSources::ZoneinfoDataSource.search_path}).
661
- #
662
- # @param data_source_or_type [Object] either `:ruby`, `:zoneinfo` or an
663
- # instance of a {DataSource}.
664
- # @param args [Array<Object>] when `data_source_or_type` is a symbol,
665
- # optional arguments to use when initializing the data source.
666
- # @raise [ArgumentError] if `data_source_or_type` is not `:ruby`,
667
- # `:zoneinfo` or an instance of {DataSource}.
668
- def set(data_source_or_type, *args); end
669
-
670
- private
671
-
672
- # Creates a {DataSource} instance for use as the default. Used if no
673
- # preference has been specified manually.
674
- #
675
- # @return [DataSource] the newly created default {DataSource} instance.
676
- def create_default_data_source; end
677
- end
678
- end
679
-
680
- # {DataSourceNotFound} is raised if no data source could be found (i.e. if
681
- # `'tzinfo/data'` cannot be found on the load path and no valid zoneinfo
682
- # directory can be found on the system).
683
- class TZInfo::DataSourceNotFound < ::StandardError; end
684
-
685
- # {DataSource} implementations and classes used by {DataSource}
686
- # implementations.
687
- module TZInfo::DataSources; end
688
-
689
- # Represents a data time zone defined by a constantly observed offset.
690
- class TZInfo::DataSources::ConstantOffsetDataTimezoneInfo < ::TZInfo::DataSources::DataTimezoneInfo
691
- # Initializes a new {ConstantOffsetDataTimezoneInfo}.
692
- #
693
- # The passed in `identifier` instance will be frozen. A reference to the
694
- # passed in {TimezoneOffset} will be retained.
695
- #
696
- # @param identifier [String] the identifier of the time zone.
697
- # @param constant_offset [TimezoneOffset] the constantly observed offset.
698
- # @raise [ArgumentError] if `identifier` or `constant_offset` is `nil`.
699
- # @return [ConstantOffsetDataTimezoneInfo] a new instance of ConstantOffsetDataTimezoneInfo
700
- def initialize(identifier, constant_offset); end
701
-
702
- # @return [TimezoneOffset] the offset that is constantly observed.
703
- def constant_offset; end
704
-
705
- # @param timestamp [Timestamp] ignored.
706
- # @return [TimezonePeriod] an unbounded {TimezonePeriod} for the time
707
- # zone's constantly observed offset.
708
- def period_for(timestamp); end
709
-
710
- # @param local_timestamp [Timestamp] ignored.
711
- # @return [Array<TimezonePeriod>] an `Array` containing a single unbounded
712
- # {TimezonePeriod} for the time zone's constantly observed offset.
713
- def periods_for_local(local_timestamp); end
714
-
715
- # @param to_timestamp [Timestamp] ignored.
716
- # @param from_timestamp [Timestamp] ignored.
717
- # @return [Array] an empty `Array`, since there are no transitions in time
718
- # zones that observe a constant offset.
719
- def transitions_up_to(to_timestamp, from_timestamp = T.unsafe(nil)); end
720
-
721
- private
722
-
723
- # @return [TimezonePeriod] an unbounded {TimezonePeriod} with the constant
724
- # offset of this timezone.
725
- def constant_period; end
726
- end
727
-
728
- # Represents a country and references to its time zones as returned by a
729
- # {DataSource}.
730
- class TZInfo::DataSources::CountryInfo
731
- # Initializes a new {CountryInfo}. The passed in `code`, `name` and
732
- # `zones` instances will be frozen.
733
- #
734
- # @param code [String] an ISO 3166-1 alpha-2 country code.
735
- # @param name [String] the name of the country.
736
- # @param zones [Array<CountryTimezone>] the time zones observed in the
737
- # country.
738
- # @raise [ArgumentError] if `code`, `name` or `zones` is `nil`.
739
- # @return [CountryInfo] a new instance of CountryInfo
740
- def initialize(code, name, zones); end
741
-
742
- # @return [String] the ISO 3166-1 alpha-2 country code.
743
- def code; end
744
-
745
- # @return [String] the internal object state as a programmer-readable
746
- # `String`.
747
- def inspect; end
748
-
749
- # @return [String] the name of the country.
750
- def name; end
751
-
752
- # @return [Array<CountryTimezone>] the time zones observed in the country.
753
- def zones; end
754
- end
755
-
756
- # The base class for time zones defined as either a series of transitions
757
- # ({TransitionsDataTimezoneInfo}) or a constantly observed offset
758
- # ({ConstantOffsetDataTimezoneInfo}).
759
- #
760
- # @abstract Data sources return instances of {DataTimezoneInfo} subclasses.
761
- class TZInfo::DataSources::DataTimezoneInfo < ::TZInfo::DataSources::TimezoneInfo
762
- # @return [DataTimezone] a new {DataTimezone} instance for the time zone
763
- # represented by this {DataTimezoneInfo}.
764
- def create_timezone; end
765
-
766
- # @param timestamp [Timestamp] a {Timestamp} with a specified
767
- # {Timestamp#utc_offset utc_offset}.
768
- # @raise [ArgumentError] may be raised if `timestamp` is `nil` or does not
769
- # have a specified {Timestamp#utc_offset utc_offset}.
770
- # @return [TimezonePeriod] the {TimezonePeriod} observed at the time
771
- # specified by `timestamp`.
772
- def period_for(timestamp); end
773
-
774
- # Returns an `Array` containing the {TimezonePeriod TimezonePeriods} that
775
- # could be observed at the local time specified by `local_timestamp`. The
776
- # results are are ordered by increasing UTC start date. An empty `Array`
777
- # is returned if no periods are found for the given local time.
778
- #
779
- # @param local_timestamp [Timestamp] a {Timestamp} representing a local
780
- # time - must have an unspecified {Timestamp#utc_offset utc_offset}.
781
- # @raise [ArgumentError] may be raised if `local_timestamp` is `nil`, or
782
- # has a specified {Timestamp#utc_offset utc_offset}.
783
- # @return [Array<TimezonePeriod>] an `Array` containing the
784
- # {TimezonePeriod TimezonePeriods} that could be observed at the local
785
- # time specified by `local_timestamp`.
786
- def periods_for_local(local_timestamp); end
787
-
788
- # Returns an `Array` of {TimezoneTransition} instances representing the
789
- # times where the UTC offset of the time zone changes.
790
- #
791
- # Transitions are returned up to a given {Timestamp} (`to_timestamp`).
792
- #
793
- # A from {Timestamp} may also be supplied using the `from_timestamp`
794
- # parameter. If `from_timestamp` is specified, only transitions from that
795
- # time onwards will be returned.
796
- #
797
- # Comparisons with `to_timestamp` are exclusive. Comparisons with
798
- # `from_timestamp` are inclusive. If a transition falls precisely on
799
- # `to_timestamp`, it will be excluded. If a transition falls on
800
- # `from_timestamp`, it will be included.
801
- #
802
- # Transitions returned are ordered by when they occur, from earliest to
803
- # latest.
804
- #
805
- # @param to_timestamp [Timestamp] a {Timestamp} with a specified
806
- # {Timestamp#utc_offset utc_offset}. Transitions are returned if they
807
- # occur before this time.
808
- # @param from_timestamp [Timestamp] an optional {Timestamp} with a
809
- # specified {Timestamp#utc_offset utc_offset}. If specified, transitions
810
- # are returned if they occur at or after this time.
811
- # @raise [ArgumentError] may be raised if `to_timestamp` is `nil` or does
812
- # not have a specified {Timestamp#utc_offset utc_offset}.
813
- # @raise [ArgumentError] may be raised if `from_timestamp` is specified
814
- # but does not have a specified {Timestamp#utc_offset utc_offset}.
815
- # @raise [ArgumentError] may be raised if `from_timestamp` is specified
816
- # but is not earlier than or at the same time as `to_timestamp`.
817
- # @return [Array<TimezoneTransition>] an `Array` of {TimezoneTransition}
818
- # instances representing the times where the UTC offset of the time zone
819
- # changes.
820
- def transitions_up_to(to_timestamp, from_timestamp = T.unsafe(nil)); end
821
-
822
- private
823
-
824
- # Raises a {NotImplementedError} to indicate that the base class is
825
- # incorrectly being used directly.
826
- #
827
- # raise [NotImplementedError] always.
828
- #
829
- # @raise [NotImplementedError]
830
- def raise_not_implemented(method_name); end
831
- end
832
-
833
- # An {InvalidPosixTimeZone} exception is raised if an invalid POSIX-style
834
- # time zone string is encountered.
835
- #
836
- # @private
837
- class TZInfo::DataSources::InvalidPosixTimeZone < ::StandardError; end
838
-
839
- # An {InvalidZoneinfoDirectory} exception is raised if {ZoneinfoDataSource}
840
- # is initialized with a specific zoneinfo path that is not a valid zoneinfo
841
- # directory. A valid zoneinfo directory is one that contains time zone
842
- # files, a country code index file named iso3166.tab and a time zone index
843
- # file named zone1970.tab or zone.tab.
844
- class TZInfo::DataSources::InvalidZoneinfoDirectory < ::StandardError; end
845
-
846
- # An {InvalidZoneinfoFile} exception is raised if an attempt is made to load
847
- # an invalid zoneinfo file.
848
- class TZInfo::DataSources::InvalidZoneinfoFile < ::StandardError; end
849
-
850
- # Represents a time zone that is defined as a link to or alias of another
851
- # zone.
852
- class TZInfo::DataSources::LinkedTimezoneInfo < ::TZInfo::DataSources::TimezoneInfo
853
- # Initializes a new {LinkedTimezoneInfo}. The passed in `identifier` and
854
- # `link_to_identifier` instances will be frozen.
855
- #
856
- # `nil`.
857
- #
858
- # @param identifier [String] the identifier of the time zone.
859
- # @param link_to_identifier [String] the identifier of the time zone that
860
- # this zone link to.
861
- # @raise [ArgumentError] if `identifier` or `link_to_identifier` are
862
- # @return [LinkedTimezoneInfo] a new instance of LinkedTimezoneInfo
863
- def initialize(identifier, link_to_identifier); end
864
-
865
- # @return [LinkedTimezone] a new {LinkedTimezone} instance for the time
866
- # zone represented by this {LinkedTimezoneInfo}.
867
- def create_timezone; end
868
-
869
- # (that this zone links to or is an alias for).
870
- #
871
- # @return [String] the identifier of the time zone that provides the data
872
- def link_to_identifier; end
873
- end
874
-
875
- # A parser for POSIX-style TZ strings used in zoneinfo files and specified
876
- # by tzfile.5 and tzset.3.
877
- #
878
- # @private
879
- class TZInfo::DataSources::PosixTimeZoneParser
880
- # Initializes a new {PosixTimeZoneParser}.
881
- #
882
- # @param string_deduper [StringDeduper] a {StringDeduper} instance to use
883
- # to dedupe abbreviations.
884
- # @return [PosixTimeZoneParser] a new instance of PosixTimeZoneParser
885
- def initialize(string_deduper); end
886
-
887
- # Parses a POSIX-style TZ string.
888
- #
889
- # @param tz_string [String] the string to parse.
890
- # @raise [InvalidPosixTimeZone] if `tz_string` is not a `String`.
891
- # @raise [InvalidPosixTimeZone] if `tz_string` is is not valid.
892
- # @return [Object] either a {TimezoneOffset} for a constantly applied
893
- # offset or an {AnnualRules} instance representing the rules.
894
- def parse(tz_string); end
895
-
896
- private
897
-
898
- # Scans for a pattern and raises an exception if the pattern does not
899
- # match the input.
900
- #
901
- # @param s [StringScanner] the `StringScanner` to scan.
902
- # @param pattern [Regexp] the pattern to match.
903
- # @raise [InvalidPosixTimeZone] if the pattern does not match the input.
904
- # @return [String] the result of the scan.
905
- def check_scan(s, pattern); end
906
-
907
- # Returns an offset in seconds from hh:mm:ss values. The value can be
908
- # negative. -02:33:12 would represent 2 hours, 33 minutes and 12 seconds
909
- # ahead of UTC.
910
- #
911
- # @param h [String] the hours.
912
- # @param m [String] the minutes.
913
- # @param s [String] the seconds.
914
- # @raise [InvalidPosixTimeZone] if the mm and ss values are greater than
915
- # 59.
916
- # @return [Integer] the offset.
917
- def get_offset_from_hms(h, m, s); end
918
-
919
- # Returns the seconds from midnight from hh:mm:ss values. Hours can exceed
920
- # 24 for a time on the following day. Hours can be negative to subtract
921
- # hours from midnight on the given day. -02:33:12 represents 22:33:12 on
922
- # the prior day.
923
- #
924
- # @param h [String] the hour.
925
- # @param m [String] the minutes past the hour.
926
- # @param s [String] the seconds past the minute.
927
- # @raise [InvalidPosixTimeZone] if the mm and ss values are greater than
928
- # 59.
929
- # @return [Integer] the number of seconds after midnight.
930
- def get_seconds_after_midnight_from_hms(h, m, s); end
931
-
932
- # Parses a rule.
933
- #
934
- # @param s [StringScanner] the `StringScanner` to read the rule from.
935
- # @param type [String] the type of rule (either `'start'` or `'end'`).
936
- # @raise [InvalidPosixTimeZone] if the rule is not valid.
937
- # @return [TransitionRule] the parsed rule.
938
- def parse_rule(s, type); end
939
- end
940
-
941
- # A DataSource implementation that loads data from the set of Ruby modules
942
- # included in the tzinfo-data gem.
943
- #
944
- # TZInfo will use {RubyDataSource} by default if the tzinfo-data gem
945
- # is available on the load path. It can also be selected by calling
946
- # {DataSource.set} as follows:
947
- #
948
- # TZInfo::DataSource.set(:ruby)
949
- class TZInfo::DataSources::RubyDataSource < ::TZInfo::DataSource
950
- # Initializes a new {RubyDataSource} instance.
951
- #
952
- # @raise [TZInfoDataNotFound] if the tzinfo-data gem could not be found
953
- # (i.e. `require 'tzinfo/data'` failed).
954
- # @return [RubyDataSource] a new instance of RubyDataSource
955
- def initialize; end
956
-
957
- # Returns the value of attribute country_codes.
958
- def country_codes; end
959
-
960
- # Returns the value of attribute data_timezone_identifiers.
961
- def data_timezone_identifiers; end
962
-
963
- # @return [String] the internal object state as a programmer-readable
964
- # `String`.
965
- def inspect; end
966
-
967
- # Returns the value of attribute linked_timezone_identifiers.
968
- def linked_timezone_identifiers; end
969
-
970
- # @return [String] a description of the {DataSource}.
971
- def to_s; end
972
-
973
- protected
974
-
975
- # @param code [String] an ISO 3166-1 alpha-2 country code.
976
- # @raise [InvalidCountryCode] if the country could not be found or the code
977
- # is invalid.
978
- # @return [DataSources::CountryInfo] a {DataSources::CountryInfo} instance
979
- # for the given ISO 3166-1 alpha-2 country code.
980
- def load_country_info(code); end
981
-
982
- # Returns a {TimezoneInfo} instance for the given time zone identifier.
983
- # The result will either be a {ConstantOffsetDataTimezoneInfo}, a
984
- # {TransitionsDataTimezoneInfo} or a {LinkedTimezoneInfo} depending on the
985
- # type of time zone.
986
- #
987
- # @param identifier [String] A time zone identifier.
988
- # @raise [InvalidTimezoneIdentifier] if the time zone is not found or the
989
- # identifier is invalid.
990
- # @return [TimezoneInfo] a {TimezoneInfo} instance for the given time zone
991
- # identifier.
992
- def load_timezone_info(identifier); end
993
-
994
- private
995
-
996
- # Requires a file from tzinfo/data.
997
- #
998
- # @param file [Array<String>] a relative path to a file to be required.
999
- def require_data(*file); end
1000
-
1001
- # Requires a zone definition by its identifier (split on /).
1002
- #
1003
- # @param identifier [Array<string>] the component parts of a time zone
1004
- # identifier (split on /). This must have already been validated.
1005
- def require_definition(identifier); end
1006
-
1007
- # Requires an index by its name.
1008
- #
1009
- # @param name [String] an index name.
1010
- def require_index(name); end
1011
-
1012
- # @return [String] a `String` containing TZInfo::Data version infomation
1013
- # for inclusion in the #to_s and #inspect output.
1014
- def version_info; end
1015
- end
1016
-
1017
- # A {TZInfoDataNotFound} exception is raised if the tzinfo-data gem could
1018
- # not be found (i.e. `require 'tzinfo/data'` failed) when selecting the Ruby
1019
- # data source.
1020
- class TZInfo::DataSources::TZInfoDataNotFound < ::StandardError; end
1021
-
1022
- # Represents a time zone defined by a data source.
1023
- #
1024
- # @abstract Data sources return instances of {TimezoneInfo} subclasses.
1025
- class TZInfo::DataSources::TimezoneInfo
1026
- # Initializes a new TimezoneInfo. The passed in `identifier` instance will
1027
- # be frozen.
1028
- #
1029
- # @param identifier [String] the identifier of the time zone.
1030
- # @raise [ArgumentError] if `identifier` is `nil`.
1031
- # @return [TimezoneInfo] a new instance of TimezoneInfo
1032
- def initialize(identifier); end
1033
-
1034
- # @return [Timezone] a new {Timezone} instance for the time zone
1035
- # represented by this {TimezoneInfo}.
1036
- def create_timezone; end
1037
-
1038
- # @return [String] the identifier of the time zone.
1039
- def identifier; end
1040
-
1041
- # @return [String] the internal object state as a programmer-readable
1042
- # `String`.
1043
- def inspect; end
1044
-
1045
- private
1046
-
1047
- # Raises a {NotImplementedError}.
1048
- #
1049
- # @param method_name [String] the name of the method that must be
1050
- # overridden.
1051
- # @raise NotImplementedError always.
1052
- def raise_not_implemented(method_name); end
1053
- end
1054
-
1055
- # Represents a data time zone defined by a list of transitions that change
1056
- # the locally observed time.
1057
- class TZInfo::DataSources::TransitionsDataTimezoneInfo < ::TZInfo::DataSources::DataTimezoneInfo
1058
- # Initializes a new {TransitionsDataTimezoneInfo}.
1059
- #
1060
- # The passed in `identifier` instance will be frozen. A reference to the
1061
- # passed in `Array` will be retained.
1062
- #
1063
- # The `transitions` `Array` must be sorted in order of ascending
1064
- # timestamp. Each transition must have a
1065
- # {TimezoneTransition#timestamp_value timestamp_value} that is greater
1066
- # than the {TimezoneTransition#timestamp_value timestamp_value} of the
1067
- # prior transition.
1068
- #
1069
- # @param identifier [String] the identifier of the time zone.
1070
- # @param transitions [Array<TimezoneTransitions>] an `Array` of
1071
- # transitions that each indicate when a change occurs in the locally
1072
- # observed time.
1073
- # @raise [ArgumentError] if `identifier` is `nil`.
1074
- # @raise [ArgumentError] if `transitions` is `nil`.
1075
- # @raise [ArgumentError] if `transitions` is an empty `Array`.
1076
- # @return [TransitionsDataTimezoneInfo] a new instance of TransitionsDataTimezoneInfo
1077
- def initialize(identifier, transitions); end
1078
-
1079
- # @param timestamp [Timestamp] a {Timestamp} with a specified
1080
- # {Timestamp#utc_offset utc_offset}.
1081
- # @raise [ArgumentError] may be raised if `timestamp` is `nil` or does not
1082
- # have a specified {Timestamp#utc_offset utc_offset}.
1083
- # @return [TimezonePeriod] the {TimezonePeriod} observed at the time
1084
- # specified by `timestamp`.
1085
- def period_for(timestamp); end
1086
-
1087
- # Returns an `Array` containing the {TimezonePeriod TimezonePeriods} that
1088
- # could be observed at the local time specified by `local_timestamp`. The
1089
- # results are are ordered by increasing UTC start date. An empty `Array`
1090
- # is returned if no periods are found for the given local time.
1091
- #
1092
- # @param local_timestamp [Timestamp] a {Timestamp} representing a local
1093
- # time - must have an unspecified {Timestamp#utc_offset utc_offset}.
1094
- # @raise [ArgumentError] may be raised if `local_timestamp` is `nil`, or
1095
- # has a specified {Timestamp#utc_offset utc_offset}.
1096
- # @return [Array<TimezonePeriod>] an `Array` containing the
1097
- # {TimezonePeriod TimezonePeriods} that could be observed at the local
1098
- # time specified by `local_timestamp`.
1099
- def periods_for_local(local_timestamp); end
1100
-
1101
- # @return [Array<TimezoneTransition>] the transitions that define this
1102
- # time zone in order of ascending timestamp.
1103
- def transitions; end
1104
-
1105
- # Returns an `Array` of {TimezoneTransition} instances representing the
1106
- # times where the UTC offset of the time zone changes.
1107
- #
1108
- # Transitions are returned up to a given {Timestamp} (`to_timestamp`).
1109
- #
1110
- # A from {Timestamp} may also be supplied using the `from_timestamp`
1111
- # parameter. If `from_timestamp` is specified, only transitions from that
1112
- # time onwards will be returned.
1113
- #
1114
- # Comparisons with `to_timestamp` are exclusive. Comparisons with
1115
- # `from_timestamp` are inclusive. If a transition falls precisely on
1116
- # `to_timestamp`, it will be excluded. If a transition falls on
1117
- # `from_timestamp`, it will be included.
1118
- #
1119
- # Transitions returned are ordered by when they occur, from earliest to
1120
- # latest.
1121
- #
1122
- # @param to_timestamp [Timestamp] a {Timestamp} with a specified
1123
- # {Timestamp#utc_offset utc_offset}. Transitions are returned if they
1124
- # occur before this time.
1125
- # @param from_timestamp [Timestamp] an optional {Timestamp} with a
1126
- # specified {Timestamp#utc_offset utc_offset}. If specified, transitions
1127
- # are returned if they occur at or after this time.
1128
- # @raise [ArgumentError] may be raised if `to_timestamp` is `nil` or does
1129
- # not have a specified {Timestamp#utc_offset utc_offset}.
1130
- # @raise [ArgumentError] may be raised if `from_timestamp` is specified
1131
- # but does not have a specified {Timestamp#utc_offset utc_offset}.
1132
- # @raise [ArgumentError] may be raised if `from_timestamp` is specified
1133
- # but is not earlier than or at the same time as `to_timestamp`.
1134
- # @return [Array<TimezoneTransition>] an `Array` of {TimezoneTransition}
1135
- # instances representing the times where the UTC offset of the time zone
1136
- # changes.
1137
- def transitions_up_to(to_timestamp, from_timestamp = T.unsafe(nil)); end
1138
-
1139
- private
1140
-
1141
- # Performs a binary search on {transitions} to find the index of the
1142
- # earliest transition satisfying a condition.
1143
- #
1144
- # :nocov_array_bsearch_index:
1145
- #
1146
- # @return [Integer] the index of the earliest transition safisfying
1147
- # the condition or `nil` if there are no such transitions.
1148
- # @yield [transition] the caller will be yielded to to test the search
1149
- # condition.
1150
- # @yieldparam transition [TimezoneTransition] a {TimezoneTransition}
1151
- # instance from {transitions}.
1152
- # @yieldreturn [Boolean] `true` for the earliest transition that
1153
- # satisfies the condition and return `true` for all subsequent
1154
- # transitions. In all other cases, the result of the block must be
1155
- # `false`.
1156
- def find_minimum_transition(&block); end
1157
-
1158
- # Determines if a transition occurs at or after a given {Timestamp},
1159
- # taking the {Timestamp#sub_second sub_second} into consideration.
1160
- #
1161
- # @param transition [TimezoneTransition] the transition to compare.
1162
- # @param timestamp [Timestamp] the timestamp to compare.
1163
- # @return [Boolean] `true` if `transition` occurs at or after `timestamp`,
1164
- # otherwise `false`.
1165
- def transition_on_or_after_timestamp?(transition, timestamp); end
1166
- end
1167
-
1168
- # A DataSource implementation that loads data from a 'zoneinfo' directory
1169
- # containing compiled "TZif" version 3 (or earlier) files in addition to
1170
- # iso3166.tab and zone1970.tab or zone.tab index files.
1171
- #
1172
- # To have TZInfo load the system zoneinfo files, call
1173
- # {TZInfo::DataSource.set} as follows:
1174
- #
1175
- # TZInfo::DataSource.set(:zoneinfo)
1176
- #
1177
- # To load zoneinfo files from a particular directory, pass the directory to
1178
- # {TZInfo::DataSource.set}:
1179
- #
1180
- # TZInfo::DataSource.set(:zoneinfo, directory)
1181
- #
1182
- # To load zoneinfo files from a particular directory, but load the
1183
- # iso3166.tab index file from a separate location, pass the directory and
1184
- # path to the iso3166.tab file to {TZInfo::DataSource.set}:
1185
- #
1186
- # TZInfo::DataSource.set(:zoneinfo, directory, iso3166_path)
1187
- #
1188
- # Please note that versions of the 'zic' tool (used to build zoneinfo files)
1189
- # that were released prior to February 2006 created zoneinfo files that used
1190
- # 32-bit integers for transition timestamps. Later versions of zic produce
1191
- # zoneinfo files that use 64-bit integers. If you have 32-bit zoneinfo files
1192
- # on your system, then any queries falling outside of the range 1901-12-13
1193
- # 20:45:52 to 2038-01-19 03:14:07 may be inaccurate.
1194
- #
1195
- # Most modern platforms include 64-bit zoneinfo files. However, Mac OS X (up
1196
- # to at least 10.8.4) still uses 32-bit zoneinfo files.
1197
- #
1198
- # To check whether your zoneinfo files contain 32-bit or 64-bit transition
1199
- # data, you can run the following code (substituting the identifier of the
1200
- # zone you want to test for `zone_identifier`):
1201
- #
1202
- # TZInfo::DataSource.set(:zoneinfo)
1203
- # dir = TZInfo::DataSource.get.zoneinfo_dir
1204
- # File.open(File.join(dir, zone_identifier), 'r') {|f| f.read(5) }
1205
- #
1206
- # If the last line returns `"TZif\\x00"`, then you have a 32-bit zoneinfo
1207
- # file. If it returns `"TZif2"` or `"TZif3"` then you have a 64-bit zoneinfo
1208
- # file.
1209
- #
1210
- # It is also worth noting that as of the 2017c release of the IANA Time Zone
1211
- # Database, 64-bit zoneinfo files only include future transitions up to
1212
- # 2038-01-19 03:14:07. Any queries falling after this time may be
1213
- # inaccurate.
1214
- class TZInfo::DataSources::ZoneinfoDataSource < ::TZInfo::DataSource
1215
- # Initializes a new {ZoneinfoDataSource}.
1216
- #
1217
- # If `zoneinfo_dir` is specified, it will be checked and used as the
1218
- # source of zoneinfo files.
1219
- #
1220
- # The directory must contain a file named iso3166.tab and a file named
1221
- # either zone1970.tab or zone.tab. These may either be included in the
1222
- # root of the directory or in a 'tab' sub-directory and named country.tab
1223
- # and zone_sun.tab respectively (as is the case on Solaris).
1224
- #
1225
- # Additionally, the path to iso3166.tab can be overridden using the
1226
- # `alternate_iso3166_tab_path` parameter.
1227
- #
1228
- # If `zoneinfo_dir` is not specified or `nil`, the paths referenced in
1229
- # {search_path} are searched in order to find a valid zoneinfo directory
1230
- # (one that contains zone1970.tab or zone.tab and iso3166.tab files as
1231
- # above).
1232
- #
1233
- # The paths referenced in {alternate_iso3166_tab_search_path} are also
1234
- # searched to find an iso3166.tab file if one of the searched zoneinfo
1235
- # directories doesn't contain an iso3166.tab file.
1236
- #
1237
- # @param zoneinfo_dir [String] an optional path to a directory to use as
1238
- # the source of zoneinfo files.
1239
- # @param alternate_iso3166_tab_path [String] an optional path to the
1240
- # iso3166.tab file.
1241
- # @raise [InvalidZoneinfoDirectory] if the iso3166.tab and zone1970.tab or
1242
- # zone.tab files cannot be found using the `zoneinfo_dir` and
1243
- # `alternate_iso3166_tab_path` parameters.
1244
- # @raise [ZoneinfoDirectoryNotFound] if no valid directory can be found
1245
- # by searching.
1246
- # @return [ZoneinfoDataSource] a new instance of ZoneinfoDataSource
1247
- def initialize(zoneinfo_dir = T.unsafe(nil), alternate_iso3166_tab_path = T.unsafe(nil)); end
1248
-
1249
- # Returns the value of attribute country_codes.
1250
- def country_codes; end
1251
-
1252
- # Returns a frozen `Array` of all the available time zone identifiers. The
1253
- # identifiers are sorted according to `String#<=>`.
1254
- #
1255
- # @return [Array<String>] a frozen `Array` of all the available time zone
1256
- # identifiers.
1257
- def data_timezone_identifiers; end
1258
-
1259
- # @return [String] the internal object state as a programmer-readable
1260
- # `String`.
1261
- def inspect; end
1262
-
1263
- # Returns an empty `Array`. There is no information about linked/aliased
1264
- # time zones in the zoneinfo files. When using {ZoneinfoDataSource}, every
1265
- # time zone will be returned as a {DataTimezone}.
1266
- #
1267
- # @return [Array<String>] an empty `Array`.
1268
- def linked_timezone_identifiers; end
1269
-
1270
- # @return [String] a description of the {DataSource}.
1271
- def to_s; end
1272
-
1273
- # @return [String] the zoneinfo directory being used.
1274
- def zoneinfo_dir; end
1275
-
1276
- protected
1277
-
1278
- # @param code [String] an ISO 3166-1 alpha-2 country code.
1279
- # @raise [InvalidCountryCode] if the country could not be found or the code
1280
- # is invalid.
1281
- # @return [DataSources::CountryInfo] a {DataSources::CountryInfo} instance
1282
- # for the given ISO 3166-1 alpha-2 country code.
1283
- def load_country_info(code); end
1284
-
1285
- # Returns a {TimezoneInfo} instance for the given time zone identifier.
1286
- # The result will either be a {ConstantOffsetDataTimezoneInfo} or a
1287
- # {TransitionsDataTimezoneInfo}.
1288
- #
1289
- # @param identifier [String] A time zone identifier.
1290
- # @raise [InvalidTimezoneIdentifier] if the time zone is not found, the
1291
- # identifier is invalid, the zoneinfo file cannot be opened or the
1292
- # zoneinfo file is not valid.
1293
- # @return [TimezoneInfo] a {TimezoneInfo} instance for the given time zone
1294
- # identifier.
1295
- def load_timezone_info(identifier); end
1296
-
1297
- private
1298
-
1299
- # Converts degrees, minutes and seconds to a Rational.
1300
- #
1301
- # @param sign [String] `'-'` or `'+'`.
1302
- # @param degrees [String] the number of degrees.
1303
- # @param minutes [String] the number of minutes.
1304
- # @param seconds [String] the number of seconds (optional).
1305
- # @return [Rational] the result of converting from degrees, minutes and
1306
- # seconds to a `Rational`.
1307
- def dms_to_rational(sign, degrees, minutes, seconds = T.unsafe(nil)); end
1308
-
1309
- # Recursively enumerate a directory of time zones.
1310
- #
1311
- # @param dir [Array<String>] the directory to enumerate as an `Array` of
1312
- # path components.
1313
- # @param exclude [Array<String>] file names to exclude when scanning
1314
- # `dir`.
1315
- # @yield [path] the path of each time zone file found is passed to
1316
- # the block.
1317
- # @yieldparam path [Array<String>] the path of a time zone file as an
1318
- # `Array` of path components.
1319
- def enum_timezones(dir, exclude = T.unsafe(nil), &block); end
1320
-
1321
- # Finds a zoneinfo directory using {search_path} and
1322
- # {alternate_iso3166_tab_search_path}.
1323
- #
1324
- # @return [Array<String>] an `Array` containing the iso3166.tab and
1325
- # zone.tab paths if a zoneinfo directory was found, otherwise `nil`.
1326
- def find_zoneinfo_dir; end
1327
-
1328
- # Uses the iso3166.tab and zone1970.tab or zone.tab files to return a Hash
1329
- # mapping country codes to CountryInfo instances.
1330
- #
1331
- # @param iso3166_tab_path [String] the path to the iso3166.tab file.
1332
- # @param zone_tab_path [String] the path to the zone.tab file.
1333
- # @return [Hash<String, CountryInfo>] a mapping from ISO 3166-1 alpha-2
1334
- # country codes to {CountryInfo} instances.
1335
- def load_countries(iso3166_tab_path, zone_tab_path); end
1336
-
1337
- # Scans @zoneinfo_dir and returns an `Array` of available time zone
1338
- # identifiers. The result is sorted according to `String#<=>`.
1339
- #
1340
- # @return [Array<String>] an `Array` containing all the time zone
1341
- # identifiers found.
1342
- def load_timezone_identifiers; end
1343
-
1344
- # Attempts to resolve the path to a tab file given its standard names and
1345
- # tab sub-directory name (as used on Solaris).
1346
- #
1347
- # @param zoneinfo_path [String] the path to a zoneinfo directory.
1348
- # @param standard_names [Array<String>] the standard names for the tab
1349
- # file.
1350
- # @param tab_name [String] the alternate name for the tab file to check in
1351
- # the tab sub-directory.
1352
- # @return [String] the path to the tab file.
1353
- def resolve_tab_path(zoneinfo_path, standard_names, tab_name); end
1354
-
1355
- # Validates a zoneinfo directory and returns the paths to the iso3166.tab
1356
- # and zone1970.tab or zone.tab files if valid. If the directory is not
1357
- # valid, returns `nil`.
1358
- #
1359
- # The path to the iso3166.tab file may be overridden by passing in a path.
1360
- # This is treated as either absolute or relative to the current working
1361
- # directory.
1362
- #
1363
- # @param path [String] the path to a possible zoneinfo directory.
1364
- # @param iso3166_tab_path [String] an optional path to an external
1365
- # iso3166.tab file.
1366
- # @return [Array<String>] an `Array` containing the iso3166.tab and
1367
- # zone.tab paths if the directory is valid, otherwise `nil`.
1368
- def validate_zoneinfo_dir(path, iso3166_tab_path = T.unsafe(nil)); end
1369
-
1370
- class << self
1371
- # An `Array` of paths that will be checked to find an alternate
1372
- # iso3166.tab file if one was not included in the zoneinfo directory
1373
- # (for example, on FreeBSD and OpenBSD systems).
1374
- #
1375
- # Paths are checked in the order they appear in the `Array`.
1376
- #
1377
- # The default value is `['/usr/share/misc/iso3166.tab',
1378
- # '/usr/share/misc/iso3166']`.
1379
- #
1380
- # @return [Array<String>] an `Array` of paths to check in order to
1381
- # locate an iso3166.tab file.
1382
- def alternate_iso3166_tab_search_path; end
1383
-
1384
- # Sets the paths to check to locate an alternate iso3166.tab file if one
1385
- # was not included in the zoneinfo directory.
1386
- #
1387
- # Can be set to an `Array` of paths or a `String` containing paths
1388
- # separated with `File::PATH_SEPARATOR`.
1389
- #
1390
- # Paths are checked in the order they appear in the array.
1391
- #
1392
- # Set to `nil` to revert to the default paths.
1393
- #
1394
- # @param alternate_iso3166_tab_search_path [Object] either `nil` or a
1395
- # list of paths to check as either an `Array` of `String` or a
1396
- # `File::PATH_SEPARATOR` separated `String`.
1397
- def alternate_iso3166_tab_search_path=(alternate_iso3166_tab_search_path); end
1398
-
1399
- # An `Array` of directories that will be checked to find the system
1400
- # zoneinfo directory.
1401
- #
1402
- # Directories are checked in the order they appear in the `Array`.
1403
- #
1404
- # The default value is `['/usr/share/zoneinfo',
1405
- # '/usr/share/lib/zoneinfo', '/etc/zoneinfo']`.
1406
- #
1407
- # @return [Array<String>] an `Array` of directories to check in order to
1408
- # find the system zoneinfo directory.
1409
- def search_path; end
1410
-
1411
- # Sets the directories to be checked when locating the system zoneinfo
1412
- # directory.
1413
- #
1414
- # Can be set to an `Array` of directories or a `String` containing
1415
- # directories separated with `File::PATH_SEPARATOR`.
1416
- #
1417
- # Directories are checked in the order they appear in the `Array` or
1418
- # `String`.
1419
- #
1420
- # Set to `nil` to revert to the default paths.
1421
- #
1422
- # @param search_path [Object] either `nil` or a list of directories to
1423
- # check as either an `Array` of `String` or a `File::PATH_SEPARATOR`
1424
- # separated `String`.
1425
- def search_path=(search_path); end
1426
-
1427
- private
1428
-
1429
- # Processes a path for use as the {search_path} or
1430
- # {alternate_iso3166_tab_search_path}.
1431
- #
1432
- # @param path [Object] either `nil` or a list of paths to check as
1433
- # either an `Array` of `String` or a `File::PATH_SEPARATOR` separated
1434
- # `String`.
1435
- # @param default [Array<String>] the default value.
1436
- # @return [Array<String>] the processed path.
1437
- def process_search_path(path, default); end
1438
- end
1439
- end
1440
-
1441
- # The default value of {ZoneinfoDataSource.alternate_iso3166_tab_search_path}.
1442
- TZInfo::DataSources::ZoneinfoDataSource::DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH = T.let(T.unsafe(nil), Array)
1443
-
1444
- # The default value of {ZoneinfoDataSource.search_path}.
1445
- TZInfo::DataSources::ZoneinfoDataSource::DEFAULT_SEARCH_PATH = T.let(T.unsafe(nil), Array)
1446
-
1447
- # Files and directories in the top level zoneinfo directory that will be
1448
- # excluded from the list of available time zones:
1449
- #
1450
- # - +VERSION is included on Mac OS X.
1451
- # - leapseconds is a list of leap seconds.
1452
- # - localtime is the current local timezone (may be a link).
1453
- # - posix, posixrules and right are directories containing other
1454
- # versions of the zoneinfo files.
1455
- # - SECURITY is included in the Arch Linux tzdata package.
1456
- # - src is a directory containing the tzdata source included on Solaris.
1457
- # - timeconfig is a symlink included on Slackware.
1458
- TZInfo::DataSources::ZoneinfoDataSource::EXCLUDED_FILENAMES = T.let(T.unsafe(nil), Array)
1459
-
1460
- # A {ZoneinfoDirectoryNotFound} exception is raised if no valid zoneinfo
1461
- # directory could be found when checking the paths listed in
1462
- # {ZoneinfoDataSource.search_path}. A valid zoneinfo directory is one that
1463
- # contains time zone files, a country code index file named iso3166.tab and
1464
- # a time zone index file named zone1970.tab or zone.tab.
1465
- class TZInfo::DataSources::ZoneinfoDirectoryNotFound < ::StandardError; end
1466
-
1467
- # Reads compiled zoneinfo TZif (\0, 2 or 3) files.
1468
- class TZInfo::DataSources::ZoneinfoReader
1469
- # Initializes a new {ZoneinfoReader}.
1470
- #
1471
- # @param posix_tz_parser [PosixTimeZoneParser] a {PosixTimeZoneParser}
1472
- # instance to use to parse POSIX-style TZ strings.
1473
- # @param string_deduper [StringDeduper] a {StringDeduper} instance to use
1474
- # to dedupe abbreviations.
1475
- # @return [ZoneinfoReader] a new instance of ZoneinfoReader
1476
- def initialize(posix_tz_parser, string_deduper); end
1477
-
1478
- # Reads a zoneinfo structure from the given path. Returns either a
1479
- # {TimezoneOffset} that is constantly observed or an `Array`
1480
- # {TimezoneTransition}s.
1481
- #
1482
- # @param file_path [String] the path of a zoneinfo file.
1483
- # @raise [SecurityError] if safe mode is enabled and `file_path` is
1484
- # tainted.
1485
- # @raise [InvalidZoneinfoFile] if `file_path`` does not refer to a valid
1486
- # zoneinfo file.
1487
- # @return [Object] either a {TimezoneOffset} or an `Array` of
1488
- # {TimezoneTransition}s.
1489
- def read(file_path); end
1490
-
1491
- private
1492
-
1493
- # Apply the rules from the TZ string when there were defined
1494
- # transitions. Checks for a matching offset with the last transition.
1495
- # Redefines the last transition if required and if the rules don't
1496
- # specific a constant offset, generates transitions until 100 years into
1497
- # the future (at the time of loading zoneinfo_reader.rb).
1498
- #
1499
- # @param file [IO] the file being processed.
1500
- # @param transitions [Array<TimezoneTransition>] the defined transitions.
1501
- # @param offsets [Array<TimezoneOffset>] the offsets used by the defined
1502
- # transitions.
1503
- # @param rules [Object] a {TimezoneOffset} specifying a constant offset or
1504
- # {AnnualRules} instance specfying transitions.
1505
- # @raise [InvalidZoneinfoFile] if the first offset does not match the
1506
- # rules.
1507
- # @raise [InvalidZoneinfoFile] if the previous offset of the first
1508
- # generated transition does not match the offset of the last defined
1509
- # transition.
1510
- def apply_rules_with_transitions(file, transitions, offsets, rules); end
1511
-
1512
- # Apply the rules from the TZ string when there were no defined
1513
- # transitions. Checks for a matching offset. Returns the rules-based
1514
- # constant offset or generates transitions from 1970 until 100 years into
1515
- # the future (at the time of loading zoneinfo_reader.rb).
1516
- #
1517
- # @param file [IO] the file being processed.
1518
- # @param first_offset [TimezoneOffset] the first offset included in the
1519
- # file that would normally apply without the rules.
1520
- # @param rules [Object] a {TimezoneOffset} specifying a constant offset or
1521
- # {AnnualRules} instance specfying transitions.
1522
- # @raise [InvalidZoneinfoFile] if the first offset does not match the
1523
- # rules.
1524
- # @return [Object] either a {TimezoneOffset} or an `Array` of
1525
- # {TimezoneTransition}s.
1526
- def apply_rules_without_transitions(file, first_offset, rules); end
1527
-
1528
- # Reads the given number of bytes from the given file and checks that the
1529
- # correct number of bytes could be read.
1530
- #
1531
- # @param file [IO] the file to read from.
1532
- # @param bytes [Integer] the number of bytes to read.
1533
- # @raise [InvalidZoneinfoFile] if the number of bytes available didn't
1534
- # match the number requested.
1535
- # @return [String] the bytes that were read.
1536
- def check_read(file, bytes); end
1537
-
1538
- # Zoneinfo files don't include the offset from standard time (std_offset)
1539
- # for DST periods. Derive the base offset (base_utc_offset) where DST is
1540
- # observed from either the previous or next non-DST period.
1541
- #
1542
- # @param transitions [Array<Hash>] an `Array` of transition hashes.
1543
- # @param offsets [Array<Hash>] an `Array` of offset hashes.
1544
- # @return [Integer] the index of the offset to be used prior to the first
1545
- # transition.
1546
- def derive_offsets(transitions, offsets); end
1547
-
1548
- # Finds an offset that is equivalent to the one specified in the given
1549
- # `Array`. Matching is performed with {TimezoneOffset#==}.
1550
- #
1551
- # @param offsets [Array<TimezoneOffset>] an `Array` to search.
1552
- # @param offset [TimezoneOffset] the offset to search for.
1553
- # @return [TimezoneOffset] the matching offset from `offsets` or `nil`
1554
- # if not found.
1555
- def find_existing_offset(offsets, offset); end
1556
-
1557
- # Translates an unsigned 32-bit integer (as returned by unpack) to signed
1558
- # 32-bit.
1559
- #
1560
- # @param long [Integer] an unsigned 32-bit integer.
1561
- # @return [Integer] {long} translated to signed 32-bit.
1562
- def make_signed_int32(long); end
1563
-
1564
- # Translates a pair of unsigned 32-bit integers (as returned by unpack,
1565
- # most significant first) to a signed 64-bit integer.
1566
- #
1567
- # @param high [Integer] the most significant 32-bits.
1568
- # @param low [Integer] the least significant 32-bits.
1569
- # @return [Integer] {high} and {low} combined and translated to signed
1570
- # 64-bit.
1571
- def make_signed_int64(high, low); end
1572
-
1573
- # Determines if the offset from a transition matches the offset from a
1574
- # rule. This is a looser match than equality, not requiring that the
1575
- # base_utc_offset and std_offset both match (which have to be derived for
1576
- # transitions, but are known for rules.
1577
- #
1578
- # @param offset [TimezoneOffset] an offset from a transition.
1579
- # @param rule_offset [TimezoneOffset] an offset from a rule.
1580
- # @return [Boolean] whether the offsets match.
1581
- def offset_matches_rule?(offset, rule_offset); end
1582
-
1583
- # Parses a zoneinfo file and returns either a {TimezoneOffset} that is
1584
- # constantly observed or an `Array` of {TimezoneTransition}s.
1585
- #
1586
- # @param file [IO] the file to be read.
1587
- # @raise [InvalidZoneinfoFile] if the file is not a valid zoneinfo file.
1588
- # @return [Object] either a {TimezoneOffset} or an `Array` of
1589
- # {TimezoneTransition}s.
1590
- def parse(file); end
1591
-
1592
- # Returns a new AnnualRules instance with standard and daylight savings
1593
- # offsets replaced with equivalents from an array. This reduces the memory
1594
- # requirement for loaded time zones by reusing offsets for rule-generated
1595
- # transitions.
1596
- #
1597
- # @param offsets [Array<TimezoneOffset>] an `Array` to search for
1598
- # equivalent offsets.
1599
- # @param annual_rules [AnnualRules] the {AnnualRules} instance to check.
1600
- # @return [AnnualRules] either a new {AnnualRules} instance with either
1601
- # the {AnnualRules#std_offset std_offset} or {AnnualRules#dst_offset
1602
- # dst_offset} replaced, or the original instance if no equivalent for
1603
- # either {AnnualRules#std_offset std_offset} or {AnnualRules#dst_offset
1604
- # dst_offset} could be found.
1605
- def replace_with_existing_offsets(offsets, annual_rules); end
1606
-
1607
- # Validates the offset indicated to be observed by the rules before the
1608
- # first generated transition against the offset of the last defined
1609
- # transition.
1610
- #
1611
- # Fix the last defined transition if it differ on just base/std offsets
1612
- # (which are derived). Raise an error if the observed UTC offset or
1613
- # abbreviations differ.
1614
- #
1615
- # @param file [IO] the file being processed.
1616
- # @param last_defined [TimezoneTransition] the last defined transition in
1617
- # the file.
1618
- # @param first_rule_offset [TimezoneOffset] the offset the rules indicate
1619
- # is observed prior to the first rules generated transition.
1620
- # @raise [InvalidZoneinfoFile] if the offset of {last_defined} and
1621
- # {first_rule_offset} do not match.
1622
- # @return [TimezoneTransition] the last defined transition (either the
1623
- # original instance or a replacement).
1624
- def validate_and_fix_last_defined_transition_offset(file, last_defined, first_rule_offset); end
1625
- end
1626
-
1627
- # The year to generate transitions up to.
1628
- #
1629
- # @private
1630
- TZInfo::DataSources::ZoneinfoReader::GENERATE_UP_TO = T.let(T.unsafe(nil), Integer)
1631
-
1632
- # Represents time zones that are defined by rules that set out when
1633
- # transitions occur.
1634
- class TZInfo::DataTimezone < ::TZInfo::InfoTimezone
1635
- # Returns the canonical {Timezone} instance for this {DataTimezone}.
1636
- #
1637
- # For a {DataTimezone}, this is always `self`.
1638
- #
1639
- # @return [Timezone] `self`.
1640
- def canonical_zone; end
1641
-
1642
- # Returns the {TimezonePeriod} that is valid at a given time.
1643
- #
1644
- # Unlike {period_for_local} and {period_for_utc}, the UTC offset of the
1645
- # `time` parameter is taken into consideration.
1646
- #
1647
- # @param time [Object] a `Time`, `DateTime` or {Timestamp}.
1648
- # @raise [ArgumentError] if `time` is `nil`.
1649
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified
1650
- # offset.
1651
- # @return [TimezonePeriod] the {TimezonePeriod} that is valid at `time`.
1652
- def period_for(time); end
1653
-
1654
- # Returns the set of {TimezonePeriod}s that are valid for the given
1655
- # local time as an `Array`.
1656
- #
1657
- # The UTC offset of the `local_time` parameter is ignored (it is treated as
1658
- # a time in the time zone represented by `self`).
1659
- #
1660
- # This will typically return an `Array` containing a single
1661
- # {TimezonePeriod}. More than one {TimezonePeriod} will be returned when the
1662
- # local time is ambiguous (for example, when daylight savings time ends). An
1663
- # empty `Array` will be returned when the local time is not valid (for
1664
- # example, when daylight savings time begins).
1665
- #
1666
- # To obtain just a single {TimezonePeriod} in all cases, use
1667
- # {period_for_local} instead and specify how ambiguities should be resolved.
1668
- #
1669
- # @param local_time [Object] a `Time`, `DateTime` or {Timestamp}.
1670
- # @raise [ArgumentError] if `local_time` is `nil`.
1671
- # @return [Array<TimezonePeriod>] the set of {TimezonePeriod}s that are
1672
- # valid at `local_time`.
1673
- def periods_for_local(local_time); end
1674
-
1675
- # Returns an `Array` of {TimezoneTransition} instances representing the
1676
- # times where the UTC offset of the timezone changes.
1677
- #
1678
- # Transitions are returned up to a given time (`to`).
1679
- #
1680
- # A from time may also be supplied using the `from` parameter. If from is
1681
- # not `nil`, only transitions from that time onwards will be returned.
1682
- #
1683
- # Comparisons with `to` are exclusive. Comparisons with `from` are
1684
- # inclusive. If a transition falls precisely on `to`, it will be excluded.
1685
- # If a transition falls on `from`, it will be included.
1686
- #
1687
- # @param to [Object] a `Time`, `DateTime` or {Timestamp} specifying the
1688
- # latest (exclusive) transition to return.
1689
- # @param from [Object] an optional `Time`, `DateTime` or {Timestamp}
1690
- # specifying the earliest (inclusive) transition to return.
1691
- # @raise [ArgumentError] if `from` is specified and `to` is not greater than
1692
- # `from`.
1693
- # @raise [ArgumentError] is raised if `to` is `nil`.
1694
- # @raise [ArgumentError] if either `to` or `from` is a {Timestamp} with an
1695
- # unspecified offset.
1696
- # @return [Array<TimezoneTransition>] the transitions that are earlier than
1697
- # `to` and, if specified, at or later than `from`. Transitions are ordered
1698
- # by when they occur, from earliest to latest.
1699
- def transitions_up_to(to, from = T.unsafe(nil)); end
1700
- end
1701
-
1702
- # A subclass of `DateTime` used to represent local times. {DateTimeWithOffset}
1703
- # holds a reference to the related {TimezoneOffset} and overrides various
1704
- # methods to return results appropriate for the {TimezoneOffset}. Certain
1705
- # operations will clear the associated {TimezoneOffset} (if the
1706
- # {TimezoneOffset} would not necessarily be valid for the result). Once the
1707
- # {TimezoneOffset} has been cleared, {DateTimeWithOffset} behaves identically
1708
- # to `DateTime`.
1709
- #
1710
- # Arithmetic performed on {DateTimeWithOffset} instances is _not_ time
1711
- # zone-aware. Regardless of whether transitions in the time zone are crossed,
1712
- # results of arithmetic operations will always maintain the same offset from
1713
- # UTC (`offset`). The associated {TimezoneOffset} will aways be cleared.
1714
- class TZInfo::DateTimeWithOffset < ::DateTime
1715
- include ::TZInfo::WithOffset
1716
-
1717
- # An overridden version of `DateTime#downto` that clears the associated
1718
- # {TimezoneOffset} of the returned or yielded instances.
1719
- def downto(min); end
1720
-
1721
- # An overridden version of `DateTime#england` that preserves the associated
1722
- # {TimezoneOffset}.
1723
- #
1724
- # @return [DateTime]
1725
- def england; end
1726
-
1727
- # An overridden version of `DateTime#gregorian` that preserves the
1728
- # associated {TimezoneOffset}.
1729
- #
1730
- # @return [DateTime]
1731
- def gregorian; end
1732
-
1733
- # An overridden version of `DateTime#italy` that preserves the associated
1734
- # {TimezoneOffset}.
1735
- #
1736
- # @return [DateTime]
1737
- def italy; end
1738
-
1739
- # An overridden version of `DateTime#julian` that preserves the associated
1740
- # {TimezoneOffset}.
1741
- #
1742
- # @return [DateTime]
1743
- def julian; end
1744
-
1745
- # An overridden version of `DateTime#new_start` that preserves the
1746
- # associated {TimezoneOffset}.
1747
- #
1748
- # @return [DateTime]
1749
- def new_start(start = T.unsafe(nil)); end
1750
-
1751
- # Sets the associated {TimezoneOffset}.
1752
- #
1753
- # @param timezone_offset [TimezoneOffset] a {TimezoneOffset} valid at the
1754
- # time and for the offset of this {DateTimeWithOffset}.
1755
- # @raise [ArgumentError] if `timezone_offset` is `nil`.
1756
- # @raise [ArgumentError] if `timezone_offset.observed_utc_offset` does not
1757
- # equal `self.offset * 86400`.
1758
- # @return [DateTimeWithOffset] `self`.
1759
- def set_timezone_offset(timezone_offset); end
1760
-
1761
- # An overridden version of `DateTime#step` that clears the associated
1762
- # {TimezoneOffset} of the returned or yielded instances.
1763
- def step(limit, step = T.unsafe(nil)); end
1764
-
1765
- # @return [TimezoneOffset] the {TimezoneOffset} associated with this
1766
- # instance.
1767
- def timezone_offset; end
1768
-
1769
- # An overridden version of `DateTime#to_time` that, if there is an
1770
- # associated {TimezoneOffset}, returns a {DateTimeWithOffset} with that
1771
- # offset.
1772
- #
1773
- # @return [Time] if there is an associated {TimezoneOffset}, a
1774
- # {TimeWithOffset} representation of this {DateTimeWithOffset}, otherwise
1775
- # a `Time` representation.
1776
- def to_time; end
1777
-
1778
- # An overridden version of `DateTime#upto` that clears the associated
1779
- # {TimezoneOffset} of the returned or yielded instances.
1780
- def upto(max); end
1781
-
1782
- protected
1783
-
1784
- # Clears the associated {TimezoneOffset}.
1785
- #
1786
- # @return [DateTimeWithOffset] `self`.
1787
- def clear_timezone_offset; end
1788
- end
1789
-
1790
- # A rule that transitions on the nth occurrence of a particular day of week
1791
- # of a calendar month.
1792
- #
1793
- # @private
1794
- class TZInfo::DayOfMonthTransitionRule < ::TZInfo::DayOfWeekTransitionRule
1795
- # Initializes a new {DayOfMonthTransitionRule}.
1796
- #
1797
- # @param transition_at [Integer] the time in seconds after midnight local
1798
- # time at which the transition occurs.
1799
- # @param week [Integer] the week of the month when the transition occurs (1
1800
- # to 4).
1801
- # @param day_of_week [Integer] the day of the week when the transition
1802
- # occurs. 0 is Sunday, 6 is Saturday.
1803
- # @param month [Integer] the month of the year when the transition occurs.
1804
- # @raise [ArgumentError] if `week` is less than 1 or greater than 4.
1805
- # @raise [ArgumentError] if `day_of_week` is not an `Integer`.
1806
- # @raise [ArgumentError] if `day_of_week` is less than 0 or greater than 6.
1807
- # @raise [ArgumentError] if `month` is less than 1 or greater than 12.
1808
- # @raise [ArgumentError] if `transition_at` is not an `Integer`.
1809
- # @raise [ArgumentError] if `month` is not an `Integer`.
1810
- # @raise [ArgumentError] if `week` is not an `Integer`.
1811
- # @return [DayOfMonthTransitionRule] a new instance of DayOfMonthTransitionRule
1812
- def initialize(month, week, day_of_week, transition_at = T.unsafe(nil)); end
1813
-
1814
- # Determines if this {DayOfMonthTransitionRule} is equal to another
1815
- # instance.
1816
- #
1817
- # @param r [Object] the instance to test for equality.
1818
- # @return [Boolean] `true` if `r` is a {DayOfMonthTransitionRule} with the
1819
- # same {transition_at}, month, week and day of week as this
1820
- # {DayOfMonthTransitionRule}, otherwise `false`.
1821
- def ==(r); end
1822
-
1823
- # Determines if this {DayOfMonthTransitionRule} is equal to another
1824
- # instance.
1825
- #
1826
- # @param r [Object] the instance to test for equality.
1827
- # @return [Boolean] `true` if `r` is a {DayOfMonthTransitionRule} with the
1828
- # same {transition_at}, month, week and day of week as this
1829
- # {DayOfMonthTransitionRule}, otherwise `false`.
1830
- def eql?(r); end
1831
-
1832
- protected
1833
-
1834
- # Returns a `Time` representing midnight local time on the day specified by
1835
- # the rule for the given offset and year.
1836
- #
1837
- # @param offset [TimezoneOffset] the current offset at the time of the
1838
- # transition.
1839
- # @param year [Integer] the year in which the transition occurs.
1840
- # @return [Time] midnight local time on the day specified by the rule for
1841
- # the given offset and year.
1842
- def get_day(offset, year); end
1843
-
1844
- # @return [Array] an `Array` of parameters that will influence the output of
1845
- # {hash}.
1846
- def hash_args; end
1847
-
1848
- # @return [Integer] the day the week starts on for a month starting on a
1849
- # Sunday.
1850
- def offset_start; end
1851
- end
1852
-
1853
- # A base class for rules that transition on a particular day of week of a
1854
- # given week (subclasses specify which week of the month).
1855
- #
1856
- # @abstract
1857
- # @private
1858
- class TZInfo::DayOfWeekTransitionRule < ::TZInfo::TransitionRule
1859
- # Initializes a new {DayOfWeekTransitionRule}.
1860
- #
1861
- # @param transition_at [Integer] the time in seconds after midnight local
1862
- # time at which the transition occurs.
1863
- # @param day_of_week [Integer] the day of the week when the transition
1864
- # occurs. 0 is Sunday, 6 is Saturday.
1865
- # @param month [Integer] the month of the year when the transition occurs.
1866
- # @raise [ArgumentError] if `day_of_week` is not an `Integer`.
1867
- # @raise [ArgumentError] if `day_of_week` is less than 0 or greater than 6.
1868
- # @raise [ArgumentError] if `month` is not an `Integer`.
1869
- # @raise [ArgumentError] if `transition_at` is not an `Integer`.
1870
- # @raise [ArgumentError] if `month` is less than 1 or greater than 12.
1871
- # @return [DayOfWeekTransitionRule] a new instance of DayOfWeekTransitionRule
1872
- def initialize(month, day_of_week, transition_at); end
1873
-
1874
- # Determines if this {DayOfWeekTransitionRule} is equal to another
1875
- # instance.
1876
- #
1877
- # @param r [Object] the instance to test for equality.
1878
- # @return [Boolean] `true` if `r` is a {DayOfWeekTransitionRule} with the
1879
- # same {transition_at}, month and day of week as this
1880
- # {DayOfWeekTransitionRule}, otherwise `false`.
1881
- def ==(r); end
1882
-
1883
- # Determines if this {DayOfWeekTransitionRule} is equal to another
1884
- # instance.
1885
- #
1886
- # @param r [Object] the instance to test for equality.
1887
- # @return [Boolean] `true` if `r` is a {DayOfWeekTransitionRule} with the
1888
- # same {transition_at}, month and day of week as this
1889
- # {DayOfWeekTransitionRule}, otherwise `false`.
1890
- def eql?(r); end
1891
-
1892
- # @return [Boolean] `false`.
1893
- def is_always_first_day_of_year?; end
1894
-
1895
- # @return [Boolean] `false`.
1896
- def is_always_last_day_of_year?; end
1897
-
1898
- protected
1899
-
1900
- # @return [Integer] the day of the week (0 to 6 for Sunday to Monday).
1901
- def day_of_week; end
1902
-
1903
- # @return [Array] an `Array` of parameters that will influence the output of
1904
- # {hash}.
1905
- def hash_args; end
1906
-
1907
- # @return [Integer] the month of the year (1 to 12).
1908
- def month; end
1909
- end
1910
-
1911
- # A base class for transition rules that activate based on an integer day of
1912
- # the year.
1913
- #
1914
- # @abstract
1915
- # @private
1916
- class TZInfo::DayOfYearTransitionRule < ::TZInfo::TransitionRule
1917
- # Initializes a new {DayOfYearTransitionRule}.
1918
- #
1919
- # @param day [Integer] the day of the year on which the transition occurs.
1920
- # The precise meaning is defined by subclasses.
1921
- # @param transition_at [Integer] the time in seconds after midnight local
1922
- # time at which the transition occurs.
1923
- # @raise [ArgumentError] if `transition_at` is not an `Integer`.
1924
- # @raise [ArgumentError] if `day` is not an `Integer`.
1925
- # @return [DayOfYearTransitionRule] a new instance of DayOfYearTransitionRule
1926
- def initialize(day, transition_at); end
1927
-
1928
- # Determines if this {DayOfYearTransitionRule} is equal to another instance.
1929
- #
1930
- # @param r [Object] the instance to test for equality.
1931
- # @return [Boolean] `true` if `r` is a {DayOfYearTransitionRule} with the
1932
- # same {transition_at} and day as this {DayOfYearTransitionRule},
1933
- # otherwise `false`.
1934
- def ==(r); end
1935
-
1936
- # Determines if this {DayOfYearTransitionRule} is equal to another instance.
1937
- #
1938
- # @param r [Object] the instance to test for equality.
1939
- # @return [Boolean] `true` if `r` is a {DayOfYearTransitionRule} with the
1940
- # same {transition_at} and day as this {DayOfYearTransitionRule},
1941
- # otherwise `false`.
1942
- def eql?(r); end
1943
-
1944
- protected
1945
-
1946
- # @return [Array] an `Array` of parameters that will influence the output of
1947
- # {hash}.
1948
- def hash_args; end
1949
-
1950
- # @return [Integer] the day multipled by the number of seconds in a day.
1951
- def seconds; end
1952
- end
1953
-
1954
- # Modules and classes used by the format 1 version of TZInfo::Data.
1955
- #
1956
- # @private
1957
- module TZInfo::Format1; end
1958
-
1959
- # Instances of {Format1::CountryDefiner} are yielded to the format 1 version
1960
- # of `TZInfo::Data::Indexes::Countries` by {CountryIndexDefinition} to allow
1961
- # the zones of a country to be specified.
1962
- #
1963
- # @private
1964
- class TZInfo::Format1::CountryDefiner < ::TZInfo::Format2::CountryDefiner
1965
- # Initializes a new {CountryDefiner}.
1966
- #
1967
- # @return [CountryDefiner] a new instance of CountryDefiner
1968
- def initialize(identifier_deduper, description_deduper); end
1969
- end
1970
-
1971
- # The format 1 TZInfo::Data country index file includes
1972
- # {Format1::CountryIndexDefinition}, which provides a
1973
- # {CountryIndexDefinition::ClassMethods#country country} method used to
1974
- # define each country in the index.
1975
- #
1976
- # @private
1977
- module TZInfo::Format1::CountryIndexDefinition
1978
- mixes_in_class_methods ::TZInfo::Format1::CountryIndexDefinition::ClassMethods
1979
-
1980
- class << self
1981
- # Adds class methods to the includee and initializes class instance
1982
- # variables.
1983
- #
1984
- # @param base [Module] the includee.
1985
- def append_features(base); end
1986
- end
1987
- end
1988
-
1989
- # Class methods for inclusion.
1990
- #
1991
- # @private
1992
- module TZInfo::Format1::CountryIndexDefinition::ClassMethods
1993
- # @return [Hash<String, DataSources::CountryInfo>] a frozen `Hash`
1994
- # of all the countries that have been defined in the index keyed by
1995
- # their codes.
1996
- def countries; end
1997
-
1998
- private
1999
-
2000
- # Defines a country with an ISO 3166-1 alpha-2 country code and name.
2001
- #
2002
- # @param code [String] the ISO 3166-1 alpha-2 country code.
2003
- # @param name [String] the name of the country.
2004
- # @yield [definer] (optional) to obtain the time zones for the country.
2005
- # @yieldparam definer [CountryDefiner] a {CountryDefiner} instance.
2006
- def country(code, name); end
2007
- end
2008
-
2009
- # Instances of {Format1::TimezoneDefiner} are yielded to TZInfo::Data
2010
- # format 1 modules by {TimezoneDefinition} to allow the offsets and
2011
- # transitions of the time zone to be specified.
2012
- #
2013
- # @private
2014
- class TZInfo::Format1::TimezoneDefiner < ::TZInfo::Format2::TimezoneDefiner
2015
- # Defines an offset.
2016
- #
2017
- # @param id [Symbol] an arbitrary value used identify the offset in
2018
- # subsequent calls to transition. It must be unique.
2019
- # @param utc_offset [Integer] the base offset from UTC of the zone in
2020
- # seconds. This does not include daylight savings time.
2021
- # @param std_offset [Integer] the daylight savings offset from the base
2022
- # offset in seconds. Typically either 0 or 3600.
2023
- # @param abbreviation [Symbol] an abbreviation for the offset, for
2024
- # example, `:EST` or `:EDT`.
2025
- # @raise [ArgumentError] if another offset has already been defined with
2026
- # the given id.
2027
- def offset(id, utc_offset, std_offset, abbreviation); end
2028
-
2029
- # Defines a transition to a given offset.
2030
- #
2031
- # Transitions must be defined in increasing time order.
2032
- #
2033
- # @param year [Integer] the UTC year in which the transition occurs. Used
2034
- # in earlier versions of TZInfo, but now ignored.
2035
- # @param month [Integer] the UTC month in which the transition occurs.
2036
- # Used in earlier versions of TZInfo, but now ignored.
2037
- # @param offset_id [Symbol] references the id of a previously defined
2038
- # offset (see #offset).
2039
- # @param timestamp_value [Integer] the time the transition occurs as an
2040
- # Integer number of seconds since 1970-01-01 00:00:00 UTC ignoring leap
2041
- # seconds (i.e. each day is treated as if it were 86,400 seconds long).
2042
- # @param datetime_numerator [Integer] the time of the transition as the
2043
- # numerator of the `Rational` returned by `DateTime#ajd`. Used in
2044
- # earlier versions of TZInfo, but now ignored.
2045
- # @param datetime_denominator [Integer] the time of the transition as the
2046
- # denominator of the `Rational` returned by `DateTime#ajd`. Used in
2047
- # earlier versions of TZInfo, but now ignored.
2048
- # @raise [ArgumentError] if `offset_id` does not reference a defined
2049
- # offset.
2050
- # @raise [ArgumentError] if `timestamp_value` is not greater than the
2051
- # `timestamp_value` of the previously defined transition.
2052
- # @raise [ArgumentError] if `datetime_numerator` is specified, but
2053
- # `datetime_denominator` is not. In older versions of TZInfo, it was
2054
- # possible to define a transition with the `DateTime` numerator as the
2055
- # 4th parameter and the denominator as the 5th parameter. This style of
2056
- # definition is not used in released versions of TZInfo::Data.
2057
- def transition(year, month, offset_id, timestamp_value, datetime_numerator = T.unsafe(nil), datetime_denominator = T.unsafe(nil)); end
2058
- end
2059
-
2060
- # {Format1::TimezoneDefinition} is included into format 1 time zone
2061
- # definition modules and provides the methods for defining time zones.
2062
- #
2063
- # @private
2064
- module TZInfo::Format1::TimezoneDefinition
2065
- mixes_in_class_methods ::TZInfo::Format2::TimezoneDefinition::ClassMethods
2066
- mixes_in_class_methods ::TZInfo::Format1::TimezoneDefinition::ClassMethods
2067
-
2068
- class << self
2069
- # Adds class methods to the includee.
2070
- #
2071
- # @param base [Module] the includee.
2072
- def append_features(base); end
2073
- end
2074
- end
2075
-
2076
- # Class methods for inclusion.
2077
- #
2078
- # @private
2079
- module TZInfo::Format1::TimezoneDefinition::ClassMethods
2080
- private
2081
-
2082
- # {Format2::TimezoneDefinition::ClassMethods#timezone}.
2083
- #
2084
- # @return the class to be instantiated and yielded by
2085
- def timezone_definer_class; end
2086
- end
2087
-
2088
- # The format 1 TZInfo::Data time zone index file includes
2089
- # {Format1::TimezoneIndexDefinition}, which provides methods used to define
2090
- # time zones in the index.
2091
- #
2092
- # @private
2093
- module TZInfo::Format1::TimezoneIndexDefinition
2094
- mixes_in_class_methods ::TZInfo::Format1::TimezoneIndexDefinition::ClassMethods
2095
-
2096
- class << self
2097
- # Adds class methods to the includee and initializes class instance
2098
- # variables.
2099
- #
2100
- # @param base [Module] the includee.
2101
- def append_features(base); end
2102
- end
2103
- end
2104
-
2105
- # Class methods for inclusion.
2106
- #
2107
- # @private
2108
- module TZInfo::Format1::TimezoneIndexDefinition::ClassMethods
2109
- # @return [Array<String>] a frozen `Array` containing the identifiers of
2110
- # all data time zones. Identifiers are sorted according to
2111
- # `String#<=>`.
2112
- def data_timezones; end
2113
-
2114
- # @return [Array<String>] a frozen `Array` containing the identifiers of
2115
- # all linked time zones. Identifiers are sorted according to
2116
- # `String#<=>`.
2117
- def linked_timezones; end
2118
-
2119
- private
2120
-
2121
- # Adds a linked time zone to the index.
2122
- #
2123
- # @param identifier [String] the time zone identifier.
2124
- def linked_timezone(identifier); end
2125
-
2126
- # Adds a data time zone to the index.
2127
- #
2128
- # @param identifier [String] the time zone identifier.
2129
- def timezone(identifier); end
2130
- end
2131
-
2132
- # Modules and classes used by the format 2 version of TZInfo::Data.
2133
- #
2134
- # @private
2135
- module TZInfo::Format2; end
2136
-
2137
- # Instances of {Format2::CountryDefiner} are yielded to the format 2 version
2138
- # of `TZInfo::Data::Indexes::Countries` by {CountryIndexDefiner} to allow
2139
- # the zones of a country to be specified.
2140
- #
2141
- # @private
2142
- class TZInfo::Format2::CountryDefiner
2143
- # Initializes a new {CountryDefiner}.
2144
- #
2145
- # @param shared_timezones [Hash<Symbol, CountryTimezone>] a `Hash`
2146
- # containing time zones shared by more than one country, keyed by a
2147
- # unique reference.
2148
- # @param identifier_deduper [StringDeduper] a {StringDeduper} instance to
2149
- # use when deduping time zone identifiers.
2150
- # @param description_deduper [StringDeduper] a {StringDeduper} instance to
2151
- # use when deduping time zone descriptions.
2152
- # @return [CountryDefiner] a new instance of CountryDefiner
2153
- def initialize(shared_timezones, identifier_deduper, description_deduper); end
2154
-
2155
- # @overload timezone
2156
- # @overload timezone
2157
- def timezone(identifier_or_reference, latitude_numerator = T.unsafe(nil), latitude_denominator = T.unsafe(nil), longitude_numerator = T.unsafe(nil), longitude_denominator = T.unsafe(nil), description = T.unsafe(nil)); end
2158
-
2159
- # @return [Array<CountryTimezone>] the time zones observed in the country.
2160
- def timezones; end
2161
- end
2162
-
2163
- # Instances of {Format2::CountryIndexDefiner} are yielded to the format 2
2164
- # version of `TZInfo::Data::Indexes::Countries` by {CountryIndexDefinition}
2165
- # to allow countries and their time zones to be specified.
2166
- #
2167
- # @private
2168
- class TZInfo::Format2::CountryIndexDefiner
2169
- # Initializes a new {CountryIndexDefiner}.
2170
- #
2171
- # @param identifier_deduper [StringDeduper] a {StringDeduper} instance to
2172
- # use when deduping time zone identifiers.
2173
- # @param description_deduper [StringDeduper] a {StringDeduper} instance to
2174
- # use when deduping time zone descriptions.
2175
- # @return [CountryIndexDefiner] a new instance of CountryIndexDefiner
2176
- def initialize(identifier_deduper, description_deduper); end
2177
-
2178
- # @return [Hash<String, CountryInfo>] a `Hash` of all the countries that
2179
- # have been defined in the index keyed by their codes.
2180
- def countries; end
2181
-
2182
- # Defines a country.
2183
- #
2184
- # @param code [String] The ISO 3166-1 alpha-2 code of the country.
2185
- # @param name [String] Then name of the country.
2186
- # @yield [definer] yields (optional) to obtain the time zones for the
2187
- # country.
2188
- # @yieldparam definer [CountryDefiner] a {CountryDefiner}
2189
- # instance that should be used to specify the time zones of the country.
2190
- def country(code, name); end
2191
-
2192
- # Defines a time zone shared by many countries with an reference for
2193
- # subsequent use in country definitions. The latitude and longitude are
2194
- # given as the numerator and denominator of a `Rational`.
2195
- #
2196
- # @param reference [Symbol] a unique reference for the time zone.
2197
- # @param identifier [String] the time zone identifier.
2198
- # @param latitude_numerator [Integer] the numerator of the latitude.
2199
- # @param latitude_denominator [Integer] the denominator of the latitude.
2200
- # @param longitude_numerator [Integer] the numerator of the longitude.
2201
- # @param longitude_denominator [Integer] the denominator of the longitude.
2202
- # @param description [String] an optional description for the time zone.
2203
- def timezone(reference, identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = T.unsafe(nil)); end
2204
- end
2205
-
2206
- # The format 2 country index file includes
2207
- # {Format2::CountryIndexDefinition}, which provides a
2208
- # {CountryIndexDefinition::ClassMethods#country_index country_index} method
2209
- # used to define the country index.
2210
- #
2211
- # @private
2212
- module TZInfo::Format2::CountryIndexDefinition
2213
- mixes_in_class_methods ::TZInfo::Format2::CountryIndexDefinition::ClassMethods
2214
-
2215
- class << self
2216
- # Adds class methods to the includee and initializes class instance
2217
- # variables.
2218
- #
2219
- # @param base [Module] the includee.
2220
- def append_features(base); end
2221
- end
2222
- end
2223
-
2224
- # Class methods for inclusion.
2225
- #
2226
- # @private
2227
- module TZInfo::Format2::CountryIndexDefinition::ClassMethods
2228
- # @return [Hash<String, DataSources::CountryInfo>] a frozen `Hash`
2229
- # of all the countries that have been defined in the index keyed by
2230
- # their codes.
2231
- def countries; end
2232
-
2233
- private
2234
-
2235
- # Defines the index.
2236
- #
2237
- # @yield [definer] yields to allow the index to be defined.
2238
- # @yieldparam definer [CountryIndexDefiner] a {CountryIndexDefiner}
2239
- # instance that should be used to define the index.
2240
- def country_index; end
2241
- end
2242
-
2243
- # Instances of {TimezoneDefiner} are yielded to TZInfo::Data modules by
2244
- # {TimezoneDefinition} to allow the offsets and transitions of the time zone
2245
- # to be specified.
2246
- #
2247
- # @private
2248
- class TZInfo::Format2::TimezoneDefiner
2249
- # Initializes a new TimezoneDefiner.
2250
- #
2251
- # @param string_deduper [StringDeduper] a {StringDeduper} instance to use
2252
- # when deduping abbreviations.
2253
- # @return [TimezoneDefiner] a new instance of TimezoneDefiner
2254
- def initialize(string_deduper); end
2255
-
2256
- # Returns the first offset to be defined or `nil` if no offsets have been
2257
- # defined. The first offset is observed before the time of the first
2258
- # transition.
2259
- #
2260
- # @return [TimezoneOffset] the first offset to be defined or `nil` if no
2261
- # offsets have been defined.
2262
- def first_offset; end
2263
-
2264
- # Defines an offset.
2265
- #
2266
- # @param id [Symbol] an arbitrary value used identify the offset in
2267
- # subsequent calls to transition. It must be unique.
2268
- # @param base_utc_offset [Integer] the base offset from UTC of the zone in
2269
- # seconds. This does not include daylight savings time.
2270
- # @param std_offset [Integer] the daylight savings offset from the base
2271
- # offset in seconds. Typically either 0 or 3600.
2272
- # @param abbreviation [String] an abbreviation for the offset, for
2273
- # example, EST or EDT.
2274
- # @raise [ArgumentError] if another offset has already been defined with
2275
- # the given id.
2276
- def offset(id, base_utc_offset, std_offset, abbreviation); end
2277
-
2278
- # Defines the rules that will be used for handling instants after the last
2279
- # transition.
2280
- #
2281
- # This method is currently just a placeholder for forward compatibility
2282
- # that accepts and ignores any arguments passed.
2283
- #
2284
- # Support for subsequent rules will be added in a future version of TZInfo
2285
- # and the rules will be included in format 2 releases of TZInfo::Data.
2286
- def subsequent_rules(*args); end
2287
-
2288
- # Defines a transition to a given offset.
2289
- #
2290
- # Transitions must be defined in increasing time order.
2291
- #
2292
- # @param offset_id [Symbol] references the id of a previously defined
2293
- # offset.
2294
- # @param timestamp_value [Integer] the time the transition occurs as a
2295
- # number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds
2296
- # (i.e. each day is treated as if it were 86,400 seconds long).
2297
- # @raise [ArgumentError] if `offset_id` does not reference a defined
2298
- # offset.
2299
- # @raise [ArgumentError] if `timestamp_value` is not greater than the
2300
- # `timestamp_value` of the previously defined transition.
2301
- def transition(offset_id, timestamp_value); end
2302
-
2303
- # @return [Array<TimezoneTransition>] the defined transitions of the time
2304
- # zone.
2305
- def transitions; end
2306
- end
2307
-
2308
- # {Format2::TimezoneDefinition} is included into format 2 time zone
2309
- # definition modules and provides methods for defining time zones.
2310
- #
2311
- # @private
2312
- module TZInfo::Format2::TimezoneDefinition
2313
- mixes_in_class_methods ::TZInfo::Format2::TimezoneDefinition::ClassMethods
2314
-
2315
- class << self
2316
- # Adds class methods to the includee.
2317
- #
2318
- # @param base [Module] the includee.
2319
- def append_features(base); end
2320
- end
2321
- end
2322
-
2323
- # Class methods for inclusion.
2324
- #
2325
- # @private
2326
- module TZInfo::Format2::TimezoneDefinition::ClassMethods
2327
- # @return [TimezoneInfo] the last time zone to be defined.
2328
- def get; end
2329
-
2330
- private
2331
-
2332
- # Defines a linked time zone.
2333
- #
2334
- # @param identifier [String] the identifier of the time zone being
2335
- # defined.
2336
- # @param link_to_identifier [String] the identifier the new time zone
2337
- # links to (is an alias for).
2338
- def linked_timezone(identifier, link_to_identifier); end
2339
-
2340
- # Defines a data time zone.
2341
- #
2342
- # @param identifier [String] the identifier of the time zone.
2343
- # @yield [definer] yields to the caller to define the time zone.
2344
- # @yieldparam definer [Object] an instance of the class returned by
2345
- # {#timezone_definer_class}, typically {TimezoneDefiner}.
2346
- def timezone(identifier); end
2347
-
2348
- # @return [Class] the class to be instantiated and yielded by
2349
- # {#timezone}.
2350
- def timezone_definer_class; end
2351
- end
2352
-
2353
- # Instances of {TimezoneIndexDefiner} are yielded by
2354
- # {TimezoneIndexDefinition} to allow the time zone index to be defined.
2355
- #
2356
- # @private
2357
- class TZInfo::Format2::TimezoneIndexDefiner
2358
- # Initializes a new TimezoneDefiner.
2359
- #
2360
- # @param string_deduper [StringDeduper] a {StringDeduper} instance to use
2361
- # when deduping identifiers.
2362
- # @return [TimezoneIndexDefiner] a new instance of TimezoneIndexDefiner
2363
- def initialize(string_deduper); end
2364
-
2365
- # Adds a data time zone to the index.
2366
- #
2367
- # @param identifier [String] the time zone identifier.
2368
- def data_timezone(identifier); end
2369
-
2370
- # @return [Array<String>] the identifiers of all data time zones.
2371
- def data_timezones; end
2372
-
2373
- # Adds a linked time zone to the index.
2374
- #
2375
- # @param identifier [String] the time zone identifier.
2376
- def linked_timezone(identifier); end
2377
-
2378
- # @return [Array<String>] the identifiers of all linked time zones.
2379
- def linked_timezones; end
2380
- end
2381
-
2382
- # The format 2 time zone index file includes {TimezoneIndexDefinition},
2383
- # which provides the {TimezoneIndexDefinition::ClassMethods#timezone_index
2384
- # timezone_index} method used to define the index.
2385
- #
2386
- # @private
2387
- module TZInfo::Format2::TimezoneIndexDefinition
2388
- mixes_in_class_methods ::TZInfo::Format2::TimezoneIndexDefinition::ClassMethods
2389
-
2390
- class << self
2391
- # Adds class methods to the includee and initializes class instance
2392
- # variables.
2393
- #
2394
- # @param base [Module] the includee.
2395
- def append_features(base); end
2396
- end
2397
- end
2398
-
2399
- # Class methods for inclusion.
2400
- #
2401
- # @private
2402
- module TZInfo::Format2::TimezoneIndexDefinition::ClassMethods
2403
- # @return [Array<String>] a frozen `Array` containing the identifiers of
2404
- # all data time zones. Identifiers are sorted according to
2405
- # `String#<=>`.
2406
- def data_timezones; end
2407
-
2408
- # @return [Array<String>] a frozen `Array` containing the identifiers of
2409
- # all linked time zones. Identifiers are sorted according to
2410
- # `String#<=>`.
2411
- def linked_timezones; end
2412
-
2413
- # Defines the index.
2414
- #
2415
- # @yield [definer] yields to the caller to allow the index to be
2416
- # defined.
2417
- # @yieldparam definer [TimezoneIndexDefiner] a {TimezoneIndexDefiner}
2418
- # instance that should be used to define the index.
2419
- def timezone_index; end
2420
- end
2421
-
2422
- # A {Timezone} based on a {DataSources::TimezoneInfo}.
2423
- #
2424
- # @abstract
2425
- class TZInfo::InfoTimezone < ::TZInfo::Timezone
2426
- # Initializes a new {InfoTimezone}.
2427
- #
2428
- # {InfoTimezone} instances should not normally be created directly. Use
2429
- # the {Timezone.get} method to obtain {Timezone} instances.
2430
- #
2431
- # @param info [DataSources::TimezoneInfo] a {DataSources::TimezoneInfo}
2432
- # instance supplied by a {DataSource} that will be used as the source of
2433
- # data for this {InfoTimezone}.
2434
- # @return [InfoTimezone] a new instance of InfoTimezone
2435
- def initialize(info); end
2436
-
2437
- # @return [String] the identifier of the time zone, for example,
2438
- # `"Europe/Paris"`.
2439
- def identifier; end
2440
-
2441
- protected
2442
-
2443
- # @return [DataSources::TimezoneInfo] the {DataSources::TimezoneInfo} this
2444
- # {InfoTimezone} is based on.
2445
- def info; end
2446
- end
2447
-
2448
- # {InvalidCountryCode} is raised by {Country#get} if the code given is not a
2449
- # valid ISO 3166-1 alpha-2 code.
2450
- class TZInfo::InvalidCountryCode < ::StandardError; end
2451
-
2452
- # {InvalidDataSource} is raised if the selected {DataSource} doesn't implement
2453
- # one of the required methods.
2454
- class TZInfo::InvalidDataSource < ::StandardError; end
2455
-
2456
- # {InvalidTimezoneIdentifier} is raised by {Timezone.get} if the identifier
2457
- # given is not valid.
2458
- class TZInfo::InvalidTimezoneIdentifier < ::StandardError; end
2459
-
2460
- # Defines transitions that occur on the one-based nth Julian day of the year.
2461
- #
2462
- # Leap days are not counted. Day 1 is 1 January. Day 60 is always 1 March.
2463
- # Day 365 is always 31 December.
2464
- #
2465
- # @private
2466
- class TZInfo::JulianDayOfYearTransitionRule < ::TZInfo::DayOfYearTransitionRule
2467
- # Initializes a new {JulianDayOfYearTransitionRule}.
2468
- #
2469
- # @param day [Integer] the one-based Julian day of the year on which the
2470
- # transition occurs (1 to 365 inclusive).
2471
- # @param transition_at [Integer] the time in seconds after midnight local
2472
- # time at which the transition occurs.
2473
- # @raise [ArgumentError] if `transition_at` is not an `Integer`.
2474
- # @raise [ArgumentError] if `day` is not an `Integer`.
2475
- # @raise [ArgumentError] if `day` is less than 1 or greater than 365.
2476
- # @return [JulianDayOfYearTransitionRule] a new instance of JulianDayOfYearTransitionRule
2477
- def initialize(day, transition_at = T.unsafe(nil)); end
2478
-
2479
- # Determines if this {JulianDayOfYearTransitionRule} is equal to another
2480
- # instance.
2481
- #
2482
- # @param r [Object] the instance to test for equality.
2483
- # @return [Boolean] `true` if `r` is a {JulianDayOfYearTransitionRule} with
2484
- # the same {transition_at} and day as this
2485
- # {JulianDayOfYearTransitionRule}, otherwise `false`.
2486
- def ==(r); end
2487
-
2488
- # Determines if this {JulianDayOfYearTransitionRule} is equal to another
2489
- # instance.
2490
- #
2491
- # @param r [Object] the instance to test for equality.
2492
- # @return [Boolean] `true` if `r` is a {JulianDayOfYearTransitionRule} with
2493
- # the same {transition_at} and day as this
2494
- # {JulianDayOfYearTransitionRule}, otherwise `false`.
2495
- def eql?(r); end
2496
-
2497
- # @return [Boolean] `true` if the day specified by this transition is the
2498
- # first in the year (a day number of 1), otherwise `false`.
2499
- def is_always_first_day_of_year?; end
2500
-
2501
- # @return [Boolean] `true` if the day specified by this transition is the
2502
- # last in the year (a day number of 365), otherwise `false`.
2503
- def is_always_last_day_of_year?; end
2504
-
2505
- protected
2506
-
2507
- # Returns a `Time` representing midnight local time on the day specified by
2508
- # the rule for the given offset and year.
2509
- #
2510
- # @param offset [TimezoneOffset] the current offset at the time of the
2511
- # transition.
2512
- # @param year [Integer] the year in which the transition occurs.
2513
- # @return [Time] midnight local time on the day specified by the rule for
2514
- # the given offset and year.
2515
- def get_day(offset, year); end
2516
-
2517
- # @return [Array] an `Array` of parameters that will influence the output of
2518
- # {hash}.
2519
- def hash_args; end
2520
- end
2521
-
2522
- # The 60 days in seconds.
2523
- TZInfo::JulianDayOfYearTransitionRule::LEAP = T.let(T.unsafe(nil), Integer)
2524
-
2525
- # The length of a non-leap year in seconds.
2526
- TZInfo::JulianDayOfYearTransitionRule::YEAR = T.let(T.unsafe(nil), Integer)
2527
-
2528
- # A rule that transitions on the last occurrence of a particular day of week
2529
- # of a calendar month.
2530
- #
2531
- # @private
2532
- class TZInfo::LastDayOfMonthTransitionRule < ::TZInfo::DayOfWeekTransitionRule
2533
- # Initializes a new {LastDayOfMonthTransitionRule}.
2534
- #
2535
- # @param transition_at [Integer] the time in seconds after midnight local
2536
- # time at which the transition occurs.
2537
- # @param day_of_week [Integer] the day of the week when the transition
2538
- # occurs. 0 is Sunday, 6 is Saturday.
2539
- # @param month [Integer] the month of the year when the transition occurs.
2540
- # @raise [ArgumentError] if `day_of_week` is not an `Integer`.
2541
- # @raise [ArgumentError] if `day_of_week` is less than 0 or greater than 6.
2542
- # @raise [ArgumentError] if `month` is not an `Integer`.
2543
- # @raise [ArgumentError] if `transition_at` is not an `Integer`.
2544
- # @raise [ArgumentError] if `month` is less than 1 or greater than 12.
2545
- # @return [LastDayOfMonthTransitionRule] a new instance of LastDayOfMonthTransitionRule
2546
- def initialize(month, day_of_week, transition_at = T.unsafe(nil)); end
2547
-
2548
- # Determines if this {LastDayOfMonthTransitionRule} is equal to another
2549
- # instance.
2550
- #
2551
- # @param r [Object] the instance to test for equality.
2552
- # @return [Boolean] `true` if `r` is a {LastDayOfMonthTransitionRule} with
2553
- # the same {transition_at}, month and day of week as this
2554
- # {LastDayOfMonthTransitionRule}, otherwise `false`.
2555
- def ==(r); end
2556
-
2557
- # Determines if this {LastDayOfMonthTransitionRule} is equal to another
2558
- # instance.
2559
- #
2560
- # @param r [Object] the instance to test for equality.
2561
- # @return [Boolean] `true` if `r` is a {LastDayOfMonthTransitionRule} with
2562
- # the same {transition_at}, month and day of week as this
2563
- # {LastDayOfMonthTransitionRule}, otherwise `false`.
2564
- def eql?(r); end
2565
-
2566
- protected
2567
-
2568
- # Returns a `Time` representing midnight local time on the day specified by
2569
- # the rule for the given offset and year.
2570
- #
2571
- # @param offset [TimezoneOffset] the current offset at the time of the
2572
- # transition.
2573
- # @param year [Integer] the year in which the transition occurs.
2574
- # @return [Time] midnight local time on the day specified by the rule for
2575
- # the given offset and year.
2576
- def get_day(offset, year); end
2577
- end
2578
-
2579
- # Represents time zones that are defined as a link to or alias for another
2580
- # time zone.
2581
- class TZInfo::LinkedTimezone < ::TZInfo::InfoTimezone
2582
- # Initializes a new {LinkedTimezone}.
2583
- #
2584
- # {LinkedTimezone} instances should not normally be created directly. Use
2585
- # the {Timezone.get} method to obtain {Timezone} instances.
2586
- #
2587
- # @param info [DataSources::LinkedTimezoneInfo] a
2588
- # {DataSources::LinkedTimezoneInfo} instance supplied by a {DataSource}
2589
- # that will be used as the source of data for this {LinkedTimezone}.
2590
- # @return [LinkedTimezone] a new instance of LinkedTimezone
2591
- def initialize(info); end
2592
-
2593
- # Returns the canonical {Timezone} instance for this {LinkedTimezone}.
2594
- #
2595
- # For a {LinkedTimezone}, this is the canonical zone of the link target.
2596
- #
2597
- # @return [Timezone] the canonical {Timezone} instance for this {Timezone}.
2598
- def canonical_zone; end
2599
-
2600
- # Returns the {TimezonePeriod} that is valid at a given time.
2601
- #
2602
- # Unlike {period_for_local} and {period_for_utc}, the UTC offset of the
2603
- # `time` parameter is taken into consideration.
2604
- #
2605
- # @param time [Object] a `Time`, `DateTime` or {Timestamp}.
2606
- # @raise [ArgumentError] if `time` is `nil`.
2607
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified
2608
- # offset.
2609
- # @return [TimezonePeriod] the {TimezonePeriod} that is valid at `time`.
2610
- def period_for(time); end
2611
-
2612
- # Returns the set of {TimezonePeriod}s that are valid for the given
2613
- # local time as an `Array`.
2614
- #
2615
- # The UTC offset of the `local_time` parameter is ignored (it is treated as
2616
- # a time in the time zone represented by `self`).
2617
- #
2618
- # This will typically return an `Array` containing a single
2619
- # {TimezonePeriod}. More than one {TimezonePeriod} will be returned when the
2620
- # local time is ambiguous (for example, when daylight savings time ends). An
2621
- # empty `Array` will be returned when the local time is not valid (for
2622
- # example, when daylight savings time begins).
2623
- #
2624
- # To obtain just a single {TimezonePeriod} in all cases, use
2625
- # {period_for_local} instead and specify how ambiguities should be resolved.
2626
- #
2627
- # @param local_time [Object] a `Time`, `DateTime` or {Timestamp}.
2628
- # @raise [ArgumentError] if `local_time` is `nil`.
2629
- # @return [Array<TimezonePeriod>] the set of {TimezonePeriod}s that are
2630
- # valid at `local_time`.
2631
- def periods_for_local(local_time); end
2632
-
2633
- # Returns an `Array` of {TimezoneTransition} instances representing the
2634
- # times where the UTC offset of the timezone changes.
2635
- #
2636
- # Transitions are returned up to a given time (`to`).
2637
- #
2638
- # A from time may also be supplied using the `from` parameter. If from is
2639
- # not `nil`, only transitions from that time onwards will be returned.
2640
- #
2641
- # Comparisons with `to` are exclusive. Comparisons with `from` are
2642
- # inclusive. If a transition falls precisely on `to`, it will be excluded.
2643
- # If a transition falls on `from`, it will be included.
2644
- #
2645
- # @param to [Object] a `Time`, `DateTime` or {Timestamp} specifying the
2646
- # latest (exclusive) transition to return.
2647
- # @param from [Object] an optional `Time`, `DateTime` or {Timestamp}
2648
- # specifying the earliest (inclusive) transition to return.
2649
- # @raise [ArgumentError] if `from` is specified and `to` is not greater than
2650
- # `from`.
2651
- # @raise [ArgumentError] is raised if `to` is `nil`.
2652
- # @raise [ArgumentError] if either `to` or `from` is a {Timestamp} with an
2653
- # unspecified offset.
2654
- # @return [Array<TimezoneTransition>] the transitions that are earlier than
2655
- # `to` and, if specified, at or later than `from`. Transitions are ordered
2656
- # by when they occur, from earliest to latest.
2657
- def transitions_up_to(to, from = T.unsafe(nil)); end
2658
- end
2659
-
2660
- # Represents the infinite period of time in a time zone that constantly
2661
- # observes the same offset from UTC (has an unbounded start and end).
2662
- class TZInfo::OffsetTimezonePeriod < ::TZInfo::TimezonePeriod
2663
- # Initializes an {OffsetTimezonePeriod}.
2664
- #
2665
- # @param offset [TimezoneOffset] the offset that is constantly observed.
2666
- # @raise [ArgumentError] if `offset` is `nil`.
2667
- # @return [OffsetTimezonePeriod] a new instance of OffsetTimezonePeriod
2668
- def initialize(offset); end
2669
-
2670
- # Determines if this {OffsetTimezonePeriod} is equal to another instance.
2671
- #
2672
- # @param p [Object] the instance to test for equality.
2673
- # @return [Boolean] `true` if `p` is a {OffsetTimezonePeriod} with the same
2674
- # {offset}, otherwise `false`.
2675
- def ==(p); end
2676
-
2677
- # @return [TimezoneTransition] the transition that defines the end of this
2678
- # {TimezonePeriod}, always `nil` for {OffsetTimezonePeriod}.
2679
- def end_transition; end
2680
-
2681
- # Determines if this {OffsetTimezonePeriod} is equal to another instance.
2682
- #
2683
- # @param p [Object] the instance to test for equality.
2684
- # @return [Boolean] `true` if `p` is a {OffsetTimezonePeriod} with the same
2685
- # {offset}, otherwise `false`.
2686
- def eql?(p); end
2687
-
2688
- # @return [Integer] a hash based on {offset}.
2689
- def hash; end
2690
-
2691
- # @return [TimezoneTransition] the transition that defines the start of this
2692
- # {TimezonePeriod}, always `nil` for {OffsetTimezonePeriod}.
2693
- def start_transition; end
2694
- end
2695
-
2696
- # {PeriodNotFound} is raised to indicate that no {TimezonePeriod} matching a
2697
- # given time could be found.
2698
- class TZInfo::PeriodNotFound < ::StandardError; end
2699
-
2700
- # Maintains a pool of `String` instances. The {#dedupe} method will return
2701
- # either a pooled copy of a given `String` or add the instance to the pool.
2702
- #
2703
- # @private
2704
- class TZInfo::StringDeduper
2705
- # Initializes a new {StringDeduper}.
2706
- #
2707
- # @return [StringDeduper] a new instance of StringDeduper
2708
- def initialize; end
2709
-
2710
- # @param string [String] the string to deduplicate.
2711
- # @return [bool] `string` if it is frozen, otherwise a frozen, possibly
2712
- # pre-existing copy of `string`.
2713
- def dedupe(string); end
2714
-
2715
- protected
2716
-
2717
- # Creates a `Hash` to store pooled `String` instances.
2718
- #
2719
- # @param block [Proc] Default value block to be passed to `Hash.new`.
2720
- # @return [Hash] a `Hash` to store pooled `String` instances.
2721
- def create_hash(&block); end
2722
-
2723
- class << self
2724
- # @return [StringDeduper] a globally available singleton instance of
2725
- # {StringDeduper}. This instance is safe for use in concurrently
2726
- # executing threads.
2727
- def global; end
2728
- end
2729
- end
2730
-
2731
- # A subclass of `Time` used to represent local times. {TimeWithOffset} holds a
2732
- # reference to the related {TimezoneOffset} and overrides various methods to
2733
- # return results appropriate for the {TimezoneOffset}. Certain operations will
2734
- # clear the associated {TimezoneOffset} (if the {TimezoneOffset} would not
2735
- # necessarily be valid for the result). Once the {TimezoneOffset} has been
2736
- # cleared, {TimeWithOffset} behaves identically to `Time`.
2737
- #
2738
- # Arithmetic performed on {TimeWithOffset} instances is _not_ time zone-aware.
2739
- # Regardless of whether transitions in the time zone are crossed, results of
2740
- # arithmetic operations will always maintain the same offset from UTC
2741
- # (`utc_offset`). The associated {TimezoneOffset} will aways be cleared.
2742
- class TZInfo::TimeWithOffset < ::Time
2743
- include ::TZInfo::WithOffset
2744
-
2745
- # An overridden version of `Time#dst?` that, if there is an associated
2746
- # {TimezoneOffset}, returns the result of calling {TimezoneOffset#dst? dst?}
2747
- # on that offset.
2748
- #
2749
- # @return [Boolean] `true` if daylight savings time is being observed,
2750
- # otherwise `false`.
2751
- def dst?; end
2752
-
2753
- # An overridden version of `Time#getlocal` that clears the associated
2754
- # {TimezoneOffset} if the base implementation of `getlocal` returns a
2755
- # {TimeWithOffset}.
2756
- #
2757
- # @return [Time] a representation of the {TimeWithOffset} using either the
2758
- # local time zone or the given offset.
2759
- def getlocal(*args); end
2760
-
2761
- # An overridden version of `Time#gmtime` that clears the associated
2762
- # {TimezoneOffset}.
2763
- #
2764
- # @return [TimeWithOffset] `self`.
2765
- def gmtime; end
2766
-
2767
- # An overridden version of `Time#dst?` that, if there is an associated
2768
- # {TimezoneOffset}, returns the result of calling {TimezoneOffset#dst? dst?}
2769
- # on that offset.
2770
- #
2771
- # @return [Boolean] `true` if daylight savings time is being observed,
2772
- # otherwise `false`.
2773
- def isdst; end
2774
-
2775
- # An overridden version of `Time#localtime` that clears the associated
2776
- # {TimezoneOffset}.
2777
- #
2778
- # @return [TimeWithOffset] `self`.
2779
- def localtime(*args); end
2780
-
2781
- # An overridden version of `Time#round` that, if there is an associated
2782
- # {TimezoneOffset}, returns a {TimeWithOffset} preserving that offset.
2783
- #
2784
- # @return [Time] the rounded time.
2785
- def round(ndigits = T.unsafe(nil)); end
2786
-
2787
- # Marks this {TimeWithOffset} as a local time with the UTC offset of a given
2788
- # {TimezoneOffset} and sets the associated {TimezoneOffset}.
2789
- #
2790
- # @param timezone_offset [TimezoneOffset] the {TimezoneOffset} to use to set
2791
- # the offset of this {TimeWithOffset}.
2792
- # @raise [ArgumentError] if `timezone_offset` is `nil`.
2793
- # @return [TimeWithOffset] `self`.
2794
- def set_timezone_offset(timezone_offset); end
2795
-
2796
- # @return [TimezoneOffset] the {TimezoneOffset} associated with this
2797
- # instance.
2798
- def timezone_offset; end
2799
-
2800
- # An overridden version of `Time#to_a`. The `isdst` (index 8) and `zone`
2801
- # (index 9) elements of the array are set according to the associated
2802
- # {TimezoneOffset}.
2803
- #
2804
- # @return [Array] an `Array` representation of the {TimeWithOffset}.
2805
- def to_a; end
2806
-
2807
- # An overridden version of `Time#to_datetime` that, if there is an
2808
- # associated {TimezoneOffset}, returns a {DateTimeWithOffset} with that
2809
- # offset.
2810
- #
2811
- # @return [DateTime] if there is an associated {TimezoneOffset}, a
2812
- # {DateTimeWithOffset} representation of this {TimeWithOffset}, otherwise
2813
- # a `Time` representation.
2814
- def to_datetime; end
2815
-
2816
- # An overridden version of `Time#utc` that clears the associated
2817
- # {TimezoneOffset}.
2818
- #
2819
- # @return [TimeWithOffset] `self`.
2820
- def utc; end
2821
-
2822
- # An overridden version of `Time#zone` that, if there is an associated
2823
- # {TimezoneOffset}, returns the {TimezoneOffset#abbreviation abbreviation}
2824
- # of that offset.
2825
- #
2826
- # @return [String] the {TimezoneOffset#abbreviation abbreviation} of the
2827
- # associated {TimezoneOffset}, or the result from `Time#zone` if there is
2828
- # no such offset.
2829
- def zone; end
2830
-
2831
- protected
2832
-
2833
- # Clears the associated {TimezoneOffset}.
2834
- #
2835
- # @return [TimeWithOffset] `self`.
2836
- def clear_timezone_offset; end
2837
- end
2838
-
2839
- # A time represented as an `Integer` number of seconds since 1970-01-01
2840
- # 00:00:00 UTC (ignoring leap seconds and using the proleptic Gregorian
2841
- # calendar), the fraction through the second (sub_second as a `Rational`) and
2842
- # an optional UTC offset. Like Ruby's `Time` class, {Timestamp} can
2843
- # distinguish between a local time with a zero offset and a time specified
2844
- # explicitly as UTC.
2845
- class TZInfo::Timestamp
2846
- include ::Comparable
2847
-
2848
- # Initializes a new {Timestamp}.
2849
- #
2850
- # @param value [Integer] the number of seconds since 1970-01-01 00:00:00 UTC
2851
- # ignoring leap seconds.
2852
- # @param utc_offset [Object] either `nil` for a {Timestamp} without a
2853
- # specified offset, an offset from UTC specified as an `Integer` number of
2854
- # seconds or the `Symbol` `:utc`).
2855
- # @param sub_second [Numeric] the fractional part of the second as either a
2856
- # `Rational` that is greater than or equal to 0 and less than 1, or
2857
- # the `Integer` 0.
2858
- # @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer` and
2859
- # not the `Symbol` `:utc`.
2860
- # @raise [ArgumentError] if `sub_second` is not a `Rational`, or the
2861
- # `Integer` 0.
2862
- # @raise [ArgumentError] if `value` is not an `Integer`.
2863
- # @raise [RangeError] if `sub_second` is a `Rational` but that is less
2864
- # than 0 or greater than or equal to 1.
2865
- # @return [Timestamp] a new instance of Timestamp
2866
- def initialize(value, sub_second = T.unsafe(nil), utc_offset = T.unsafe(nil)); end
2867
-
2868
- # Compares this {Timestamp} with another.
2869
- #
2870
- # {Timestamp} instances without a defined UTC offset are not comparable with
2871
- # {Timestamp} instances that have a defined UTC offset.
2872
- #
2873
- # @param t [Timestamp] the {Timestamp} to compare this instance with.
2874
- # @return [Integer] -1, 0 or 1 depending if this instance is earlier, equal
2875
- # or later than `t` respectively. Returns `nil` when comparing a
2876
- # {Timestamp} that does not have a defined UTC offset with a {Timestamp}
2877
- # that does have a defined UTC offset. Returns `nil` if `t` is not a
2878
- # {Timestamp}.
2879
- def <=>(t); end
2880
-
2881
- # Adds a number of seconds to the {Timestamp} value, setting the UTC offset
2882
- # of the result.
2883
- #
2884
- # @param seconds [Integer] the number of seconds to be added.
2885
- # @param utc_offset [Object] either `nil` for a {Timestamp} without a
2886
- # specified offset, an offset from UTC specified as an `Integer` number of
2887
- # seconds or the `Symbol` `:utc`).
2888
- # @raise [ArgumentError] if `seconds` is not an `Integer`.
2889
- # @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer` and
2890
- # not the `Symbol` `:utc`.
2891
- # @return [Timestamp] the result of adding `seconds` to the
2892
- # {Timestamp} value as a new {Timestamp} instance with the chosen
2893
- # `utc_offset`.
2894
- def add_and_set_utc_offset(seconds, utc_offset); end
2895
-
2896
- def eql?(_arg0); end
2897
-
2898
- # @return [Integer] a hash based on the value, sub-second and whether there
2899
- # is a defined UTC offset.
2900
- def hash; end
2901
-
2902
- # @return [String] the internal object state as a programmer-readable
2903
- # `String`.
2904
- def inspect; end
2905
-
2906
- # Formats this {Timestamp} according to the directives in the given format
2907
- # string.
2908
- #
2909
- # @param format [String] the format string. Please refer to `Time#strftime`
2910
- # for a list of supported format directives.
2911
- # @raise [ArgumentError] if `format` is not specified.
2912
- # @return [String] the formatted {Timestamp}.
2913
- def strftime(format); end
2914
-
2915
- # @return [Numeric] the fraction of a second elapsed since timestamp as
2916
- # either a `Rational` or the `Integer` 0. Always greater than or equal to
2917
- # 0 and less than 1.
2918
- def sub_second; end
2919
-
2920
- # Converts this {Timestamp} to a Gregorian `DateTime`.
2921
- #
2922
- # @return [DateTime] a Gregorian `DateTime` representation of this
2923
- # {Timestamp}. If the UTC offset of this {Timestamp} is not specified, a
2924
- # UTC `DateTime` will be returned.
2925
- def to_datetime; end
2926
-
2927
- # Converts this {Timestamp} to an `Integer` number of seconds since
2928
- # 1970-01-01 00:00:00 UTC (ignoring leap seconds).
2929
- #
2930
- # @return [Integer] an `Integer` representation of this {Timestamp} (the
2931
- # number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds).
2932
- def to_i; end
2933
-
2934
- # @return [String] a `String` representation of this {Timestamp}.
2935
- def to_s; end
2936
-
2937
- # Converts this {Timestamp} to a `Time`.
2938
- #
2939
- # @return [Time] a `Time` representation of this {Timestamp}. If the UTC
2940
- # offset of this {Timestamp} is not specified, a UTC `Time` will be
2941
- # returned.
2942
- def to_time; end
2943
-
2944
- # @return [Timestamp] a UTC {Timestamp} equivalent to this instance. Returns
2945
- # `self` if {#utc? self.utc?} is `true`.
2946
- def utc; end
2947
-
2948
- # @return [Boolean] `true` if this {Timestamp} represents UTC, `false` if
2949
- # the {Timestamp} wasn't specified as UTC or `nil` if the {Timestamp} has
2950
- # no specified offset.
2951
- def utc?; end
2952
-
2953
- # @return [Integer] the offset from UTC in seconds or `nil` if the
2954
- # {Timestamp} doesn't have a specified offset.
2955
- def utc_offset; end
2956
-
2957
- # @return [Integer] the number of seconds since 1970-01-01 00:00:00 UTC
2958
- # ignoring leap seconds (i.e. each day is treated as if it were 86,400
2959
- # seconds long).
2960
- def value; end
2961
-
2962
- protected
2963
-
2964
- # Constructs a new instance of a `DateTime` or `DateTime`-like class with
2965
- # the same {value}, {sub_second} and {utc_offset} as this {Timestamp}.
2966
- #
2967
- # @param klass [Class] the class to instantiate.
2968
- # @private
2969
- def new_datetime(klass = T.unsafe(nil)); end
2970
-
2971
- # Creates a new instance of a `Time` or `Time`-like class matching the
2972
- # {value} and {sub_second} of this {Timestamp}, but not setting the offset.
2973
- #
2974
- # @param klass [Class] the class to instantiate.
2975
- # @private
2976
- def new_time(klass = T.unsafe(nil)); end
2977
-
2978
- private
2979
-
2980
- # Initializes a new {Timestamp} without validating the parameters. This
2981
- # method is used internally within {Timestamp} to avoid the overhead of
2982
- # checking parameters.
2983
- #
2984
- # @param value [Integer] the number of seconds since 1970-01-01 00:00:00 UTC
2985
- # ignoring leap seconds.
2986
- # @param sub_second [Numeric] the fractional part of the second as either a
2987
- # `Rational` that is greater than or equal to 0 and less than 1, or the
2988
- # `Integer` 0.
2989
- # @param utc_offset [Object] either `nil` for a {Timestamp} without a
2990
- # specified offset, an offset from UTC specified as an `Integer` number of
2991
- # seconds or the `Symbol` `:utc`).
2992
- def initialize!(value, sub_second = T.unsafe(nil), utc_offset = T.unsafe(nil)); end
2993
-
2994
- # Converts the {sub_second} value to a `String` suitable for appending to
2995
- # the `String` representation of a {Timestamp}.
2996
- #
2997
- # @return [String] a `String` representation of {sub_second}.
2998
- def sub_second_to_s; end
2999
-
3000
- # Converts the value and sub-seconds to a `String`, adding on the given
3001
- # offset.
3002
- #
3003
- # @param offset [Integer] the offset to add to the value.
3004
- # @return [String] the value and sub-seconds.
3005
- def value_and_sub_second_to_s(offset = T.unsafe(nil)); end
3006
-
3007
- class << self
3008
- # Returns a new {Timestamp} representing the (proleptic Gregorian
3009
- # calendar) date and time specified by the supplied parameters.
3010
- #
3011
- # If `utc_offset` is `nil`, `:utc` or 0, the date and time parameters will
3012
- # be interpreted as representing a UTC date and time. Otherwise the date
3013
- # and time parameters will be interpreted as a local date and time with
3014
- # the given offset.
3015
- #
3016
- # @param month [Integer] the month (1-12).
3017
- # @param day [Integer] the day of the month (1-31).
3018
- # @param hour [Integer] the hour (0-23).
3019
- # @param minute [Integer] the minute (0-59).
3020
- # @param second [Integer] the second (0-59).
3021
- # @param sub_second [Numeric] the fractional part of the second as either
3022
- # a `Rational` that is greater than or equal to 0 and less than 1, or
3023
- # the `Integer` 0.
3024
- # @param utc_offset [Object] either `nil` for a {Timestamp} without a
3025
- # specified offset, an offset from UTC specified as an `Integer` number
3026
- # of seconds or the `Symbol` `:utc`).
3027
- # @param year [Integer] the year.
3028
- # @raise [RangeError] if `sub_second` is a `Rational` but that is less
3029
- # than 0 or greater than or equal to 1.
3030
- # @raise [ArgumentError] if `sub_second` is not a `Rational`, or the
3031
- # `Integer` 0.
3032
- # @raise [ArgumentError] if either of `year`, `month`, `day`, `hour`,
3033
- # `minute`, or `second` is not an `Integer`.
3034
- # @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer`
3035
- # and not the `Symbol` `:utc`.
3036
- # @raise [RangeError] if `month` is not between 1 and 12.
3037
- # @raise [RangeError] if `day` is not between 1 and 31.
3038
- # @raise [RangeError] if `hour` is not between 0 and 23.
3039
- # @raise [RangeError] if `minute` is not between 0 and 59.
3040
- # @raise [RangeError] if `second` is not between 0 and 59.
3041
- # @return [Timestamp] a new {Timestamp} representing the specified
3042
- # (proleptic Gregorian calendar) date and time.
3043
- def create(year, month = T.unsafe(nil), day = T.unsafe(nil), hour = T.unsafe(nil), minute = T.unsafe(nil), second = T.unsafe(nil), sub_second = T.unsafe(nil), utc_offset = T.unsafe(nil)); end
3044
-
3045
- # When used without a block, returns a {Timestamp} representation of a
3046
- # given `Time`, `DateTime` or {Timestamp}.
3047
- #
3048
- # When called with a block, the {Timestamp} representation of `value` is
3049
- # passed to the block. The block must then return a {Timestamp}, which
3050
- # will be converted back to the type of the initial value. If the initial
3051
- # value was a {Timestamp}, the block result will be returned. If the
3052
- # initial value was a `DateTime`, a Gregorian `DateTime` will be returned.
3053
- #
3054
- # The UTC offset of `value` can either be preserved (the {Timestamp}
3055
- # representation will have the same UTC offset as `value`), ignored (the
3056
- # {Timestamp} representation will have no defined UTC offset), or treated
3057
- # as though it were UTC (the {Timestamp} representation will have a
3058
- # {utc_offset} of 0 and {utc?} will return `true`).
3059
- #
3060
- # @param value [Object] a `Time`, `DateTime` or {Timestamp}.
3061
- # @param offset [Symbol] either `:preserve` to preserve the offset of
3062
- # `value`, `:ignore` to ignore the offset of `value` and create a
3063
- # {Timestamp} with an unspecified offset, or `:treat_as_utc` to treat
3064
- # the offset of `value` as though it were UTC and create a UTC
3065
- # {Timestamp}.
3066
- # @raise [ArgumentError]
3067
- # @return [Object] if called without a block, the {Timestamp}
3068
- # representation of `value`, otherwise the result of the block,
3069
- # converted back to the type of `value`.
3070
- # @yield [timestamp] if a block is provided, the {Timestamp}
3071
- # representation is passed to the block.
3072
- # @yieldparam timestamp [Timestamp] the {Timestamp} representation of
3073
- # `value`.
3074
- # @yieldreturn [Timestamp] a {Timestamp} to be converted back to the type
3075
- # of `value`.
3076
- def for(value, offset = T.unsafe(nil)); end
3077
-
3078
- # Creates a new UTC {Timestamp}.
3079
- #
3080
- # @param value [Integer] the number of seconds since 1970-01-01 00:00:00
3081
- # UTC ignoring leap seconds.
3082
- # @param sub_second [Numeric] the fractional part of the second as either
3083
- # a `Rational` that is greater than or equal to 0 and less than 1, or
3084
- # the `Integer` 0.
3085
- # @raise [ArgumentError] if `value` is not an `Integer`.
3086
- # @raise [ArgumentError] if `sub_second` is not a `Rational`, or the
3087
- # `Integer` 0.
3088
- # @raise [RangeError] if `sub_second` is a `Rational` but that is less
3089
- # than 0 or greater than or equal to 1.
3090
- def utc(value, sub_second = T.unsafe(nil)); end
3091
-
3092
- private
3093
-
3094
- # Creates a {Timestamp} that represents a given `DateTime`, optionally
3095
- # ignoring the offset.
3096
- #
3097
- # @param datetime [DateTime] a `DateTime`.
3098
- # @param ignore_offset [Boolean] whether to ignore the offset of
3099
- # `datetime`.
3100
- # @param target_utc_offset [Object] if `ignore_offset` is `true`, the UTC
3101
- # offset of the result (`:utc`, `nil` or an `Integer`).
3102
- # @return [Timestamp] the {Timestamp} representation of `datetime`.
3103
- def for_datetime(datetime, ignore_offset, target_utc_offset); end
3104
-
3105
- # Creates a {Timestamp} that represents a given `Time`, optionally
3106
- # ignoring the offset.
3107
- #
3108
- # @param time [Time] a `Time`.
3109
- # @param ignore_offset [Boolean] whether to ignore the offset of `time`.
3110
- # @param target_utc_offset [Object] if `ignore_offset` is `true`, the UTC
3111
- # offset of the result (`:utc`, `nil` or an `Integer`).
3112
- # @return [Timestamp] the {Timestamp} representation of `time`.
3113
- def for_time(time, ignore_offset, target_utc_offset); end
3114
-
3115
- # Creates a {Timestamp} that represents a given `Time`-like object,
3116
- # optionally ignoring the offset (if the `time_like` responds to
3117
- # `utc_offset`).
3118
- #
3119
- # @param time_like [Object] a `Time`-like object.
3120
- # @param ignore_offset [Boolean] whether to ignore the offset of `time`.
3121
- # @param target_utc_offset [Object] if `ignore_offset` is `true`, the UTC
3122
- # offset of the result (`:utc`, `nil` or an `Integer`).
3123
- # @return [Timestamp] the {Timestamp} representation of `time_like`.
3124
- def for_time_like(time_like, ignore_offset, target_utc_offset); end
3125
-
3126
- # Returns a {Timestamp} that represents another {Timestamp}, optionally
3127
- # ignoring the offset. If the result would be identical to `value`, the
3128
- # same instance is returned. If the passed in value is an instance of a
3129
- # subclass of {Timestamp}, then a new {Timestamp} will always be returned.
3130
- #
3131
- # @param timestamp [Timestamp] a {Timestamp}.
3132
- # @param ignore_offset [Boolean] whether to ignore the offset of
3133
- # `timestamp`.
3134
- # @param target_utc_offset [Object] if `ignore_offset` is `true`, the UTC
3135
- # offset of the result (`:utc`, `nil` or an `Integer`).
3136
- # @return [Timestamp] a [Timestamp] representation of `timestamp`.
3137
- def for_timestamp(timestamp, ignore_offset, target_utc_offset); end
3138
-
3139
- # Determines if an object is like a `Time` (for the purposes of converting
3140
- # to a {Timestamp} with {for}), responding to `to_i` and `subsec`.
3141
- #
3142
- # @param value [Object] an object to test.
3143
- # @return [Boolean] `true` if the object is `Time`-like, otherwise
3144
- # `false`.
3145
- def is_time_like?(value); end
3146
-
3147
- # Constructs a new instance of `self` (i.e. {Timestamp} or a subclass of
3148
- # {Timestamp}) without validating the parameters. This method is used
3149
- # internally within {Timestamp} to avoid the overhead of checking
3150
- # parameters.
3151
- #
3152
- # @param value [Integer] the number of seconds since 1970-01-01 00:00:00
3153
- # UTC ignoring leap seconds.
3154
- # @param sub_second [Numeric] the fractional part of the second as either
3155
- # a `Rational` that is greater than or equal to 0 and less than 1, or
3156
- # the `Integer` 0.
3157
- # @param utc_offset [Object] either `nil` for a {Timestamp} without a
3158
- # specified offset, an offset from UTC specified as an `Integer` number
3159
- # of seconds or the `Symbol` `:utc`).
3160
- # @return [Timestamp] a new instance of `self`.
3161
- def new!(value, sub_second = T.unsafe(nil), utc_offset = T.unsafe(nil)); end
3162
- end
3163
- end
3164
-
3165
- # The Unix epoch (1970-01-01 00:00:00 UTC) as a chronological Julian day
3166
- # number.
3167
- TZInfo::Timestamp::JD_EPOCH = T.let(T.unsafe(nil), Integer)
3168
-
3169
- # A subclass of {Timestamp} used to represent local times.
3170
- # {TimestampWithOffset} holds a reference to the related {TimezoneOffset} and
3171
- # overrides various methods to return results appropriate for the
3172
- # {TimezoneOffset}. Certain operations will clear the associated
3173
- # {TimezoneOffset} (if the {TimezoneOffset} would not necessarily be valid for
3174
- # the result). Once the {TimezoneOffset} has been cleared,
3175
- # {TimestampWithOffset} behaves identically to {Timestamp}.
3176
- class TZInfo::TimestampWithOffset < ::TZInfo::Timestamp
3177
- include ::TZInfo::WithOffset
3178
-
3179
- # Sets the associated {TimezoneOffset} of this {TimestampWithOffset}.
3180
- #
3181
- # @param timezone_offset [TimezoneOffset] a {TimezoneOffset} valid at the time
3182
- # and for the offset of this {TimestampWithOffset}.
3183
- # @raise [ArgumentError] if `timezone_offset` is `nil`.
3184
- # @raise [ArgumentError] if {utc? self.utc?} is `true`.
3185
- # @raise [ArgumentError] if `timezone_offset.observed_utc_offset` does not equal
3186
- # `self.utc_offset`.
3187
- # @return [TimestampWithOffset] `self`.
3188
- def set_timezone_offset(timezone_offset); end
3189
-
3190
- # @return [TimezoneOffset] the {TimezoneOffset} associated with this
3191
- # instance.
3192
- def timezone_offset; end
3193
-
3194
- # An overridden version of {Timestamp#to_datetime}, if there is an
3195
- # associated {TimezoneOffset}, returns a {DateTimeWithOffset} with that
3196
- # offset.
3197
- #
3198
- # @return [DateTime] if there is an associated {TimezoneOffset}, a
3199
- # {DateTimeWithOffset} representation of this {TimestampWithOffset},
3200
- # otherwise a `DateTime` representation.
3201
- def to_datetime; end
3202
-
3203
- # An overridden version of {Timestamp#to_time} that, if there is an
3204
- # associated {TimezoneOffset}, returns a {TimeWithOffset} with that offset.
3205
- #
3206
- # @return [Time] if there is an associated {TimezoneOffset}, a
3207
- # {TimeWithOffset} representation of this {TimestampWithOffset}, otherwise
3208
- # a `Time` representation.
3209
- def to_time; end
3210
-
3211
- class << self
3212
- # Creates a new {TimestampWithOffset} from a given {Timestamp} and
3213
- # {TimezoneOffset}.
3214
- #
3215
- # time of `timestamp`.
3216
- #
3217
- # @param timestamp [Timestamp] a {Timestamp}.
3218
- # @param timezone_offset [TimezoneOffset] a {TimezoneOffset} valid at the
3219
- # @raise [ArgumentError] if `timestamp` or `timezone_offset` is `nil`.
3220
- # @return [TimestampWithOffset] a {TimestampWithOffset} that has the same
3221
- # {value value} and {sub_second sub_second} as the `timestamp` parameter,
3222
- # a {utc_offset utc_offset} equal to the
3223
- # {TimezoneOffset#observed_utc_offset observed_utc_offset} of the
3224
- # `timezone_offset` parameter and {timezone_offset timezone_offset} set to
3225
- # the `timezone_offset` parameter.
3226
- def set_timezone_offset(timestamp, timezone_offset); end
3227
- end
3228
- end
3229
-
3230
- # The {Timezone} class represents a time zone. It provides a factory method,
3231
- # {get}, to retrieve {Timezone} instances by their identifier.
3232
- #
3233
- # The {Timezone#to_local} method can be used to convert `Time` and `DateTime`
3234
- # instances to the local time for the zone. For example:
3235
- #
3236
- # tz = TZInfo::Timezone.get('America/New_York')
3237
- # local_time = tz.to_local(Time.utc(2005,8,29,15,35,0))
3238
- # local_datetime = tz.to_local(DateTime.new(2005,8,29,15,35,0))
3239
- #
3240
- # Local `Time` and `DateTime` instances returned by `Timezone` have the
3241
- # correct local offset.
3242
- #
3243
- # The {Timezone#local_to_utc} method can by used to convert local `Time` and
3244
- # `DateTime` instances to UTC. {Timezone#local_to_utc} ignores the UTC offset
3245
- # of the supplied value and treats if it is a local time for the zone. For
3246
- # example:
3247
- #
3248
- # tz = TZInfo::Timezone.get('America/New_York')
3249
- # utc_time = tz.local_to_utc(Time.new(2005,8,29,11,35,0))
3250
- # utc_datetime = tz.local_to_utc(DateTime.new(2005,8,29,11,35,0))
3251
- #
3252
- # Each time zone is treated as sequence of periods of time ({TimezonePeriod})
3253
- # that observe the same offset ({TimezoneOffset}). Transitions
3254
- # ({TimezoneTransition}) denote the end of one period and the start of the
3255
- # next. The {Timezone} class has methods that allow the periods, offsets and
3256
- # transitions of a time zone to be interrogated.
3257
- #
3258
- # All methods that take `Time` objects as parameters can be used with
3259
- # arbitrary `Time`-like objects that respond to both `to_i` and `subsec` and
3260
- # optionally `utc_offset`.
3261
- #
3262
- # The {Timezone} class is thread-safe. It is safe to use class and instance
3263
- # methods of {Timezone} in concurrently executing threads. Instances of
3264
- # {Timezone} can be shared across thread boundaries.
3265
- #
3266
- # The IANA Time Zone Database maintainers recommend that time zone identifiers
3267
- # are not made visible to end-users (see [Names of
3268
- # timezones](https://data.iana.org/time-zones/theory.html#naming)). The
3269
- # {Country} class can be used to obtain lists of time zones by country,
3270
- # including user-friendly descriptions and approximate locations.
3271
- #
3272
- # @abstract The {get} method returns an instance of either {DataTimezone} or
3273
- # {LinkedTimezone}. The {get_proxy} method and other methods returning
3274
- # collections of time zones return instances of {TimezoneProxy}.
3275
- class TZInfo::Timezone
3276
- include ::Comparable
3277
-
3278
- # Compares this {Timezone} with another based on the {identifier}.
3279
- #
3280
- # @param tz [Object] an `Object` to compare this {Timezone} with.
3281
- # @return [Integer] -1 if `tz` is less than `self`, 0 if `tz` is equal to
3282
- # `self` and +1 if `tz` is greater than `self`, or `nil` if `tz` is not an
3283
- # instance of {Timezone}.
3284
- def <=>(tz); end
3285
-
3286
- # Matches `regexp` against the {identifier} of this {Timezone}.
3287
- #
3288
- # @param regexp [Regexp] a `Regexp` to match against the {identifier} of
3289
- # this {Timezone}.
3290
- # @return [Integer] the position the match starts, or `nil` if there is no
3291
- # match.
3292
- def =~(regexp); end
3293
-
3294
- # Returns a serialized representation of this {Timezone}. This method is
3295
- # called when using `Marshal.dump` with an instance of {Timezone}.
3296
- #
3297
- # @param limit [Integer] the maximum depth to dump - ignored.
3298
- # @return [String] a serialized representation of this {Timezone}.
3299
- def _dump(limit); end
3300
-
3301
- # @param time [Object] a `Time`, `DateTime` or `Timestamp`.
3302
- # @raise [ArgumentError] if `time` is `nil`.
3303
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified UTC
3304
- # offset.
3305
- # @return [String] the abbreviation of this {Timezone} at the given time.
3306
- def abbr(time = T.unsafe(nil)); end
3307
-
3308
- # @param time [Object] a `Time`, `DateTime` or `Timestamp`.
3309
- # @raise [ArgumentError] if `time` is `nil`.
3310
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified UTC
3311
- # offset.
3312
- # @return [String] the abbreviation of this {Timezone} at the given time.
3313
- def abbreviation(time = T.unsafe(nil)); end
3314
-
3315
- # Returns the base offset from UTC in seconds at the given time. This does
3316
- # not include any adjustment made for daylight savings time and will
3317
- # typically remain constant throughout the year.
3318
- #
3319
- # To obtain the observed offset from UTC, including the effect of daylight
3320
- # savings time, use {observed_utc_offset} instead.
3321
- #
3322
- # If you require accurate {base_utc_offset} values, you should install the
3323
- # tzinfo-data gem and set {DataSources::RubyDataSource} as the {DataSource}.
3324
- # When using {DataSources::ZoneinfoDataSource}, the value of
3325
- # {base_utc_offset} has to be derived from changes to the observed UTC
3326
- # offset and DST status since it is not included in zoneinfo files.
3327
- #
3328
- # @param time [Object] a `Time`, `DateTime` or `Timestamp`.
3329
- # @raise [ArgumentError] if `time` is `nil`.
3330
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified UTC
3331
- # offset.
3332
- # @return [Integer] the base offset from UTC in seconds at the given time.
3333
- def base_utc_offset(time = T.unsafe(nil)); end
3334
-
3335
- # Returns the canonical identifier of this time zone.
3336
- #
3337
- # This is a shortcut for calling `canonical_zone.identifier`. Please refer
3338
- # to the {canonical_zone} documentation for further information.
3339
- #
3340
- # @return [String] the canonical identifier of this time zone.
3341
- def canonical_identifier; end
3342
-
3343
- # Returns the canonical {Timezone} instance for this {Timezone}.
3344
- #
3345
- # The IANA Time Zone database contains two types of definition: Zones and
3346
- # Links. Zones are defined by rules that set out when transitions occur.
3347
- # Links are just references to fully defined Zone, creating an alias for
3348
- # that Zone.
3349
- #
3350
- # Links are commonly used where a time zone has been renamed in a release of
3351
- # the Time Zone database. For example, the US/Eastern Zone was renamed as
3352
- # America/New_York. A US/Eastern Link was added in its place, linking to
3353
- # (and creating an alias for) America/New_York.
3354
- #
3355
- # Links are also used for time zones that are currently identical to a full
3356
- # Zone, but that are administered separately. For example, Europe/Vatican is
3357
- # a Link to (and alias for) Europe/Rome.
3358
- #
3359
- # For a full Zone (implemented by {DataTimezone}), {canonical_zone} returns
3360
- # self.
3361
- #
3362
- # For a Link (implemented by {LinkedTimezone}), {canonical_zone} returns a
3363
- # {Timezone} instance representing the full Zone that the link targets.
3364
- #
3365
- # TZInfo can be used with different data sources (see the documentation for
3366
- # {TZInfo::DataSource}). Some DataSource implementations may not support
3367
- # distinguishing between full Zones and Links and will treat all time zones
3368
- # as full Zones. In this case, {canonical_zone} will always return `self`.
3369
- #
3370
- # There are two built-in DataSource implementations.
3371
- # {DataSources::RubyDataSource} (which will be used if the tzinfo-data gem
3372
- # is available) supports Link zones. {DataSources::ZoneinfoDataSource}
3373
- # returns Link zones as if they were full Zones. If the {canonical_zone} or
3374
- # {canonical_identifier} methods are needed, the tzinfo-data gem should be
3375
- # installed.
3376
- #
3377
- # The {TZInfo::DataSource.get} method can be used to check which DataSource
3378
- # implementation is being used.
3379
- #
3380
- # @return [Timezone] the canonical {Timezone} instance for this {Timezone}.
3381
- def canonical_zone; end
3382
-
3383
- # @return [TimezonePeriod] the current {TimezonePeriod} for the time zone.
3384
- def current_period; end
3385
-
3386
- # Returns the current local time and {TimezonePeriod} for the time zone as
3387
- # an `Array`. The first element is the time as a {TimeWithOffset}. The
3388
- # second element is the period.
3389
- #
3390
- # @return [Array] an `Array` containing the current {TimeWithOffset} for the
3391
- # time zone as the first element and the current {TimezonePeriod} for the
3392
- # time zone as the second element.
3393
- def current_period_and_time; end
3394
-
3395
- # Returns the current local time and {TimezonePeriod} for the time zone as
3396
- # an `Array`. The first element is the time as a {TimeWithOffset}. The
3397
- # second element is the period.
3398
- #
3399
- # @return [Array] an `Array` containing the current {TimeWithOffset} for the
3400
- # time zone as the first element and the current {TimezonePeriod} for the
3401
- # time zone as the second element.
3402
- def current_time_and_period; end
3403
-
3404
- # @param time [Object] a `Time`, `DateTime` or `Timestamp`.
3405
- # @raise [ArgumentError] if `time` is `nil`.
3406
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified UTC
3407
- # offset.
3408
- # @return [Boolean] whether daylight savings time is in effect at the given
3409
- # time.
3410
- def dst?(time = T.unsafe(nil)); end
3411
-
3412
- # @param tz [Object] an `Object` to compare this {Timezone} with.
3413
- # @return [Boolean] `true` if `tz` is an instance of {Timezone} and has the
3414
- # same {identifier} as `self`, otherwise `false`.
3415
- def eql?(tz); end
3416
-
3417
- # Returns {identifier}, modified to make it more readable. Set
3418
- # `skip_first_part` to omit the first part of the identifier (typically a
3419
- # region name) where there is more than one part.
3420
- #
3421
- # For example:
3422
- #
3423
- # TZInfo::Timezone.get('Europe/Paris').friendly_identifier(false) #=> "Europe - Paris"
3424
- # TZInfo::Timezone.get('Europe/Paris').friendly_identifier(true) #=> "Paris"
3425
- # TZInfo::Timezone.get('America/Indiana/Knox').friendly_identifier(false) #=> "America - Knox, Indiana"
3426
- # TZInfo::Timezone.get('America/Indiana/Knox').friendly_identifier(true) #=> "Knox, Indiana"
3427
- #
3428
- # @param skip_first_part [Boolean] whether the first part of the identifier
3429
- # (typically a region name) should be omitted.
3430
- # @return [String] the modified identifier.
3431
- def friendly_identifier(skip_first_part = T.unsafe(nil)); end
3432
-
3433
- # @return [Integer] a hash based on the {identifier}.
3434
- def hash; end
3435
-
3436
- # @return [String] the identifier of the time zone, for example,
3437
- # `"Europe/Paris"`.
3438
- def identifier; end
3439
-
3440
- # @return [String] the internal object state as a programmer-readable
3441
- # `String`.
3442
- def inspect; end
3443
-
3444
- # Creates a `DateTime` object based on the given (Gregorian calendar) date
3445
- # and time parameters. The parameters are interpreted as a local time in the
3446
- # time zone. The result has the appropriate `offset` and
3447
- # {DateTimeWithOffset#timezone_offset timezone_offset}.
3448
- #
3449
- # _Warning:_ There are time values that are not valid as local times in a
3450
- # time zone (for example, during the transition from standard time to
3451
- # daylight savings time). There are also time values that are ambiguous,
3452
- # occurring more than once with different offsets to UTC (for example,
3453
- # during the transition from daylight savings time to standard time).
3454
- #
3455
- # In the first case (an invalid local time), a {PeriodNotFound} exception
3456
- # will be raised.
3457
- #
3458
- # In the second case (more than one occurrence), an {AmbiguousTime}
3459
- # exception will be raised unless the optional `dst` parameter or block
3460
- # handles the ambiguity.
3461
- #
3462
- # If the ambiguity is due to a transition from daylight savings time to
3463
- # standard time, the `dst` parameter can be used to select whether the
3464
- # daylight savings time or local time is used. For example, the following
3465
- # code would raise an {AmbiguousTime} exception:
3466
- #
3467
- # tz = TZInfo::Timezone.get('America/New_York')
3468
- # tz.local_datetime(2004,10,31,1,30,0,0)
3469
- #
3470
- # Specifying `dst = true` would return a `Time` with a UTC offset of -4
3471
- # hours and abbreviation EDT (Eastern Daylight Time). Specifying `dst =
3472
- # false` would return a `Time` with a UTC offset of -5 hours and
3473
- # abbreviation EST (Eastern Standard Time).
3474
- #
3475
- # The `dst` parameter will not be able to resolve an ambiguity resulting
3476
- # from the clocks being set back without changing from daylight savings time
3477
- # to standard time. In this case, if a block is specified, it will be called
3478
- # to resolve the ambiguity. The block must take a single parameter - an
3479
- # `Array` of {TimezonePeriod}s that need to be resolved. The block can
3480
- # select and return a single {TimezonePeriod} or return `nil` or an empty
3481
- # `Array` to cause an {AmbiguousTime} exception to be raised.
3482
- #
3483
- # The default value of the `dst` parameter can be specified using
3484
- # {Timezone.default_dst=}.
3485
- #
3486
- # values, interpreted as a local time in the time zone.
3487
- #
3488
- # @param hour [Integer] the hour (0-23).
3489
- # @param minute [Integer] the minute (0-59).
3490
- # @param second [Integer] the second (0-59).
3491
- # @param sub_second [Numeric] the fractional part of the second as either
3492
- # a `Rational` that is greater than or equal to 0 and less than 1, or
3493
- # the `Integer` 0.
3494
- # @param dst [Boolean] whether to resolve ambiguous local times by always
3495
- # selecting the period observing daylight savings time (`true`), always
3496
- # selecting the period observing standard time (`false`), or leaving the
3497
- # ambiguity unresolved (`nil`).
3498
- # @param month [Integer] the month (1-12).
3499
- # @param day [Integer] the day of the month (1-31).
3500
- # @param year [Integer] the year.
3501
- # @raise [RangeError] if `sub_second` is a `Rational` but that is less
3502
- # than 0 or greater than or equal to 1.
3503
- # @raise [PeriodNotFound] if the date and time parameters do not specify a
3504
- # valid local time in the time zone.
3505
- # @raise [AmbiguousTime] if the date and time parameters are ambiguous for
3506
- # the time zone and the `dst` parameter or block did not resolve the
3507
- # ambiguity.
3508
- # @raise [RangeError] if `month` is not between 1 and 12.
3509
- # @raise [ArgumentError] if either of `year`, `month`, `day`, `hour`,
3510
- # `minute`, or `second` is not an `Integer`.
3511
- # @raise [ArgumentError] if `sub_second` is not a `Rational`, or the
3512
- # `Integer` 0.
3513
- # @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer`
3514
- # and not the `Symbol` `:utc`.
3515
- # @raise [RangeError] if `day` is not between 1 and 31.
3516
- # @raise [RangeError] if `hour` is not between 0 and 23.
3517
- # @raise [RangeError] if `minute` is not between 0 and 59.
3518
- # @raise [RangeError] if `second` is not between 0 and 59.
3519
- # @return [DateTimeWithOffset] a new `DateTime` object based on the given
3520
- # @yield [periods] if the `dst` parameter did not resolve an ambiguity, an
3521
- # optional block is yielded to.
3522
- # @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all
3523
- # the {TimezonePeriod}s that still match `local_time` after applying the
3524
- # `dst` parameter.
3525
- # @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod}
3526
- # or an `Array` containing a chosen {TimezonePeriod}; to leave the
3527
- # ambiguity unresolved: an empty `Array`, an `Array` containing more than
3528
- # one {TimezonePeriod}, or `nil`.
3529
- def local_datetime(year, month = T.unsafe(nil), day = T.unsafe(nil), hour = T.unsafe(nil), minute = T.unsafe(nil), second = T.unsafe(nil), sub_second = T.unsafe(nil), dst = T.unsafe(nil), &block); end
3530
-
3531
- # Creates a `Time` object based on the given (Gregorian calendar) date and
3532
- # time parameters. The parameters are interpreted as a local time in the
3533
- # time zone. The result has the appropriate `utc_offset`, `zone` and
3534
- # {TimeWithOffset#timezone_offset timezone_offset}.
3535
- #
3536
- # _Warning:_ There are time values that are not valid as local times in a
3537
- # time zone (for example, during the transition from standard time to
3538
- # daylight savings time). There are also time values that are ambiguous,
3539
- # occurring more than once with different offsets to UTC (for example,
3540
- # during the transition from daylight savings time to standard time).
3541
- #
3542
- # In the first case (an invalid local time), a {PeriodNotFound} exception
3543
- # will be raised.
3544
- #
3545
- # In the second case (more than one occurrence), an {AmbiguousTime}
3546
- # exception will be raised unless the optional `dst` parameter or block
3547
- # handles the ambiguity.
3548
- #
3549
- # If the ambiguity is due to a transition from daylight savings time to
3550
- # standard time, the `dst` parameter can be used to select whether the
3551
- # daylight savings time or local time is used. For example, the following
3552
- # code would raise an {AmbiguousTime} exception:
3553
- #
3554
- # tz = TZInfo::Timezone.get('America/New_York')
3555
- # tz.local_time(2004,10,31,1,30,0,0)
3556
- #
3557
- # Specifying `dst = true` would return a `Time` with a UTC offset of -4
3558
- # hours and abbreviation EDT (Eastern Daylight Time). Specifying `dst =
3559
- # false` would return a `Time` with a UTC offset of -5 hours and
3560
- # abbreviation EST (Eastern Standard Time).
3561
- #
3562
- # The `dst` parameter will not be able to resolve an ambiguity resulting
3563
- # from the clocks being set back without changing from daylight savings time
3564
- # to standard time. In this case, if a block is specified, it will be called
3565
- # to resolve the ambiguity. The block must take a single parameter - an
3566
- # `Array` of {TimezonePeriod}s that need to be resolved. The block can
3567
- # select and return a single {TimezonePeriod} or return `nil` or an empty
3568
- # `Array` to cause an {AmbiguousTime} exception to be raised.
3569
- #
3570
- # The default value of the `dst` parameter can be specified using
3571
- # {Timezone.default_dst=}.
3572
- #
3573
- # @param hour [Integer] the hour (0-23).
3574
- # @param minute [Integer] the minute (0-59).
3575
- # @param second [Integer] the second (0-59).
3576
- # @param sub_second [Numeric] the fractional part of the second as either
3577
- # a `Rational` that is greater than or equal to 0 and less than 1, or
3578
- # the `Integer` 0.
3579
- # @param dst [Boolean] whether to resolve ambiguous local times by always
3580
- # selecting the period observing daylight savings time (`true`), always
3581
- # selecting the period observing standard time (`false`), or leaving the
3582
- # ambiguity unresolved (`nil`).
3583
- # @param month [Integer] the month (1-12).
3584
- # @param day [Integer] the day of the month (1-31).
3585
- # @param year [Integer] the year.
3586
- # @raise [RangeError] if `sub_second` is a `Rational` but that is less
3587
- # than 0 or greater than or equal to 1.
3588
- # @raise [PeriodNotFound] if the date and time parameters do not specify a
3589
- # valid local time in the time zone.
3590
- # @raise [AmbiguousTime] if the date and time parameters are ambiguous for
3591
- # the time zone and the `dst` parameter or block did not resolve the
3592
- # ambiguity.
3593
- # @raise [RangeError] if `month` is not between 1 and 12.
3594
- # @raise [ArgumentError] if either of `year`, `month`, `day`, `hour`,
3595
- # `minute`, or `second` is not an `Integer`.
3596
- # @raise [ArgumentError] if `sub_second` is not a `Rational`, or the
3597
- # `Integer` 0.
3598
- # @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer`
3599
- # and not the `Symbol` `:utc`.
3600
- # @raise [RangeError] if `day` is not between 1 and 31.
3601
- # @raise [RangeError] if `hour` is not between 0 and 23.
3602
- # @raise [RangeError] if `minute` is not between 0 and 59.
3603
- # @raise [RangeError] if `second` is not between 0 and 59.
3604
- # @return [TimeWithOffset] a new `Time` object based on the given values,
3605
- # interpreted as a local time in the time zone.
3606
- # @yield [periods] if the `dst` parameter did not resolve an ambiguity, an
3607
- # optional block is yielded to.
3608
- # @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all
3609
- # the {TimezonePeriod}s that still match `local_time` after applying the
3610
- # `dst` parameter.
3611
- # @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod}
3612
- # or an `Array` containing a chosen {TimezonePeriod}; to leave the
3613
- # ambiguity unresolved: an empty `Array`, an `Array` containing more than
3614
- # one {TimezonePeriod}, or `nil`.
3615
- def local_time(year, month = T.unsafe(nil), day = T.unsafe(nil), hour = T.unsafe(nil), minute = T.unsafe(nil), second = T.unsafe(nil), sub_second = T.unsafe(nil), dst = T.unsafe(nil), &block); end
3616
-
3617
- # Creates a {Timestamp} object based on the given (Gregorian calendar) date
3618
- # and time parameters. The parameters are interpreted as a local time in the
3619
- # time zone. The result has the appropriate {Timestamp#utc_offset
3620
- # utc_offset} and {TimestampWithOffset#timezone_offset timezone_offset}.
3621
- #
3622
- # _Warning:_ There are time values that are not valid as local times in a
3623
- # time zone (for example, during the transition from standard time to
3624
- # daylight savings time). There are also time values that are ambiguous,
3625
- # occurring more than once with different offsets to UTC (for example,
3626
- # during the transition from daylight savings time to standard time).
3627
- #
3628
- # In the first case (an invalid local time), a {PeriodNotFound} exception
3629
- # will be raised.
3630
- #
3631
- # In the second case (more than one occurrence), an {AmbiguousTime}
3632
- # exception will be raised unless the optional `dst` parameter or block
3633
- # handles the ambiguity.
3634
- #
3635
- # If the ambiguity is due to a transition from daylight savings time to
3636
- # standard time, the `dst` parameter can be used to select whether the
3637
- # daylight savings time or local time is used. For example, the following
3638
- # code would raise an {AmbiguousTime} exception:
3639
- #
3640
- # tz = TZInfo::Timezone.get('America/New_York')
3641
- # tz.local_timestamp(2004,10,31,1,30,0,0)
3642
- #
3643
- # Specifying `dst = true` would return a `Time` with a UTC offset of -4
3644
- # hours and abbreviation EDT (Eastern Daylight Time). Specifying `dst =
3645
- # false` would return a `Time` with a UTC offset of -5 hours and
3646
- # abbreviation EST (Eastern Standard Time).
3647
- #
3648
- # The `dst` parameter will not be able to resolve an ambiguity resulting
3649
- # from the clocks being set back without changing from daylight savings time
3650
- # to standard time. In this case, if a block is specified, it will be called
3651
- # to resolve the ambiguity. The block must take a single parameter - an
3652
- # `Array` of {TimezonePeriod}s that need to be resolved. The block can
3653
- # select and return a single {TimezonePeriod} or return `nil` or an empty
3654
- # `Array` to cause an {AmbiguousTime} exception to be raised.
3655
- #
3656
- # The default value of the `dst` parameter can be specified using
3657
- # {Timezone.default_dst=}.
3658
- #
3659
- # @param hour [Integer] the hour (0-23).
3660
- # @param minute [Integer] the minute (0-59).
3661
- # @param second [Integer] the second (0-59).
3662
- # @param sub_second [Numeric] the fractional part of the second as either
3663
- # a `Rational` that is greater than or equal to 0 and less than 1, or
3664
- # the `Integer` 0.
3665
- # @param dst [Boolean] whether to resolve ambiguous local times by always
3666
- # selecting the period observing daylight savings time (`true`), always
3667
- # selecting the period observing standard time (`false`), or leaving the
3668
- # ambiguity unresolved (`nil`).
3669
- # @param month [Integer] the month (1-12).
3670
- # @param day [Integer] the day of the month (1-31).
3671
- # @param year [Integer] the year.
3672
- # @raise [RangeError] if `sub_second` is a `Rational` but that is less
3673
- # than 0 or greater than or equal to 1.
3674
- # @raise [PeriodNotFound] if the date and time parameters do not specify a
3675
- # valid local time in the time zone.
3676
- # @raise [AmbiguousTime] if the date and time parameters are ambiguous for
3677
- # the time zone and the `dst` parameter or block did not resolve the
3678
- # ambiguity.
3679
- # @raise [RangeError] if `month` is not between 1 and 12.
3680
- # @raise [ArgumentError] if either of `year`, `month`, `day`, `hour`,
3681
- # `minute`, or `second` is not an `Integer`.
3682
- # @raise [ArgumentError] if `sub_second` is not a `Rational`, or the
3683
- # `Integer` 0.
3684
- # @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer`
3685
- # and not the `Symbol` `:utc`.
3686
- # @raise [RangeError] if `day` is not between 1 and 31.
3687
- # @raise [RangeError] if `hour` is not between 0 and 23.
3688
- # @raise [RangeError] if `minute` is not between 0 and 59.
3689
- # @raise [RangeError] if `second` is not between 0 and 59.
3690
- # @return [TimestampWithOffset] a new {Timestamp} object based on the given
3691
- # values, interpreted as a local time in the time zone.
3692
- # @yield [periods] if the `dst` parameter did not resolve an ambiguity, an
3693
- # optional block is yielded to.
3694
- # @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all
3695
- # the {TimezonePeriod}s that still match `local_time` after applying the
3696
- # `dst` parameter.
3697
- # @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod}
3698
- # or an `Array` containing a chosen {TimezonePeriod}; to leave the
3699
- # ambiguity unresolved: an empty `Array`, an `Array` containing more than
3700
- # one {TimezonePeriod}, or `nil`.
3701
- def local_timestamp(year, month = T.unsafe(nil), day = T.unsafe(nil), hour = T.unsafe(nil), minute = T.unsafe(nil), second = T.unsafe(nil), sub_second = T.unsafe(nil), dst = T.unsafe(nil), &block); end
3702
-
3703
- # Converts a local time for the time zone to UTC.
3704
- #
3705
- # The result will either be a `Time`, `DateTime` or {Timestamp} according to
3706
- # the type of the `local_time` parameter.
3707
- #
3708
- # The UTC offset of the `local_time` parameter is ignored (it is treated as
3709
- # a time in the time zone represented by `self`).
3710
- #
3711
- # _Warning:_ There are local times that have no equivalent UTC times (for
3712
- # example, during the transition from standard time to daylight savings
3713
- # time). There are also local times that have more than one UTC equivalent
3714
- # (for example, during the transition from daylight savings time to standard
3715
- # time).
3716
- #
3717
- # In the first case (no equivalent UTC time), a {PeriodNotFound} exception
3718
- # will be raised.
3719
- #
3720
- # In the second case (more than one equivalent UTC time), an {AmbiguousTime}
3721
- # exception will be raised unless the optional `dst` parameter or block
3722
- # handles the ambiguity.
3723
- #
3724
- # If the ambiguity is due to a transition from daylight savings time to
3725
- # standard time, the `dst` parameter can be used to select whether the
3726
- # daylight savings time or local time is used. For example, the following
3727
- # code would raise an {AmbiguousTime} exception:
3728
- #
3729
- # tz = TZInfo::Timezone.get('America/New_York')
3730
- # tz.period_for_local(Time.new(2004,10,31,1,30,0))
3731
- #
3732
- # Specifying `dst = true` would select the daylight savings period from
3733
- # April to October 2004. Specifying `dst = false` would return the
3734
- # standard time period from October 2004 to April 2005.
3735
- #
3736
- # The `dst` parameter will not be able to resolve an ambiguity resulting
3737
- # from the clocks being set back without changing from daylight savings time
3738
- # to standard time. In this case, if a block is specified, it will be called
3739
- # to resolve the ambiguity. The block must take a single parameter - an
3740
- # `Array` of {TimezonePeriod}s that need to be resolved. The block can
3741
- # select and return a single {TimezonePeriod} or return `nil` or an empty
3742
- # `Array` to cause an {AmbiguousTime} exception to be raised.
3743
- #
3744
- # The default value of the `dst` parameter can be specified using
3745
- # {Timezone.default_dst=}.
3746
- #
3747
- # @param dst [Boolean] whether to resolve ambiguous local times by always
3748
- # selecting the period observing daylight savings time (`true`), always
3749
- # selecting the period observing standard time (`false`), or leaving the
3750
- # ambiguity unresolved (`nil`).
3751
- # @param local_time [Object] a `Time`, `DateTime` or {Timestamp}.
3752
- # @raise [PeriodNotFound] if `local_time` is not valid for the time zone
3753
- # (there is no equivalent UTC time).
3754
- # @raise [AmbiguousTime] if `local_time` was ambiguous for the time zone and
3755
- # the `dst` parameter or block did not resolve the ambiguity.
3756
- # @raise [ArgumentError] if `local_time` is `nil`.
3757
- # @return [Object] the UTC equivalent of `local_time` as a `Time`,
3758
- # `DateTime` or {Timestamp}.
3759
- # @yield [periods] if the `dst` parameter did not resolve an ambiguity, an
3760
- # optional block is yielded to.
3761
- # @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all
3762
- # the {TimezonePeriod}s that still match `local_time` after applying the
3763
- # `dst` parameter.
3764
- # @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod}
3765
- # or an `Array` containing a chosen {TimezonePeriod}; to leave the
3766
- # ambiguity unresolved: an empty `Array`, an `Array` containing more than
3767
- # one {TimezonePeriod}, or `nil`.
3768
- def local_to_utc(local_time, dst = T.unsafe(nil)); end
3769
-
3770
- # @return [String] the identifier of the time zone, for example,
3771
- # `"Europe/Paris"`.
3772
- def name; end
3773
-
3774
- # @return [TimeWithOffset] the current local time in the time zone.
3775
- def now; end
3776
-
3777
- # Returns the observed offset from UTC in seconds at the given time. This
3778
- # includes adjustments made for daylight savings time.
3779
- #
3780
- # @param time [Object] a `Time`, `DateTime` or `Timestamp`.
3781
- # @raise [ArgumentError] if `time` is `nil`.
3782
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified UTC
3783
- # offset.
3784
- # @return [Integer] the observed offset from UTC in seconds at the given
3785
- # time.
3786
- def observed_utc_offset(time = T.unsafe(nil)); end
3787
-
3788
- # Returns the unique offsets used by the time zone up to a given time (`to`)
3789
- # as an `Array` of {TimezoneOffset} instances.
3790
- #
3791
- # A from time may also be supplied using the `from` parameter. If from is
3792
- # not `nil`, only offsets used from that time onwards will be returned.
3793
- #
3794
- # Comparisons with `to` are exclusive. Comparisons with `from` are
3795
- # inclusive.
3796
- #
3797
- # @param to [Object] a `Time`, `DateTime` or {Timestamp} specifying the
3798
- # latest (exclusive) offset to return.
3799
- # @param from [Object] an optional `Time`, `DateTime` or {Timestamp}
3800
- # specifying the earliest (inclusive) offset to return.
3801
- # @raise [ArgumentError] if `from` is specified and `to` is not greater than
3802
- # `from`.
3803
- # @raise [ArgumentError] is raised if `to` is `nil`.
3804
- # @raise [ArgumentError] if either `to` or `from` is a {Timestamp} with an
3805
- # unspecified offset.
3806
- # @return [Array<TimezoneOffsets>] the offsets that are used earlier than
3807
- # `to` and, if specified, at or later than `from`. Offsets may be returned
3808
- # in any order.
3809
- def offsets_up_to(to, from = T.unsafe(nil)); end
3810
-
3811
- # Returns the {TimezonePeriod} that is valid at a given time.
3812
- #
3813
- # Unlike {period_for_local} and {period_for_utc}, the UTC offset of the
3814
- # `time` parameter is taken into consideration.
3815
- #
3816
- # @param time [Object] a `Time`, `DateTime` or {Timestamp}.
3817
- # @raise [ArgumentError] if `time` is `nil`.
3818
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified
3819
- # offset.
3820
- # @return [TimezonePeriod] the {TimezonePeriod} that is valid at `time`.
3821
- def period_for(time); end
3822
-
3823
- # Returns the {TimezonePeriod} that is valid at the given local time.
3824
- #
3825
- # The UTC offset of the `local_time` parameter is ignored (it is treated as
3826
- # a time in the time zone represented by `self`). Use the {period_for}
3827
- # method instead if the the UTC offset of the time needs to be taken into
3828
- # consideration.
3829
- #
3830
- # _Warning:_ There are local times that have no equivalent UTC times (for
3831
- # example, during the transition from standard time to daylight savings
3832
- # time). There are also local times that have more than one UTC equivalent
3833
- # (for example, during the transition from daylight savings time to standard
3834
- # time).
3835
- #
3836
- # In the first case (no equivalent UTC time), a {PeriodNotFound} exception
3837
- # will be raised.
3838
- #
3839
- # In the second case (more than one equivalent UTC time), an {AmbiguousTime}
3840
- # exception will be raised unless the optional `dst` parameter or block
3841
- # handles the ambiguity.
3842
- #
3843
- # If the ambiguity is due to a transition from daylight savings time to
3844
- # standard time, the `dst` parameter can be used to select whether the
3845
- # daylight savings time or local time is used. For example, the following
3846
- # code would raise an {AmbiguousTime} exception:
3847
- #
3848
- # tz = TZInfo::Timezone.get('America/New_York')
3849
- # tz.period_for_local(Time.new(2004,10,31,1,30,0))
3850
- #
3851
- # Specifying `dst = true` would select the daylight savings period from
3852
- # April to October 2004. Specifying `dst = false` would return the
3853
- # standard time period from October 2004 to April 2005.
3854
- #
3855
- # The `dst` parameter will not be able to resolve an ambiguity resulting
3856
- # from the clocks being set back without changing from daylight savings time
3857
- # to standard time. In this case, if a block is specified, it will be called
3858
- # to resolve the ambiguity. The block must take a single parameter - an
3859
- # `Array` of {TimezonePeriod}s that need to be resolved. The block can
3860
- # select and return a single {TimezonePeriod} or return `nil` or an empty
3861
- # `Array` to cause an {AmbiguousTime} exception to be raised.
3862
- #
3863
- # The default value of the `dst` parameter can be specified using
3864
- # {Timezone.default_dst=}.
3865
- #
3866
- # @param dst [Boolean] whether to resolve ambiguous local times by always
3867
- # selecting the period observing daylight savings time (`true`), always
3868
- # selecting the period observing standard time (`false`), or leaving the
3869
- # ambiguity unresolved (`nil`).
3870
- # @param local_time [Object] a `Time`, `DateTime` or {Timestamp}.
3871
- # @raise [PeriodNotFound] if `local_time` is not valid for the time zone
3872
- # (there is no equivalent UTC time).
3873
- # @raise [AmbiguousTime] if `local_time` was ambiguous for the time zone and
3874
- # the `dst` parameter or block did not resolve the ambiguity.
3875
- # @raise [ArgumentError] if `local_time` is `nil`.
3876
- # @return [TimezonePeriod] the {TimezonePeriod} that is valid at
3877
- # `local_time`.
3878
- # @yield [periods] if the `dst` parameter did not resolve an ambiguity, an
3879
- # optional block is yielded to.
3880
- # @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all
3881
- # the {TimezonePeriod}s that still match `local_time` after applying the
3882
- # `dst` parameter.
3883
- # @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod}
3884
- # or an `Array` containing a chosen {TimezonePeriod}; to leave the
3885
- # ambiguity unresolved: an empty `Array`, an `Array` containing more than
3886
- # one {TimezonePeriod}, or `nil`.
3887
- def period_for_local(local_time, dst = T.unsafe(nil)); end
3888
-
3889
- # Returns the {TimezonePeriod} that is valid at a given time.
3890
- #
3891
- # The UTC offset of the `utc_time` parameter is ignored (it is treated as a
3892
- # UTC time). Use the {period_for} method instead if the UTC offset of the
3893
- # time needs to be taken into consideration.
3894
- #
3895
- # @param utc_time [Object] a `Time`, `DateTime` or {Timestamp}.
3896
- # @raise [ArgumentError] if `utc_time` is `nil`.
3897
- # @return [TimezonePeriod] the {TimezonePeriod} that is valid at `utc_time`.
3898
- def period_for_utc(utc_time); end
3899
-
3900
- # Returns the set of {TimezonePeriod}s that are valid for the given
3901
- # local time as an `Array`.
3902
- #
3903
- # The UTC offset of the `local_time` parameter is ignored (it is treated as
3904
- # a time in the time zone represented by `self`).
3905
- #
3906
- # This will typically return an `Array` containing a single
3907
- # {TimezonePeriod}. More than one {TimezonePeriod} will be returned when the
3908
- # local time is ambiguous (for example, when daylight savings time ends). An
3909
- # empty `Array` will be returned when the local time is not valid (for
3910
- # example, when daylight savings time begins).
3911
- #
3912
- # To obtain just a single {TimezonePeriod} in all cases, use
3913
- # {period_for_local} instead and specify how ambiguities should be resolved.
3914
- #
3915
- # @param local_time [Object] a `Time`, `DateTime` or {Timestamp}.
3916
- # @raise [ArgumentError] if `local_time` is `nil`.
3917
- # @return [Array<TimezonePeriod>] the set of {TimezonePeriod}s that are
3918
- # valid at `local_time`.
3919
- def periods_for_local(local_time); end
3920
-
3921
- # Converts a time to local time for the time zone and returns a `String`
3922
- # representation of the local time according to the given format.
3923
- #
3924
- # `Timezone#strftime` first expands any occurrences of `%Z` in the format
3925
- # string to the time zone abbreviation for the local time (for example, EST
3926
- # or EDT). Depending on the type of `time` parameter, the result of the
3927
- # expansion is then passed to either `Time#strftime`, `DateTime#strftime` or
3928
- # `Timestamp#strftime` to handle any other format directives.
3929
- #
3930
- # This method is equivalent to the following:
3931
- #
3932
- # time_zone.to_local(time).strftime(format)
3933
- #
3934
- # @param format [String] the format string.
3935
- # @param time [Object] a `Time`, `DateTime` or `Timestamp`.
3936
- # @raise [ArgumentError] if `format` or `time` is `nil`.
3937
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified UTC
3938
- # offset.
3939
- # @return [String] the formatted local time.
3940
- def strftime(format, time = T.unsafe(nil)); end
3941
-
3942
- # Converts a time to the local time for the time zone.
3943
- #
3944
- # The result will be of type {TimeWithOffset} (if passed a `Time`),
3945
- # {DateTimeWithOffset} (if passed a `DateTime`) or {TimestampWithOffset} (if
3946
- # passed a {Timestamp}). {TimeWithOffset}, {DateTimeWithOffset} and
3947
- # {TimestampWithOffset} are subclasses of `Time`, `DateTime` and {Timestamp}
3948
- # that provide additional information about the local result.
3949
- #
3950
- # Unlike {utc_to_local}, {to_local} takes the UTC offset of the given time
3951
- # into consideration.
3952
- #
3953
- # @param time [Object] a `Time`, `DateTime` or {Timestamp}.
3954
- # @raise [ArgumentError] if `time` is `nil`.
3955
- # @raise [ArgumentError] if `time` is a {Timestamp} that does not have a
3956
- # specified UTC offset.
3957
- # @return [Object] the local equivalent of `time` as a {TimeWithOffset},
3958
- # {DateTimeWithOffset} or {TimestampWithOffset}.
3959
- def to_local(time); end
3960
-
3961
- # @return [String] {identifier}, modified to make it more readable.
3962
- def to_s; end
3963
-
3964
- # Returns an `Array` of {TimezoneTransition} instances representing the
3965
- # times where the UTC offset of the timezone changes.
3966
- #
3967
- # Transitions are returned up to a given time (`to`).
3968
- #
3969
- # A from time may also be supplied using the `from` parameter. If from is
3970
- # not `nil`, only transitions from that time onwards will be returned.
3971
- #
3972
- # Comparisons with `to` are exclusive. Comparisons with `from` are
3973
- # inclusive. If a transition falls precisely on `to`, it will be excluded.
3974
- # If a transition falls on `from`, it will be included.
3975
- #
3976
- # @param to [Object] a `Time`, `DateTime` or {Timestamp} specifying the
3977
- # latest (exclusive) transition to return.
3978
- # @param from [Object] an optional `Time`, `DateTime` or {Timestamp}
3979
- # specifying the earliest (inclusive) transition to return.
3980
- # @raise [ArgumentError] if `from` is specified and `to` is not greater than
3981
- # `from`.
3982
- # @raise [ArgumentError] is raised if `to` is `nil`.
3983
- # @raise [ArgumentError] if either `to` or `from` is a {Timestamp} with an
3984
- # unspecified offset.
3985
- # @return [Array<TimezoneTransition>] the transitions that are earlier than
3986
- # `to` and, if specified, at or later than `from`. Transitions are ordered
3987
- # by when they occur, from earliest to latest.
3988
- def transitions_up_to(to, from = T.unsafe(nil)); end
3989
-
3990
- # Returns the observed offset from UTC in seconds at the given time. This
3991
- # includes adjustments made for daylight savings time.
3992
- #
3993
- # @param time [Object] a `Time`, `DateTime` or `Timestamp`.
3994
- # @raise [ArgumentError] if `time` is `nil`.
3995
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified UTC
3996
- # offset.
3997
- # @return [Integer] the observed offset from UTC in seconds at the given
3998
- # time.
3999
- def utc_offset(time = T.unsafe(nil)); end
4000
-
4001
- # Converts a time in UTC to the local time for the time zone.
4002
- #
4003
- # The result will be of type {TimeWithOffset} (if passed a `Time`),
4004
- # {DateTimeWithOffset} (if passed a `DateTime`) or {TimestampWithOffset} (if
4005
- # passed a {Timestamp}). {TimeWithOffset}, {DateTimeWithOffset} and
4006
- # {TimestampWithOffset} are subclasses of `Time`, `DateTime` and {Timestamp}
4007
- # that provide additional information about the local result.
4008
- #
4009
- # The UTC offset of the `utc_time` parameter is ignored (it is treated as a
4010
- # UTC time). Use the {to_local} method instead if the the UTC offset of the
4011
- # time needs to be taken into consideration.
4012
- #
4013
- # @param utc_time [Object] a `Time`, `DateTime` or {Timestamp}.
4014
- # @raise [ArgumentError] if `utc_time` is `nil`.
4015
- # @return [Object] the local equivalent of `utc_time` as a {TimeWithOffset},
4016
- # {DateTimeWithOffset} or {TimestampWithOffset}.
4017
- def utc_to_local(utc_time); end
4018
-
4019
- private
4020
-
4021
- # Raises an {UnknownTimezone} exception.
4022
- #
4023
- # @raise [UnknownTimezone] always.
4024
- def raise_unknown_timezone; end
4025
-
4026
- class << self
4027
- # Loads a {Timezone} from the serialized representation returned by {_dump}.
4028
- # This is method is called when using `Marshal.load` or `Marshal.restore`
4029
- # to restore a serialized {Timezone}.
4030
- #
4031
- # @param data [String] a serialized representation of a {Timezone}.
4032
- # @return [Timezone] the result of converting `data` back into a {Timezone}.
4033
- def _load(data); end
4034
-
4035
- # Returns an `Array` of all the available time zones.
4036
- #
4037
- # {TimezoneProxy} instances are returned to avoid the overhead of loading
4038
- # time zone data until it is first needed.
4039
- #
4040
- # @return [Array<Timezone>] all available time zones.
4041
- def all; end
4042
-
4043
- # Returns an `Array` of the identifiers of all the time zones that are
4044
- # observed by at least one {Country}. This is not the complete set of time
4045
- # zone identifiers as some are not country specific (e.g. `'Etc/GMT'`).
4046
- #
4047
- # {TimezoneProxy} instances are returned to avoid the overhead of loading
4048
- # time zone data until it is first needed.
4049
- #
4050
- # zones that are observed by at least one {Country}.
4051
- #
4052
- # @return [Array<String>] an `Array` of the identifiers of all the time
4053
- def all_country_zone_identifiers; end
4054
-
4055
- # Returns an `Array` of all the time zones that are observed by at least
4056
- # one {Country}. This is not the complete set of time zones as some are
4057
- # not country specific (e.g. `'Etc/GMT'`).
4058
- #
4059
- # {TimezoneProxy} instances are returned to avoid the overhead of loading
4060
- # time zone data until it is first needed.
4061
- #
4062
- # @return [Array<Timezone>] an `Array` of all the time zones that are
4063
- # observed by at least one {Country}.
4064
- def all_country_zones; end
4065
-
4066
- # time zones that are defined by offsets and transitions.
4067
- #
4068
- # @return [Array<String>] an `Array` of the identifiers of all available
4069
- def all_data_zone_identifiers; end
4070
-
4071
- # Returns an `Array` of all the available time zones that are
4072
- # defined by offsets and transitions.
4073
- #
4074
- # {TimezoneProxy} instances are returned to avoid the overhead of loading
4075
- # time zone data until it is first needed.
4076
- #
4077
- # @return [Array<Timezone>] an `Array` of all the available time zones
4078
- # that are defined by offsets and transitions.
4079
- def all_data_zones; end
4080
-
4081
- # @return [Array<String>] an `Array` containing the identifiers of all the
4082
- # available time zones.
4083
- def all_identifiers; end
4084
-
4085
- # time zones that are defined as links to / aliases for other time zones.
4086
- #
4087
- # @return [Array<String>] an `Array` of the identifiers of all available
4088
- def all_linked_zone_identifiers; end
4089
-
4090
- # Returns an `Array` of all the available time zones that are
4091
- # defined as links to / aliases for other time zones.
4092
- #
4093
- # {TimezoneProxy} instances are returned to avoid the overhead of loading
4094
- # time zone data until it is first needed.
4095
- #
4096
- # @return [Array<Timezone>] an `Array` of all the available time zones
4097
- # that are defined as links to / aliases for other time zones.
4098
- def all_linked_zones; end
4099
-
4100
- # Returns the default value of the optional `dst` parameter of the
4101
- # {local_time}, {local_datetime} and {local_timestamp}, {local_to_utc}
4102
- # and {period_for_local} methods (`nil`, `true` or `false`).
4103
- #
4104
- # {default_dst} defaults to `nil` unless changed with {default_dst=}.
4105
- #
4106
- # @return [Boolean] the default value of the optional `dst` parameter of
4107
- # the {local_time}, {local_datetime} and {local_timestamp},
4108
- # {local_to_utc} and {period_for_local} methods (`nil`, `true` or
4109
- # `false`).
4110
- def default_dst; end
4111
-
4112
- # Sets the default value of the optional `dst` parameter of the
4113
- # {local_datetime}, {local_time}, {local_timestamp}, {local_to_utc} and
4114
- # {period_for_local} methods. Can be set to `nil`, `true` or `false`.
4115
- #
4116
- # @param value [Boolean] `nil`, `true` or `false`.
4117
- def default_dst=(value); end
4118
-
4119
- # Returns a time zone by its IANA Time Zone Database identifier (e.g.
4120
- # `"Europe/London"` or `"America/Chicago"`). Call {all_identifiers} for a
4121
- # list of all the valid identifiers.
4122
- #
4123
- # The {get} method will return a subclass of {Timezone}, either a
4124
- # {DataTimezone} (for a time zone defined by rules that set out when
4125
- # transitions occur) or a {LinkedTimezone} (for a time zone that is just a
4126
- # link to or alias for a another time zone).
4127
- #
4128
- # @param identifier [String] an IANA Time Zone Database time zone
4129
- # identifier.
4130
- # @raise [InvalidTimezoneIdentifier] if the `identifier` is not valid.
4131
- # @return [Timezone] the {Timezone} with the given `identifier`.
4132
- def get(identifier); end
4133
-
4134
- # Returns a proxy for the time zone with the given identifier. This allows
4135
- # loading of the time zone data to be deferred until it is first needed.
4136
- #
4137
- # The identifier will not be validated. If an invalid identifier is
4138
- # specified, no exception will be raised until the proxy is used.
4139
- #
4140
- # @param identifier [String] an IANA Time Zone Database time zone
4141
- # identifier.
4142
- # @return [TimezoneProxy] a proxy for the time zone with the given
4143
- # `identifier`.
4144
- def get_proxy(identifier); end
4145
-
4146
- private
4147
-
4148
- # @return [DataSource] the current DataSource.
4149
- def data_source; end
4150
-
4151
- # @param identifiers [Enumerable<String>] an `Enumerable` of time zone
4152
- # identifiers.
4153
- # @return [Array<TimezoneProxy>] an `Array` of {TimezoneProxy}
4154
- # instances corresponding to the given identifiers.
4155
- def get_proxies(identifiers); end
4156
- end
4157
- end
4158
-
4159
- # Alias used by TZInfo::Data format1 releases.
4160
- #
4161
- # @private
4162
- TZInfo::TimezoneDefinition = TZInfo::Format1::TimezoneDefinition
4163
-
4164
- # Alias used by TZInfo::Data format 1 releases.
4165
- #
4166
- # @private
4167
- TZInfo::TimezoneIndexDefinition = TZInfo::Format1::TimezoneIndexDefinition
4168
-
4169
- # Represents an offset from UTC observed by a time zone.
4170
- class TZInfo::TimezoneOffset
4171
- # Initializes a new {TimezoneOffset}.
4172
- #
4173
- # {TimezoneOffset} instances should not normally be constructed manually.
4174
- #
4175
- # The passed in `abbreviation` instance will be frozen.
4176
- #
4177
- # @param base_utc_offset [Integer] the base offset from UTC in seconds.
4178
- # @param std_offset [Integer] the offset from standard time in seconds.
4179
- # @param abbreviation [String] the abbreviation identifying the offset.
4180
- # @return [TimezoneOffset] a new instance of TimezoneOffset
4181
- def initialize(base_utc_offset, std_offset, abbreviation); end
4182
-
4183
- # Determines if this {TimezoneOffset} is equal to another instance.
4184
- #
4185
- # @param toi [Object] the instance to test for equality.
4186
- # @return [Boolean] `true` if `toi` is a {TimezoneOffset} with the same
4187
- # {utc_offset}, {std_offset} and {abbreviation} as this {TimezoneOffset},
4188
- # otherwise `false`.
4189
- def ==(toi); end
4190
-
4191
- # The abbreviation that identifies this offset. For example GMT
4192
- # (Greenwich Mean Time) or BST (British Summer Time) for Europe/London.
4193
- #
4194
- # @return [String] the abbreviation that identifies this offset.
4195
- def abbr; end
4196
-
4197
- # The abbreviation that identifies this offset. For example GMT
4198
- # (Greenwich Mean Time) or BST (British Summer Time) for Europe/London.
4199
- #
4200
- # @return [String] the abbreviation that identifies this offset.
4201
- def abbreviation; end
4202
-
4203
- # Returns the base offset from UTC in seconds (`observed_utc_offset -
4204
- # std_offset`). This does not include any adjustment made for daylight
4205
- # savings time and will typically remain constant throughout the year.
4206
- #
4207
- # To obtain the currently observed offset from UTC, including the effect of
4208
- # daylight savings time, use {observed_utc_offset} instead.
4209
- #
4210
- # If you require accurate {base_utc_offset} values, you should install the
4211
- # tzinfo-data gem and set {DataSources::RubyDataSource} as the {DataSource}.
4212
- # When using {DataSources::ZoneinfoDataSource}, the value of
4213
- # {base_utc_offset} has to be derived from changes to the observed UTC
4214
- # offset and DST status since it is not included in zoneinfo files.
4215
- #
4216
- # @return [Integer] the base offset from UTC in seconds.
4217
- def base_utc_offset; end
4218
-
4219
- # Determines if daylight savings is in effect (i.e. if {std_offset} is
4220
- # non-zero).
4221
- #
4222
- # @return [Boolean] `true` if {std_offset} is non-zero, otherwise `false`.
4223
- def dst?; end
4224
-
4225
- # Determines if this {TimezoneOffset} is equal to another instance.
4226
- #
4227
- # @param toi [Object] the instance to test for equality.
4228
- # @return [Boolean] `true` if `toi` is a {TimezoneOffset} with the same
4229
- # {utc_offset}, {std_offset} and {abbreviation} as this {TimezoneOffset},
4230
- # otherwise `false`.
4231
- def eql?(toi); end
4232
-
4233
- # @return [Integer] a hash based on {utc_offset}, {std_offset} and
4234
- # {abbreviation}.
4235
- def hash; end
4236
-
4237
- # @return [String] the internal object state as a programmer-readable
4238
- # `String`.
4239
- def inspect; end
4240
-
4241
- # Returns the observed offset from UTC in seconds (`base_utc_offset +
4242
- # std_offset`). This includes adjustments made for daylight savings time.
4243
- #
4244
- # @return [Integer] the observed offset from UTC in seconds.
4245
- def observed_utc_offset; end
4246
-
4247
- # Returns the offset from the time zone's standard time in seconds
4248
- # (`observed_utc_offset - base_utc_offset`). Zero when daylight savings time
4249
- # is not in effect. Non-zero (usually 3600 = 1 hour) if daylight savings is
4250
- # being observed.
4251
- #
4252
- # If you require accurate {std_offset} values, you should install the
4253
- # tzinfo-data gem and set {DataSources::RubyDataSource} as the {DataSource}.
4254
- # When using {DataSources::ZoneinfoDataSource}, the value of {std_offset}
4255
- # has to be derived from changes to the observed UTC offset and DST status
4256
- # since it is not included in zoneinfo files.
4257
- #
4258
- # @return [Integer] the offset from the time zone's standard time in
4259
- # seconds.
4260
- def std_offset; end
4261
-
4262
- # Returns the base offset from UTC in seconds (`observed_utc_offset -
4263
- # std_offset`). This does not include any adjustment made for daylight
4264
- # savings time and will typically remain constant throughout the year.
4265
- #
4266
- # To obtain the currently observed offset from UTC, including the effect of
4267
- # daylight savings time, use {observed_utc_offset} instead.
4268
- #
4269
- # If you require accurate {base_utc_offset} values, you should install the
4270
- # tzinfo-data gem and set {DataSources::RubyDataSource} as the {DataSource}.
4271
- # When using {DataSources::ZoneinfoDataSource}, the value of
4272
- # {base_utc_offset} has to be derived from changes to the observed UTC
4273
- # offset and DST status since it is not included in zoneinfo files.
4274
- #
4275
- # @return [Integer] the base offset from UTC in seconds.
4276
- def utc_offset; end
4277
-
4278
- # Returns the observed offset from UTC in seconds (`base_utc_offset +
4279
- # std_offset`). This includes adjustments made for daylight savings time.
4280
- #
4281
- # @return [Integer] the observed offset from UTC in seconds.
4282
- def utc_total_offset; end
4283
- end
4284
-
4285
- # {TimezonePeriod} represents a period of time for a time zone where the same
4286
- # offset from UTC applies. It provides access to the observed offset, time
4287
- # zone abbreviation, start time and end time.
4288
- #
4289
- # The period of time can be unbounded at the start, end, or both the start
4290
- # and end.
4291
- #
4292
- # @abstract Time zone period data will returned as an instance of one of the
4293
- # subclasses of {TimezonePeriod}.
4294
- class TZInfo::TimezonePeriod
4295
- # Initializes a {TimezonePeriod}.
4296
- #
4297
- # @param offset [TimezoneOffset] the offset that is observed for the period
4298
- # of time.
4299
- # @raise [ArgumentError] if `offset` is `nil`.
4300
- # @return [TimezonePeriod] a new instance of TimezonePeriod
4301
- def initialize(offset); end
4302
-
4303
- # The abbreviation that identifies this offset. For example GMT
4304
- # (Greenwich Mean Time) or BST (British Summer Time) for Europe/London.
4305
- #
4306
- # @return [String] the abbreviation that identifies this offset.
4307
- def abbr; end
4308
-
4309
- # The abbreviation that identifies this offset. For example GMT
4310
- # (Greenwich Mean Time) or BST (British Summer Time) for Europe/London.
4311
- #
4312
- # @return [String] the abbreviation that identifies this offset.
4313
- def abbreviation; end
4314
-
4315
- # Returns the base offset from UTC in seconds (`observed_utc_offset -
4316
- # std_offset`). This does not include any adjustment made for daylight
4317
- # savings time and will typically remain constant throughout the year.
4318
- #
4319
- # To obtain the currently observed offset from UTC, including the effect of
4320
- # daylight savings time, use {observed_utc_offset} instead.
4321
- #
4322
- # If you require accurate {base_utc_offset} values, you should install the
4323
- # tzinfo-data gem and set {DataSources::RubyDataSource} as the {DataSource}.
4324
- # When using {DataSources::ZoneinfoDataSource}, the value of
4325
- # {base_utc_offset} has to be derived from changes to the observed UTC
4326
- # offset and DST status since it is not included in zoneinfo files.
4327
- #
4328
- # @return [Integer] the base offset from UTC in seconds.
4329
- def base_utc_offset; end
4330
-
4331
- # Determines if daylight savings is in effect (i.e. if {std_offset} is
4332
- # non-zero).
4333
- #
4334
- # @return [Boolean] `true` if {std_offset} is non-zero, otherwise `false`.
4335
- def dst?; end
4336
-
4337
- # @return [TimezoneTransition] the transition that defines the end of this
4338
- # {TimezonePeriod} (`nil` if the end is unbounded).
4339
- def end_transition; end
4340
-
4341
- # Returns the UTC end time of the period or `nil` if the end of the period
4342
- # is unbounded.
4343
- #
4344
- # The result is returned as a {Timestamp}. To obtain the end time as a
4345
- # `Time` or `DateTime`, call either {Timestamp#to_time to_time} or
4346
- # {Timestamp#to_datetime to_datetime} on the result.
4347
- #
4348
- # @return [Timestamp] the UTC end time of the period or `nil` if the end of
4349
- # the period is unbounded.
4350
- def ends_at; end
4351
-
4352
- # Returns the local end time of the period or `nil` if the end of the period
4353
- # is unbounded.
4354
- #
4355
- # The result is returned as a {TimestampWithOffset}. To obtain the end time
4356
- # as a `Time` or `DateTime`, call either {TimestampWithOffset#to_time
4357
- # to_time} or {TimestampWithOffset#to_datetime to_datetime} on the result.
4358
- #
4359
- # @return [TimestampWithOffset] the local end time of the period or `nil` if
4360
- # the end of the period is unbounded.
4361
- def local_ends_at; end
4362
-
4363
- # Returns the local start time of the period or `nil` if the start of the
4364
- # period is unbounded.
4365
- #
4366
- # The result is returned as a {TimestampWithOffset}. To obtain the start
4367
- # time as a `Time` or `DateTime`, call either {TimestampWithOffset#to_time
4368
- # to_time} or {TimestampWithOffset#to_datetime to_datetime} on the result.
4369
- #
4370
- # @return [TimestampWithOffset] the local start time of the period or `nil`
4371
- # if the start of the period is unbounded.
4372
- def local_starts_at; end
4373
-
4374
- # Returns the observed offset from UTC in seconds (`base_utc_offset +
4375
- # std_offset`). This includes adjustments made for daylight savings time.
4376
- #
4377
- # @return [Integer] the observed offset from UTC in seconds.
4378
- def observed_utc_offset; end
4379
-
4380
- # @return [TimezoneOffset] the offset that applies in the period of time.
4381
- def offset; end
4382
-
4383
- # @return [TimezoneTransition] the transition that defines the start of this
4384
- # {TimezonePeriod} (`nil` if the start is unbounded).
4385
- def start_transition; end
4386
-
4387
- # Returns the UTC start time of the period or `nil` if the start of the
4388
- # period is unbounded.
4389
- #
4390
- # The result is returned as a {Timestamp}. To obtain the start time as a
4391
- # `Time` or `DateTime`, call either {Timestamp#to_time to_time} or
4392
- # {Timestamp#to_datetime to_datetime} on the result.
4393
- #
4394
- # @return [Timestamp] the UTC start time of the period or `nil` if the start
4395
- # of the period is unbounded.
4396
- def starts_at; end
4397
-
4398
- # Returns the offset from the time zone's standard time in seconds
4399
- # (`observed_utc_offset - base_utc_offset`). Zero when daylight savings time
4400
- # is not in effect. Non-zero (usually 3600 = 1 hour) if daylight savings is
4401
- # being observed.
4402
- #
4403
- # If you require accurate {std_offset} values, you should install the
4404
- # tzinfo-data gem and set {DataSources::RubyDataSource} as the {DataSource}.
4405
- # When using {DataSources::ZoneinfoDataSource}, the value of {std_offset}
4406
- # has to be derived from changes to the observed UTC offset and DST status
4407
- # since it is not included in zoneinfo files.
4408
- #
4409
- # @return [Integer] the offset from the time zone's standard time in
4410
- # seconds.
4411
- def std_offset; end
4412
-
4413
- # Returns the base offset from UTC in seconds (`observed_utc_offset -
4414
- # std_offset`). This does not include any adjustment made for daylight
4415
- # savings time and will typically remain constant throughout the year.
4416
- #
4417
- # To obtain the currently observed offset from UTC, including the effect of
4418
- # daylight savings time, use {observed_utc_offset} instead.
4419
- #
4420
- # If you require accurate {base_utc_offset} values, you should install the
4421
- # tzinfo-data gem and set {DataSources::RubyDataSource} as the {DataSource}.
4422
- # When using {DataSources::ZoneinfoDataSource}, the value of
4423
- # {base_utc_offset} has to be derived from changes to the observed UTC
4424
- # offset and DST status since it is not included in zoneinfo files.
4425
- #
4426
- # @return [Integer] the base offset from UTC in seconds.
4427
- def utc_offset; end
4428
-
4429
- # Returns the observed offset from UTC in seconds (`base_utc_offset +
4430
- # std_offset`). This includes adjustments made for daylight savings time.
4431
- #
4432
- # @return [Integer] the observed offset from UTC in seconds.
4433
- def utc_total_offset; end
4434
-
4435
- # The abbreviation that identifies this offset. For example GMT
4436
- # (Greenwich Mean Time) or BST (British Summer Time) for Europe/London.
4437
- #
4438
- # @return [String] the abbreviation that identifies this offset.
4439
- def zone_identifier; end
4440
-
4441
- private
4442
-
4443
- # Raises a {NotImplementedError} to indicate that subclasses should override
4444
- # a method.
4445
- #
4446
- # @raise [NotImplementedError] always.
4447
- def raise_not_implemented(method_name); end
4448
-
4449
- # @param transition [TimezoneTransition] a transition or `nil`.
4450
- # @return [Timestamp] the {Timestamp} representing when a transition occurs,
4451
- # or `nil` if `transition` is `nil`.
4452
- def timestamp(transition); end
4453
-
4454
- # @param transition [TimezoneTransition] a transition or `nil`.
4455
- # @return [TimestampWithOffset] a {Timestamp} representing when a transition
4456
- # occurs with offset set to {#offset}, or `nil` if `transition` is `nil`.
4457
- def timestamp_with_offset(transition); end
4458
- end
4459
-
4460
- # A proxy class standing in for a {Timezone} with a given identifier.
4461
- # {TimezoneProxy} inherits from {Timezone} and can be treated identically to
4462
- # {Timezone} instances loaded with {Timezone.get}.
4463
- #
4464
- # {TimezoneProxy} instances are used to avoid the performance overhead of
4465
- # loading time zone data into memory, for example, by {Timezone.all}.
4466
- #
4467
- # The first time an attempt is made to access the data for the time zone, the
4468
- # real {Timezone} will be loaded is loaded. If the proxy's identifier was not
4469
- # valid, then an exception will be raised at this point.
4470
- class TZInfo::TimezoneProxy < ::TZInfo::Timezone
4471
- # Initializes a new {TimezoneProxy}.
4472
- #
4473
- # The `identifier` parameter is not checked when initializing the proxy. It
4474
- # will be validated when the real {Timezone} instance is loaded.
4475
- #
4476
- # @param identifier [String] an IANA Time Zone Database time zone
4477
- # identifier.
4478
- # @return [TimezoneProxy] a new instance of TimezoneProxy
4479
- def initialize(identifier); end
4480
-
4481
- # Returns a serialized representation of this {TimezoneProxy}. This method
4482
- # is called when using `Marshal.dump` with an instance of {TimezoneProxy}.
4483
- #
4484
- # @param limit [Integer] the maximum depth to dump - ignored. @return
4485
- # [String] a serialized representation of this {TimezoneProxy}.
4486
- # @return [String] a serialized representation of this {TimezoneProxy}.
4487
- def _dump(limit); end
4488
-
4489
- # Returns the canonical {Timezone} instance for this {Timezone}.
4490
- #
4491
- # The IANA Time Zone database contains two types of definition: Zones and
4492
- # Links. Zones are defined by rules that set out when transitions occur.
4493
- # Links are just references to fully defined Zone, creating an alias for
4494
- # that Zone.
4495
- #
4496
- # Links are commonly used where a time zone has been renamed in a release of
4497
- # the Time Zone database. For example, the US/Eastern Zone was renamed as
4498
- # America/New_York. A US/Eastern Link was added in its place, linking to
4499
- # (and creating an alias for) America/New_York.
4500
- #
4501
- # Links are also used for time zones that are currently identical to a full
4502
- # Zone, but that are administered separately. For example, Europe/Vatican is
4503
- # a Link to (and alias for) Europe/Rome.
4504
- #
4505
- # For a full Zone (implemented by {DataTimezone}), {canonical_zone} returns
4506
- # self.
4507
- #
4508
- # For a Link (implemented by {LinkedTimezone}), {canonical_zone} returns a
4509
- # {Timezone} instance representing the full Zone that the link targets.
4510
- #
4511
- # TZInfo can be used with different data sources (see the documentation for
4512
- # {TZInfo::DataSource}). Some DataSource implementations may not support
4513
- # distinguishing between full Zones and Links and will treat all time zones
4514
- # as full Zones. In this case, {canonical_zone} will always return `self`.
4515
- #
4516
- # There are two built-in DataSource implementations.
4517
- # {DataSources::RubyDataSource} (which will be used if the tzinfo-data gem
4518
- # is available) supports Link zones. {DataSources::ZoneinfoDataSource}
4519
- # returns Link zones as if they were full Zones. If the {canonical_zone} or
4520
- # {canonical_identifier} methods are needed, the tzinfo-data gem should be
4521
- # installed.
4522
- #
4523
- # The {TZInfo::DataSource.get} method can be used to check which DataSource
4524
- # implementation is being used.
4525
- #
4526
- # @return [Timezone] the canonical {Timezone} instance for this {Timezone}.
4527
- def canonical_zone; end
4528
-
4529
- # @return [String] the identifier of the time zone, for example,
4530
- # `"Europe/Paris"`.
4531
- def identifier; end
4532
-
4533
- # Returns the {TimezonePeriod} that is valid at a given time.
4534
- #
4535
- # Unlike {period_for_local} and {period_for_utc}, the UTC offset of the
4536
- # `time` parameter is taken into consideration.
4537
- #
4538
- # @param time [Object] a `Time`, `DateTime` or {Timestamp}.
4539
- # @raise [ArgumentError] if `time` is `nil`.
4540
- # @raise [ArgumentError] if `time` is a {Timestamp} with an unspecified
4541
- # offset.
4542
- # @return [TimezonePeriod] the {TimezonePeriod} that is valid at `time`.
4543
- def period_for(time); end
4544
-
4545
- # Returns the set of {TimezonePeriod}s that are valid for the given
4546
- # local time as an `Array`.
4547
- #
4548
- # The UTC offset of the `local_time` parameter is ignored (it is treated as
4549
- # a time in the time zone represented by `self`).
4550
- #
4551
- # This will typically return an `Array` containing a single
4552
- # {TimezonePeriod}. More than one {TimezonePeriod} will be returned when the
4553
- # local time is ambiguous (for example, when daylight savings time ends). An
4554
- # empty `Array` will be returned when the local time is not valid (for
4555
- # example, when daylight savings time begins).
4556
- #
4557
- # To obtain just a single {TimezonePeriod} in all cases, use
4558
- # {period_for_local} instead and specify how ambiguities should be resolved.
4559
- #
4560
- # @param local_time [Object] a `Time`, `DateTime` or {Timestamp}.
4561
- # @raise [ArgumentError] if `local_time` is `nil`.
4562
- # @return [Array<TimezonePeriod>] the set of {TimezonePeriod}s that are
4563
- # valid at `local_time`.
4564
- def periods_for_local(local_time); end
4565
-
4566
- # Returns an `Array` of {TimezoneTransition} instances representing the
4567
- # times where the UTC offset of the timezone changes.
4568
- #
4569
- # Transitions are returned up to a given time (`to`).
4570
- #
4571
- # A from time may also be supplied using the `from` parameter. If from is
4572
- # not `nil`, only transitions from that time onwards will be returned.
4573
- #
4574
- # Comparisons with `to` are exclusive. Comparisons with `from` are
4575
- # inclusive. If a transition falls precisely on `to`, it will be excluded.
4576
- # If a transition falls on `from`, it will be included.
4577
- #
4578
- # @param to [Object] a `Time`, `DateTime` or {Timestamp} specifying the
4579
- # latest (exclusive) transition to return.
4580
- # @param from [Object] an optional `Time`, `DateTime` or {Timestamp}
4581
- # specifying the earliest (inclusive) transition to return.
4582
- # @raise [ArgumentError] if `from` is specified and `to` is not greater than
4583
- # `from`.
4584
- # @raise [ArgumentError] is raised if `to` is `nil`.
4585
- # @raise [ArgumentError] if either `to` or `from` is a {Timestamp} with an
4586
- # unspecified offset.
4587
- # @return [Array<TimezoneTransition>] the transitions that are earlier than
4588
- # `to` and, if specified, at or later than `from`. Transitions are ordered
4589
- # by when they occur, from earliest to latest.
4590
- def transitions_up_to(to, from = T.unsafe(nil)); end
4591
-
4592
- private
4593
-
4594
- # Returns the real {Timezone} instance being proxied.
4595
- #
4596
- # The real {Timezone} is loaded using {Timezone.get} on the first access.
4597
- #
4598
- # @return [Timezone] the real {Timezone} instance being proxied.
4599
- def real_timezone; end
4600
-
4601
- class << self
4602
- # Loads a {TimezoneProxy} from the serialized representation returned by
4603
- # {_dump}. This is method is called when using `Marshal.load` or
4604
- # `Marshal.restore` to restore a serialized {Timezone}.
4605
- #
4606
- # @param data [String] a serialized representation of a {TimezoneProxy}.
4607
- # @return [TimezoneProxy] the result of converting `data` back into a
4608
- # {TimezoneProxy}.
4609
- def _load(data); end
4610
- end
4611
- end
4612
-
4613
- # Represents a transition from one observed UTC offset ({TimezoneOffset} to
4614
- # another for a time zone.
4615
- class TZInfo::TimezoneTransition
4616
- # Initializes a new {TimezoneTransition}.
4617
- #
4618
- # {TimezoneTransition} instances should not normally be constructed
4619
- # manually.
4620
- #
4621
- # @param offset [TimezoneOffset] the offset the transition changes to.
4622
- # @param previous_offset [TimezoneOffset] the offset the transition changes
4623
- # from.
4624
- # @param timestamp_value [Integer] when the transition occurs as a
4625
- # number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds
4626
- # (i.e. each day is treated as if it were 86,400 seconds long).
4627
- # @return [TimezoneTransition] a new instance of TimezoneTransition
4628
- def initialize(offset, previous_offset, timestamp_value); end
4629
-
4630
- # Determines if this {TimezoneTransition} is equal to another instance.
4631
- #
4632
- # @param tti [Object] the instance to test for equality.
4633
- # @return [Boolean] `true` if `tti` is a {TimezoneTransition} with the same
4634
- # {offset}, {previous_offset} and {timestamp_value} as this
4635
- # {TimezoneTransition}, otherwise `false`.
4636
- def ==(tti); end
4637
-
4638
- # Returns a {Timestamp} instance representing the UTC time when this
4639
- # transition occurs.
4640
- #
4641
- # To obtain the result as a `Time` or `DateTime`, call either
4642
- # {Timestamp#to_time to_time} or {Timestamp#to_datetime to_datetime} on the
4643
- # {Timestamp} instance that is returned.
4644
- #
4645
- # @return [Timestamp] the UTC time when this transition occurs.
4646
- def at; end
4647
-
4648
- # Determines if this {TimezoneTransition} is equal to another instance.
4649
- #
4650
- # @param tti [Object] the instance to test for equality.
4651
- # @return [Boolean] `true` if `tti` is a {TimezoneTransition} with the same
4652
- # {offset}, {previous_offset} and {timestamp_value} as this
4653
- # {TimezoneTransition}, otherwise `false`.
4654
- def eql?(tti); end
4655
-
4656
- # @return [Integer] a hash based on {offset}, {previous_offset} and
4657
- # {timestamp_value}.
4658
- def hash; end
4659
-
4660
- # Returns a {TimestampWithOffset} instance representing the local time when
4661
- # this transition causes the previous observance to end (calculated from
4662
- # {at} using {previous_offset}).
4663
- #
4664
- # To obtain the result as a `Time` or `DateTime`, call either
4665
- # {TimestampWithOffset#to_time to_time} or {TimestampWithOffset#to_datetime
4666
- # to_datetime} on the {TimestampWithOffset} instance that is returned.
4667
- #
4668
- # @return [TimestampWithOffset] the local time when this transition causes
4669
- # the previous observance to end.
4670
- def local_end_at; end
4671
-
4672
- # Returns a {TimestampWithOffset} instance representing the local time when
4673
- # this transition causes the next observance to start (calculated from {at}
4674
- # using {offset}).
4675
- #
4676
- # To obtain the result as a `Time` or `DateTime`, call either
4677
- # {TimestampWithOffset#to_time to_time} or {TimestampWithOffset#to_datetime
4678
- # to_datetime} on the {TimestampWithOffset} instance that is returned.
4679
- #
4680
- # @return [TimestampWithOffset] the local time when this transition causes
4681
- # the next observance to start.
4682
- def local_start_at; end
4683
-
4684
- # @return [TimezoneOffset] the offset this transition changes to.
4685
- def offset; end
4686
-
4687
- # @return [TimezoneOffset] the offset this transition changes from.
4688
- def previous_offset; end
4689
-
4690
- # When this transition occurs as an `Integer` number of seconds since
4691
- # 1970-01-01 00:00:00 UTC ignoring leap seconds (i.e. each day is treated as
4692
- # if it were 86,400 seconds long). Equivalent to the result of calling the
4693
- # {Timestamp#value value} method on the {Timestamp} returned by {at}.
4694
- #
4695
- # @return [Integer] when this transition occurs as a number of seconds since
4696
- # 1970-01-01 00:00:00 UTC ignoring leap seconds.
4697
- def timestamp_value; end
4698
- end
4699
-
4700
- # Base class for rules definining the transition between standard and daylight
4701
- # savings time.
4702
- #
4703
- # @abstract
4704
- # @private
4705
- class TZInfo::TransitionRule
4706
- # Initializes a new {TransitionRule}.
4707
- #
4708
- # @param transition_at [Integer] the time in seconds after midnight local
4709
- # time at which the transition occurs.
4710
- # @raise [ArgumentError] if `transition_at` is not an `Integer`.
4711
- # @return [TransitionRule] a new instance of TransitionRule
4712
- def initialize(transition_at); end
4713
-
4714
- # Determines if this {TransitionRule} is equal to another instance.
4715
- #
4716
- # @param r [Object] the instance to test for equality.
4717
- # @return [Boolean] `true` if `r` is a {TransitionRule} with the same
4718
- # {transition_at} as this {TransitionRule}, otherwise `false`.
4719
- def ==(r); end
4720
-
4721
- # Calculates the time of the transition from a given offset on a given year.
4722
- #
4723
- # @param offset [TimezoneOffset] the current offset at the time the rule
4724
- # will transition.
4725
- # @param year [Integer] the year in which the transition occurs (local
4726
- # time).
4727
- # @return [TimestampWithOffset] the time at which the transition occurs.
4728
- def at(offset, year); end
4729
-
4730
- # Determines if this {TransitionRule} is equal to another instance.
4731
- #
4732
- # @param r [Object] the instance to test for equality.
4733
- # @return [Boolean] `true` if `r` is a {TransitionRule} with the same
4734
- # {transition_at} as this {TransitionRule}, otherwise `false`.
4735
- def eql?(r); end
4736
-
4737
- # @return [Integer] a hash based on {hash_args} (defaulting to
4738
- # {transition_at}).
4739
- def hash; end
4740
-
4741
- # Returns the number of seconds after midnight local time on the day
4742
- # identified by the rule at which the transition occurs. Can be negative to
4743
- # denote a time on the prior day. Can be greater than or equal to 86,400 to
4744
- # denote a time of the following day.
4745
- #
4746
- # @return [Integer] the time in seconds after midnight local time at which
4747
- # the transition occurs.
4748
- def transition_at; end
4749
-
4750
- protected
4751
-
4752
- # @return [Array] an `Array` of parameters that will influence the output of
4753
- # {hash}.
4754
- def hash_args; end
4755
- end
4756
-
4757
- # Represents a period of time in a time zone where the same offset from UTC
4758
- # applies. The period of time is bounded at at least one end, either having a
4759
- # start transition, end transition or both start and end transitions.
4760
- class TZInfo::TransitionsTimezonePeriod < ::TZInfo::TimezonePeriod
4761
- # Initializes a {TransitionsTimezonePeriod}.
4762
- #
4763
- # At least one of `start_transition` and `end_transition` must be specified.
4764
- #
4765
- # @param start_transition [TimezoneTransition] the transition that defines
4766
- # the start of the period, or `nil` if the start is unbounded.
4767
- # @param end_transition [TimezoneTransition] the transition that defines the
4768
- # end of the period, or `nil` if the end is unbounded.
4769
- # @raise [ArgumentError] if both `start_transition` and `end_transition` are
4770
- # `nil`.
4771
- # @return [TransitionsTimezonePeriod] a new instance of TransitionsTimezonePeriod
4772
- def initialize(start_transition, end_transition); end
4773
-
4774
- # Determines if this {TransitionsTimezonePeriod} is equal to another
4775
- # instance.
4776
- #
4777
- # @param p [Object] the instance to test for equality.
4778
- # @return [Boolean] `true` if `p` is a {TransitionsTimezonePeriod} with the
4779
- # same {offset}, {start_transition} and {end_transition}, otherwise
4780
- # `false`.
4781
- def ==(p); end
4782
-
4783
- # @return [TimezoneTransition] the transition that defines the end of this
4784
- # {TimezonePeriod} (`nil` if the end is unbounded).
4785
- def end_transition; end
4786
-
4787
- # Determines if this {TransitionsTimezonePeriod} is equal to another
4788
- # instance.
4789
- #
4790
- # @param p [Object] the instance to test for equality.
4791
- # @return [Boolean] `true` if `p` is a {TransitionsTimezonePeriod} with the
4792
- # same {offset}, {start_transition} and {end_transition}, otherwise
4793
- # `false`.
4794
- def eql?(p); end
4795
-
4796
- # @return [Integer] a hash based on {start_transition} and {end_transition}.
4797
- def hash; end
4798
-
4799
- # @return [String] the internal object state as a programmer-readable
4800
- # `String`.
4801
- def inspect; end
4802
-
4803
- # @return [TimezoneTransition] the transition that defines the start of this
4804
- # {TimezonePeriod} (`nil` if the start is unbounded).
4805
- def start_transition; end
4806
- end
4807
-
4808
- # An implementation of {StringDeduper} using the `String#-@` method where
4809
- # that method performs deduplication (Ruby 2.5 and later).
4810
- #
4811
- # Note that this is slightly different to the plain {StringDeduper}
4812
- # implementation. In this implementation, frozen literal strings are already
4813
- # in the pool and are candidates for being returned, even when passed
4814
- # another equal frozen non-literal string. {StringDeduper} will always
4815
- # return frozen strings.
4816
- #
4817
- # There are also differences in encoding handling. This implementation will
4818
- # treat strings with different encodings as different strings.
4819
- # {StringDeduper} will treat strings with the compatible encodings as the
4820
- # same string.
4821
- #
4822
- # @private
4823
- class TZInfo::UnaryMinusGlobalStringDeduper
4824
- # @param string [String] the string to deduplicate.
4825
- # @return [bool] `string` if it is frozen, otherwise a frozen, possibly
4826
- # pre-existing copy of `string`.
4827
- def dedupe(string); end
4828
- end
4829
-
4830
- # {UnknownTimezone} is raised when calling methods on an instance of
4831
- # {Timezone} that was created directly. To obtain {Timezone} instances the
4832
- # {Timezone.get} method should be used instead.
4833
- class TZInfo::UnknownTimezone < ::StandardError; end
4834
-
4835
- # Object#untaint is deprecated in Ruby >= 2.7 and will be removed in 3.2.
4836
- # UntaintExt adds a refinement to make Object#untaint a no-op and avoid the
4837
- # warning.
4838
- #
4839
- # @private
4840
- module TZInfo::UntaintExt; end
4841
-
4842
- # The TZInfo version number.
4843
- TZInfo::VERSION = T.let(T.unsafe(nil), String)
4844
-
4845
- # The {WithOffset} module is included in {TimeWithOffset},
4846
- # {DateTimeWithOffset} and {TimestampWithOffset}. It provides an override for
4847
- # the {strftime} method that handles expanding the `%Z` directive according to
4848
- # the {TimezoneOffset#abbreviation abbreviation} of the {TimezoneOffset}
4849
- # associated with a local time.
4850
- module TZInfo::WithOffset
4851
- # Overrides the `Time`, `DateTime` or {Timestamp} version of `strftime`,
4852
- # replacing `%Z` with the {TimezoneOffset#abbreviation abbreviation} of the
4853
- # associated {TimezoneOffset}. If there is no associated offset, `%Z` is
4854
- # expanded by the base class instead.
4855
- #
4856
- # All the format directives handled by the base class are supported.
4857
- #
4858
- # @param format [String] the format string.
4859
- # @raise [ArgumentError] if `format` is `nil`.
4860
- # @return [String] the formatted time.
4861
- def strftime(format); end
4862
-
4863
- protected
4864
-
4865
- # Performs a calculation if there is an associated {TimezoneOffset}.
4866
- #
4867
- # @param result [Object] a result value that can be manipulated by the block
4868
- # if there is an associated {TimezoneOffset}.
4869
- # @private
4870
- # @return [Object] the result of the block if there is an associated
4871
- # {TimezoneOffset}, otherwise the `result` parameter.
4872
- # @yield [period, result] if there is an associated {TimezoneOffset}, the
4873
- # block is yielded to in order to calculate the method result.
4874
- # @yieldparam period [TimezoneOffset] the associated {TimezoneOffset}.
4875
- # @yieldparam result [Object] the `result` parameter.
4876
- # @yieldreturn [Object] the result of the calculation performed if there is
4877
- # an associated {TimezoneOffset}.
4878
- def if_timezone_offset(result = T.unsafe(nil)); end
4879
- end