tzinfo 1.2.3 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.yardopts +3 -0
  5. data/CHANGES.md +501 -372
  6. data/LICENSE +13 -13
  7. data/README.md +368 -113
  8. data/lib/tzinfo.rb +64 -29
  9. data/lib/tzinfo/country.rb +141 -129
  10. data/lib/tzinfo/country_timezone.rb +71 -101
  11. data/lib/tzinfo/data_source.rb +389 -144
  12. data/lib/tzinfo/data_sources.rb +8 -0
  13. data/lib/tzinfo/data_sources/constant_offset_data_timezone_info.rb +56 -0
  14. data/lib/tzinfo/data_sources/country_info.rb +42 -0
  15. data/lib/tzinfo/data_sources/data_timezone_info.rb +91 -0
  16. data/lib/tzinfo/data_sources/linked_timezone_info.rb +33 -0
  17. data/lib/tzinfo/data_sources/ruby_data_source.rb +143 -0
  18. data/lib/tzinfo/data_sources/timezone_info.rb +47 -0
  19. data/lib/tzinfo/data_sources/transitions_data_timezone_info.rb +214 -0
  20. data/lib/tzinfo/data_sources/zoneinfo_data_source.rb +575 -0
  21. data/lib/tzinfo/data_sources/zoneinfo_reader.rb +286 -0
  22. data/lib/tzinfo/data_timezone.rb +33 -47
  23. data/lib/tzinfo/datetime_with_offset.rb +153 -0
  24. data/lib/tzinfo/format1.rb +10 -0
  25. data/lib/tzinfo/format1/country_definer.rb +17 -0
  26. data/lib/tzinfo/format1/country_index_definition.rb +64 -0
  27. data/lib/tzinfo/format1/timezone_definer.rb +64 -0
  28. data/lib/tzinfo/format1/timezone_definition.rb +39 -0
  29. data/lib/tzinfo/format1/timezone_index_definition.rb +77 -0
  30. data/lib/tzinfo/format2.rb +10 -0
  31. data/lib/tzinfo/format2/country_definer.rb +68 -0
  32. data/lib/tzinfo/format2/country_index_definer.rb +68 -0
  33. data/lib/tzinfo/format2/country_index_definition.rb +46 -0
  34. data/lib/tzinfo/format2/timezone_definer.rb +94 -0
  35. data/lib/tzinfo/format2/timezone_definition.rb +73 -0
  36. data/lib/tzinfo/format2/timezone_index_definer.rb +45 -0
  37. data/lib/tzinfo/format2/timezone_index_definition.rb +55 -0
  38. data/lib/tzinfo/info_timezone.rb +26 -21
  39. data/lib/tzinfo/linked_timezone.rb +33 -52
  40. data/lib/tzinfo/offset_timezone_period.rb +42 -0
  41. data/lib/tzinfo/string_deduper.rb +118 -0
  42. data/lib/tzinfo/time_with_offset.rb +128 -0
  43. data/lib/tzinfo/timestamp.rb +548 -0
  44. data/lib/tzinfo/timestamp_with_offset.rb +85 -0
  45. data/lib/tzinfo/timezone.rb +989 -498
  46. data/lib/tzinfo/timezone_offset.rb +90 -57
  47. data/lib/tzinfo/timezone_period.rb +155 -197
  48. data/lib/tzinfo/timezone_proxy.rb +71 -74
  49. data/lib/tzinfo/timezone_transition.rb +77 -99
  50. data/lib/tzinfo/transitions_timezone_period.rb +63 -0
  51. data/lib/tzinfo/untaint_ext.rb +18 -0
  52. data/lib/tzinfo/version.rb +7 -0
  53. data/lib/tzinfo/with_offset.rb +61 -0
  54. metadata +63 -120
  55. metadata.gz.sig +0 -0
  56. data/Rakefile +0 -107
  57. data/lib/tzinfo/country_index_definition.rb +0 -31
  58. data/lib/tzinfo/country_info.rb +0 -42
  59. data/lib/tzinfo/data_timezone_info.rb +0 -55
  60. data/lib/tzinfo/linked_timezone_info.rb +0 -26
  61. data/lib/tzinfo/offset_rationals.rb +0 -77
  62. data/lib/tzinfo/ruby_core_support.rb +0 -146
  63. data/lib/tzinfo/ruby_country_info.rb +0 -70
  64. data/lib/tzinfo/ruby_data_source.rb +0 -136
  65. data/lib/tzinfo/time_or_datetime.rb +0 -333
  66. data/lib/tzinfo/timezone_definition.rb +0 -36
  67. data/lib/tzinfo/timezone_index_definition.rb +0 -54
  68. data/lib/tzinfo/timezone_info.rb +0 -30
  69. data/lib/tzinfo/timezone_transition_definition.rb +0 -101
  70. data/lib/tzinfo/transition_data_timezone_info.rb +0 -274
  71. data/lib/tzinfo/zoneinfo_country_info.rb +0 -35
  72. data/lib/tzinfo/zoneinfo_data_source.rb +0 -487
  73. data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -294
  74. data/test/tc_country.rb +0 -236
  75. data/test/tc_country_index_definition.rb +0 -69
  76. data/test/tc_country_info.rb +0 -16
  77. data/test/tc_country_timezone.rb +0 -161
  78. data/test/tc_data_source.rb +0 -218
  79. data/test/tc_data_timezone.rb +0 -99
  80. data/test/tc_data_timezone_info.rb +0 -18
  81. data/test/tc_info_timezone.rb +0 -34
  82. data/test/tc_linked_timezone.rb +0 -155
  83. data/test/tc_linked_timezone_info.rb +0 -23
  84. data/test/tc_offset_rationals.rb +0 -23
  85. data/test/tc_ruby_core_support.rb +0 -168
  86. data/test/tc_ruby_country_info.rb +0 -80
  87. data/test/tc_ruby_data_source.rb +0 -143
  88. data/test/tc_time_or_datetime.rb +0 -639
  89. data/test/tc_timezone.rb +0 -1350
  90. data/test/tc_timezone_definition.rb +0 -113
  91. data/test/tc_timezone_index_definition.rb +0 -73
  92. data/test/tc_timezone_info.rb +0 -11
  93. data/test/tc_timezone_london.rb +0 -143
  94. data/test/tc_timezone_melbourne.rb +0 -142
  95. data/test/tc_timezone_new_york.rb +0 -142
  96. data/test/tc_timezone_offset.rb +0 -126
  97. data/test/tc_timezone_period.rb +0 -548
  98. data/test/tc_timezone_proxy.rb +0 -127
  99. data/test/tc_timezone_transition.rb +0 -352
  100. data/test/tc_timezone_transition_definition.rb +0 -284
  101. data/test/tc_timezone_utc.rb +0 -27
  102. data/test/tc_transition_data_timezone_info.rb +0 -423
  103. data/test/tc_zoneinfo_country_info.rb +0 -64
  104. data/test/tc_zoneinfo_data_source.rb +0 -1193
  105. data/test/tc_zoneinfo_timezone_info.rb +0 -1128
  106. data/test/test_utils.rb +0 -134
  107. data/test/ts_all.rb +0 -7
  108. data/test/ts_all_ruby.rb +0 -5
  109. data/test/ts_all_zoneinfo.rb +0 -7
  110. data/test/tzinfo-data/tzinfo/data.rb +0 -8
  111. data/test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb +0 -89
  112. data/test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb +0 -315
  113. data/test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb +0 -218
  114. data/test/tzinfo-data/tzinfo/data/definitions/EST.rb +0 -19
  115. data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb +0 -21
  116. data/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb +0 -21
  117. data/test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb +0 -21
  118. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb +0 -261
  119. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb +0 -186
  120. data/test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb +0 -321
  121. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb +0 -265
  122. data/test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb +0 -220
  123. data/test/tzinfo-data/tzinfo/data/definitions/UTC.rb +0 -16
  124. data/test/tzinfo-data/tzinfo/data/indexes/countries.rb +0 -927
  125. data/test/tzinfo-data/tzinfo/data/indexes/timezones.rb +0 -596
  126. data/test/tzinfo-data/tzinfo/data/version.rb +0 -14
  127. data/test/zoneinfo/America/Argentina/Buenos_Aires +0 -0
  128. data/test/zoneinfo/America/New_York +0 -0
  129. data/test/zoneinfo/Australia/Melbourne +0 -0
  130. data/test/zoneinfo/EST +0 -0
  131. data/test/zoneinfo/Etc/UTC +0 -0
  132. data/test/zoneinfo/Europe/Amsterdam +0 -0
  133. data/test/zoneinfo/Europe/Andorra +0 -0
  134. data/test/zoneinfo/Europe/London +0 -0
  135. data/test/zoneinfo/Europe/Paris +0 -0
  136. data/test/zoneinfo/Europe/Prague +0 -0
  137. data/test/zoneinfo/Factory +0 -0
  138. data/test/zoneinfo/iso3166.tab +0 -275
  139. data/test/zoneinfo/posix/Europe/London +0 -0
  140. data/test/zoneinfo/posixrules +0 -0
  141. data/test/zoneinfo/right/Europe/London +0 -0
  142. data/test/zoneinfo/zone.tab +0 -439
  143. data/test/zoneinfo/zone1970.tab +0 -369
  144. data/tzinfo.gemspec +0 -21
@@ -1,333 +0,0 @@
1
- require 'date'
2
- require 'rational' unless defined?(Rational)
3
- require 'time'
4
-
5
- module TZInfo
6
- # Used by TZInfo internally to represent either a Time, DateTime or
7
- # an Integer timestamp (seconds since 1970-01-01 00:00:00).
8
- class TimeOrDateTime
9
- include Comparable
10
-
11
- # Constructs a new TimeOrDateTime. timeOrDateTime can be a Time, DateTime
12
- # or Integer. If using a Time or DateTime, any time zone information
13
- # is ignored.
14
- #
15
- # Integer timestamps must be within the range supported by Time on the
16
- # platform being used.
17
- def initialize(timeOrDateTime)
18
- @time = nil
19
- @datetime = nil
20
- @timestamp = nil
21
-
22
- if timeOrDateTime.is_a?(Time)
23
- @time = timeOrDateTime
24
-
25
- # Avoid using the slower Rational class unless necessary.
26
- nsec = RubyCoreSupport.time_nsec(@time)
27
- usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)
28
-
29
- @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc?
30
- @orig = @time
31
- elsif timeOrDateTime.is_a?(DateTime)
32
- @datetime = timeOrDateTime
33
- @datetime = @datetime.new_offset(0) unless @datetime.offset == 0
34
- @orig = @datetime
35
- else
36
- @timestamp = timeOrDateTime.to_i
37
-
38
- if !RubyCoreSupport.time_supports_64bit && (@timestamp > 2147483647 || @timestamp < -2147483648 || (@timestamp < 0 && !RubyCoreSupport.time_supports_negative))
39
- raise RangeError, 'Timestamp is outside the supported range of Time on this platform'
40
- end
41
-
42
- @orig = @timestamp
43
- end
44
- end
45
-
46
- # Returns the time as a Time.
47
- #
48
- # When converting from a DateTime, the result is truncated to microsecond
49
- # precision.
50
- def to_time
51
- # Thread-safety: It is possible that the value of @time may be
52
- # calculated multiple times in concurrently executing threads. It is not
53
- # worth the overhead of locking to ensure that @time is only
54
- # calculated once.
55
-
56
- unless @time
57
- if @timestamp
58
- @time = Time.at(@timestamp).utc
59
- else
60
- @time = Time.utc(year, mon, mday, hour, min, sec, usec)
61
- end
62
- end
63
-
64
- @time
65
- end
66
-
67
- # Returns the time as a DateTime.
68
- #
69
- # When converting from a Time, the result is truncated to microsecond
70
- # precision.
71
- def to_datetime
72
- # Thread-safety: It is possible that the value of @datetime may be
73
- # calculated multiple times in concurrently executing threads. It is not
74
- # worth the overhead of locking to ensure that @datetime is only
75
- # calculated once.
76
-
77
- unless @datetime
78
- # Avoid using Rational unless necessary.
79
- u = usec
80
- s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000)
81
- @datetime = RubyCoreSupport.datetime_new(year, mon, mday, hour, min, s)
82
- end
83
-
84
- @datetime
85
- end
86
-
87
- # Returns the time as an integer timestamp.
88
- def to_i
89
- # Thread-safety: It is possible that the value of @timestamp may be
90
- # calculated multiple times in concurrently executing threads. It is not
91
- # worth the overhead of locking to ensure that @timestamp is only
92
- # calculated once.
93
-
94
- unless @timestamp
95
- @timestamp = to_time.to_i
96
- end
97
-
98
- @timestamp
99
- end
100
-
101
- # Returns the time as the original time passed to new.
102
- def to_orig
103
- @orig
104
- end
105
-
106
- # Returns a string representation of the TimeOrDateTime.
107
- def to_s
108
- if @orig.is_a?(Time)
109
- "Time: #{@orig.to_s}"
110
- elsif @orig.is_a?(DateTime)
111
- "DateTime: #{@orig.to_s}"
112
- else
113
- "Timestamp: #{@orig.to_s}"
114
- end
115
- end
116
-
117
- # Returns internal object state as a programmer-readable string.
118
- def inspect
119
- "#<#{self.class}: #{@orig.inspect}>"
120
- end
121
-
122
- # Returns the year.
123
- def year
124
- if @time
125
- @time.year
126
- elsif @datetime
127
- @datetime.year
128
- else
129
- to_time.year
130
- end
131
- end
132
-
133
- # Returns the month of the year (1..12).
134
- def mon
135
- if @time
136
- @time.mon
137
- elsif @datetime
138
- @datetime.mon
139
- else
140
- to_time.mon
141
- end
142
- end
143
- alias :month :mon
144
-
145
- # Returns the day of the month (1..n).
146
- def mday
147
- if @time
148
- @time.mday
149
- elsif @datetime
150
- @datetime.mday
151
- else
152
- to_time.mday
153
- end
154
- end
155
- alias :day :mday
156
-
157
- # Returns the hour of the day (0..23).
158
- def hour
159
- if @time
160
- @time.hour
161
- elsif @datetime
162
- @datetime.hour
163
- else
164
- to_time.hour
165
- end
166
- end
167
-
168
- # Returns the minute of the hour (0..59).
169
- def min
170
- if @time
171
- @time.min
172
- elsif @datetime
173
- @datetime.min
174
- else
175
- to_time.min
176
- end
177
- end
178
-
179
- # Returns the second of the minute (0..60). (60 for a leap second).
180
- def sec
181
- if @time
182
- @time.sec
183
- elsif @datetime
184
- @datetime.sec
185
- else
186
- to_time.sec
187
- end
188
- end
189
-
190
- # Returns the number of microseconds for the time.
191
- def usec
192
- if @time
193
- @time.usec
194
- elsif @datetime
195
- # Ruby 1.8 has sec_fraction (of which the documentation says
196
- # 'I do NOT recommend you to use this method'). sec_fraction no longer
197
- # exists in Ruby 1.9.
198
-
199
- # Calculate the sec_fraction from the day_fraction.
200
- ((@datetime.day_fraction - OffsetRationals.rational_for_offset(@datetime.hour * 3600 + @datetime.min * 60 + @datetime.sec)) * 86400000000).to_i
201
- else
202
- 0
203
- end
204
- end
205
-
206
- # Compares this TimeOrDateTime with another Time, DateTime, timestamp
207
- # (Integer) or TimeOrDateTime. Returns -1, 0 or +1 depending
208
- # whether the receiver is less than, equal to, or greater than
209
- # timeOrDateTime.
210
- #
211
- # Returns nil if the passed in timeOrDateTime is not comparable with
212
- # TimeOrDateTime instances.
213
- #
214
- # Comparisons involving a DateTime will be performed using DateTime#<=>.
215
- # Comparisons that don't involve a DateTime, but include a Time will be
216
- # performed with Time#<=>. Otherwise comparisons will be performed with
217
- # Integer#<=>.
218
- def <=>(timeOrDateTime)
219
- return nil unless timeOrDateTime.is_a?(TimeOrDateTime) ||
220
- timeOrDateTime.is_a?(Time) ||
221
- timeOrDateTime.is_a?(DateTime) ||
222
- timeOrDateTime.respond_to?(:to_i)
223
-
224
- unless timeOrDateTime.is_a?(TimeOrDateTime)
225
- timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)
226
- end
227
-
228
- orig = timeOrDateTime.to_orig
229
-
230
- if @orig.is_a?(DateTime) || orig.is_a?(DateTime)
231
- # If either is a DateTime, assume it is there for a reason
232
- # (i.e. for its larger range of acceptable values on 32-bit systems).
233
- to_datetime <=> timeOrDateTime.to_datetime
234
- elsif @orig.is_a?(Time) || orig.is_a?(Time)
235
- to_time <=> timeOrDateTime.to_time
236
- else
237
- to_i <=> timeOrDateTime.to_i
238
- end
239
- end
240
-
241
- # Adds a number of seconds to the TimeOrDateTime. Returns a new
242
- # TimeOrDateTime, preserving what the original constructed type was.
243
- # If the original type is a Time and the resulting calculation goes out of
244
- # range for Times, then an exception will be raised by the Time class.
245
- def +(seconds)
246
- if seconds == 0
247
- self
248
- else
249
- if @orig.is_a?(DateTime)
250
- TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))
251
- else
252
- # + defined for Time and Integer
253
- TimeOrDateTime.new(@orig + seconds)
254
- end
255
- end
256
- end
257
-
258
- # Subtracts a number of seconds from the TimeOrDateTime. Returns a new
259
- # TimeOrDateTime, preserving what the original constructed type was.
260
- # If the original type is a Time and the resulting calculation goes out of
261
- # range for Times, then an exception will be raised by the Time class.
262
- def -(seconds)
263
- self + (-seconds)
264
- end
265
-
266
- # Similar to the + operator, but converts to a DateTime based TimeOrDateTime
267
- # where the Time or Integer timestamp to go out of the allowed range for a
268
- # Time, converts to a DateTime based TimeOrDateTime.
269
- #
270
- # Note that the range of Time varies based on the platform.
271
- def add_with_convert(seconds)
272
- if seconds == 0
273
- self
274
- else
275
- if @orig.is_a?(DateTime)
276
- TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds))
277
- else
278
- # A Time or timestamp.
279
- result = to_i + seconds
280
-
281
- if ((result > 2147483647 || result < -2147483648) && !RubyCoreSupport.time_supports_64bit) || (result < 0 && !RubyCoreSupport.time_supports_negative)
282
- result = TimeOrDateTime.new(to_datetime + OffsetRationals.rational_for_offset(seconds))
283
- else
284
- result = TimeOrDateTime.new(@orig + seconds)
285
- end
286
- end
287
- end
288
- end
289
-
290
- # Returns true if todt represents the same time and was originally
291
- # constructed with the same type (DateTime, Time or timestamp) as this
292
- # TimeOrDateTime.
293
- def eql?(todt)
294
- todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig)
295
- end
296
-
297
- # Returns a hash of this TimeOrDateTime.
298
- def hash
299
- @orig.hash
300
- end
301
-
302
- # If no block is given, returns a TimeOrDateTime wrapping the given
303
- # timeOrDateTime. If a block is specified, a TimeOrDateTime is constructed
304
- # and passed to the block. The result of the block must be a TimeOrDateTime.
305
- #
306
- # The result of the block will be converted to the type of the originally
307
- # passed in timeOrDateTime and then returned as the result of wrap.
308
- #
309
- # timeOrDateTime can be a Time, DateTime, timestamp (Integer) or
310
- # TimeOrDateTime. If a TimeOrDateTime is passed in, no new TimeOrDateTime
311
- # will be constructed and the value passed to wrap will be used when
312
- # calling the block.
313
- def self.wrap(timeOrDateTime)
314
- t = timeOrDateTime.is_a?(TimeOrDateTime) ? timeOrDateTime : TimeOrDateTime.new(timeOrDateTime)
315
-
316
- if block_given?
317
- t = yield t
318
-
319
- if timeOrDateTime.is_a?(TimeOrDateTime)
320
- t
321
- elsif timeOrDateTime.is_a?(Time)
322
- t.to_time
323
- elsif timeOrDateTime.is_a?(DateTime)
324
- t.to_datetime
325
- else
326
- t.to_i
327
- end
328
- else
329
- t
330
- end
331
- end
332
- end
333
- end
@@ -1,36 +0,0 @@
1
- module TZInfo
2
-
3
- # TimezoneDefinition is included into Timezone definition modules.
4
- # TimezoneDefinition provides the methods for defining timezones.
5
- #
6
- # @private
7
- module TimezoneDefinition #:nodoc:
8
- # Add class methods to the includee.
9
- def self.append_features(base)
10
- super
11
- base.extend(ClassMethods)
12
- end
13
-
14
- # Class methods for inclusion.
15
- #
16
- # @private
17
- module ClassMethods #:nodoc:
18
- # Returns and yields a TransitionDataTimezoneInfo object to define a
19
- # timezone.
20
- def timezone(identifier)
21
- yield @timezone = TransitionDataTimezoneInfo.new(identifier)
22
- end
23
-
24
- # Defines a linked timezone.
25
- def linked_timezone(identifier, link_to_identifier)
26
- @timezone = LinkedTimezoneInfo.new(identifier, link_to_identifier)
27
- end
28
-
29
- # Returns the last TimezoneInfo to be defined with timezone or
30
- # linked_timezone.
31
- def get
32
- @timezone
33
- end
34
- end
35
- end
36
- end
@@ -1,54 +0,0 @@
1
- module TZInfo
2
- # The timezone index file includes TimezoneIndexDefinition which provides
3
- # methods used to define timezones in the index.
4
- #
5
- # @private
6
- module TimezoneIndexDefinition #:nodoc:
7
- # Add class methods to the includee and initialize class instance variables.
8
- def self.append_features(base)
9
- super
10
- base.extend(ClassMethods)
11
- base.instance_eval do
12
- @timezones = []
13
- @data_timezones = []
14
- @linked_timezones = []
15
- end
16
- end
17
-
18
- # Class methods for inclusion.
19
- #
20
- # @private
21
- module ClassMethods #:nodoc:
22
- # Defines a timezone based on data.
23
- def timezone(identifier)
24
- @timezones << identifier
25
- @data_timezones << identifier
26
- end
27
-
28
- # Defines a timezone which is a link to another timezone.
29
- def linked_timezone(identifier)
30
- @timezones << identifier
31
- @linked_timezones << identifier
32
- end
33
-
34
- # Returns a frozen array containing the identifiers of all the timezones.
35
- # Identifiers appear in the order they were defined in the index.
36
- def timezones
37
- @timezones.freeze
38
- end
39
-
40
- # Returns a frozen array containing the identifiers of all data timezones.
41
- # Identifiers appear in the order they were defined in the index.
42
- def data_timezones
43
- @data_timezones.freeze
44
- end
45
-
46
- # Returns a frozen array containing the identifiers of all linked
47
- # timezones. Identifiers appear in the order they were defined in
48
- # the index.
49
- def linked_timezones
50
- @linked_timezones.freeze
51
- end
52
- end
53
- end
54
- end
@@ -1,30 +0,0 @@
1
- module TZInfo
2
- # Represents a timezone defined by a data source.
3
- class TimezoneInfo
4
-
5
- # The timezone identifier.
6
- attr_reader :identifier
7
-
8
- # Constructs a new TimezoneInfo with an identifier.
9
- def initialize(identifier)
10
- @identifier = identifier
11
- end
12
-
13
- # Returns internal object state as a programmer-readable string.
14
- def inspect
15
- "#<#{self.class}: #@identifier>"
16
- end
17
-
18
- # Constructs a Timezone instance for the timezone represented by this
19
- # TimezoneInfo.
20
- def create_timezone
21
- raise_not_implemented('create_timezone')
22
- end
23
-
24
- private
25
-
26
- def raise_not_implemented(method_name)
27
- raise NotImplementedError, "Subclasses must override #{method_name}"
28
- end
29
- end
30
- end