tzinfo 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of tzinfo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES.md +11 -0
- data/README.md +2 -2
- data/lib/tzinfo/country.rb +17 -1
- data/lib/tzinfo/timezone.rb +6 -5
- data/lib/tzinfo/zoneinfo_data_source.rb +57 -30
- data/test/tc_data_source.rb +26 -0
- data/test/tc_timezone_melbourne.rb +40 -40
- data/test/tc_zoneinfo_data_source.rb +151 -14
- data/test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb +2 -2
- data/test/tzinfo-data/tzinfo/data/indexes/countries.rb +116 -116
- data/test/tzinfo-data/tzinfo/data/indexes/timezones.rb +15 -13
- data/test/tzinfo-data/tzinfo/data/version.rb +1 -1
- data/test/zoneinfo/Australia/Melbourne +0 -0
- data/test/zoneinfo/iso3166.tab +6 -6
- data/test/zoneinfo/zone.tab +25 -38
- data/test/zoneinfo/zone1970.tab +369 -0
- data/tzinfo.gemspec +1 -1
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ebc85eb68af0647a8989ba7cb104b24100ef198
|
4
|
+
data.tar.gz: a2fdbcd5b2c456658ef15e7cedea229a66259a03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96a612b4835747ab4a3990195c1d6ff0e8fbed4905091e0380fc0b8fb64f4635a5f2cdf1a4deb4d0e3983e64a346c8afae2b063d1f53a4a5fddda4950b1eaf11
|
7
|
+
data.tar.gz: 59611995417725d20c591824e40b09df9325c39fb0161744228876effb6d263776cf12e9e209fa5380207e017fc38dd49a960c7f8582243c3982745ee1c3e37c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
Version 1.2.2 - 8-Aug-2014
|
2
|
+
--------------------------
|
3
|
+
|
4
|
+
* Fix an error with duplicates being returned by Timezone#all_country_zones
|
5
|
+
and Timezone#all_country_zone_identifiers when used with tzinfo-data
|
6
|
+
v1.2014.6 or later.
|
7
|
+
* Use the zone1970.tab file for country timezone data if it is found in the
|
8
|
+
zoneinfo directory (and fallback to zone.tab if not). zone1970.tab was added
|
9
|
+
in tzdata 2014f. zone.tab is now deprecated.
|
10
|
+
|
11
|
+
|
1
12
|
Version 1.2.1 - 1-Jun-2014
|
2
13
|
--------------------------
|
3
14
|
|
data/README.md
CHANGED
@@ -91,8 +91,8 @@ The current local time in a `Timezone` can be obtained with the
|
|
91
91
|
now = tz.now
|
92
92
|
|
93
93
|
All methods in TZInfo that operate on a time can be used with either `Time` or
|
94
|
-
`DateTime` instances or with
|
95
|
-
`Time#to_i`). The type of the values returned will match the
|
94
|
+
`DateTime` instances or with Integer timestamps (i.e. as returned by
|
95
|
+
`Time#to_i`). The type of the values returned will match the type passed in.
|
96
96
|
|
97
97
|
A list of all the available timezone identifiers can be obtained using the
|
98
98
|
`TZInfo::Timezone.all_identifiers` method. `TZInfo::Timezone.all` can be called
|
data/lib/tzinfo/country.rb
CHANGED
@@ -102,6 +102,11 @@ module TZInfo
|
|
102
102
|
#
|
103
103
|
# 1. makes some geographical sense, and
|
104
104
|
# 2. puts the most populous zones first, where that does not contradict 1.
|
105
|
+
#
|
106
|
+
# Returned zone identifiers may refer to cities and regions outside of the
|
107
|
+
# country. This will occur if the zone covers multiple countries. Any zones
|
108
|
+
# referring to a city or region in a different country will be listed after
|
109
|
+
# those relating to this country.
|
105
110
|
def zone_identifiers
|
106
111
|
@info.zone_identifiers
|
107
112
|
end
|
@@ -114,6 +119,11 @@ module TZInfo
|
|
114
119
|
#
|
115
120
|
# 1. makes some geographical sense, and
|
116
121
|
# 2. puts the most populous zones first, where that does not contradict 1.
|
122
|
+
#
|
123
|
+
# Identifiers of the zones returned may refer to cities and regions outside
|
124
|
+
# of the country. This will occur if the zone covers multiple countries. Any
|
125
|
+
# zones referring to a city or region in a different country will be listed
|
126
|
+
# after those relating to this country.
|
117
127
|
def zones
|
118
128
|
zone_identifiers.collect {|id|
|
119
129
|
Timezone.get_proxy(id)
|
@@ -126,6 +136,11 @@ module TZInfo
|
|
126
136
|
#
|
127
137
|
# 1. makes some geographical sense, and
|
128
138
|
# 2. puts the most populous zones first, where that does not contradict 1.
|
139
|
+
#
|
140
|
+
# Identifiers and descriptions of the zones returned may refer to cities and
|
141
|
+
# regions outside of the country. This will occur if the zone covers
|
142
|
+
# multiple countries. Any zones referring to a city or region in a different
|
143
|
+
# country will be listed after those relating to this country.
|
129
144
|
def zone_info
|
130
145
|
@info.zones
|
131
146
|
end
|
@@ -166,7 +181,8 @@ module TZInfo
|
|
166
181
|
def setup(info)
|
167
182
|
@info = info
|
168
183
|
end
|
169
|
-
|
184
|
+
|
185
|
+
# Initializes @@countries.
|
170
186
|
def self.init_countries
|
171
187
|
@@countries = ThreadSafe::Cache.new
|
172
188
|
end
|
data/lib/tzinfo/timezone.rb
CHANGED
@@ -167,9 +167,9 @@ module TZInfo
|
|
167
167
|
# Returns TimezoneProxy objects to avoid the overhead of loading Timezone
|
168
168
|
# definitions until a conversion is actually required.
|
169
169
|
def self.all_country_zones
|
170
|
-
Country.all_codes.inject([])
|
170
|
+
Country.all_codes.inject([]) do |zones,country|
|
171
171
|
zones += Country.get(country).zones
|
172
|
-
|
172
|
+
end.uniq
|
173
173
|
end
|
174
174
|
|
175
175
|
# Returns all the zone identifiers defined for all Countries. This is not the
|
@@ -177,9 +177,9 @@ module TZInfo
|
|
177
177
|
# 'Etc/GMT'). You can obtain a Timezone instance for a given identifier
|
178
178
|
# with the get method.
|
179
179
|
def self.all_country_zone_identifiers
|
180
|
-
Country.all_codes.inject([])
|
180
|
+
Country.all_codes.inject([]) do |zones,country|
|
181
181
|
zones += Country.get(country).zone_identifiers
|
182
|
-
|
182
|
+
end.uniq
|
183
183
|
end
|
184
184
|
|
185
185
|
# Returns all US Timezone instances. A shortcut for
|
@@ -624,11 +624,12 @@ module TZInfo
|
|
624
624
|
identifiers.collect {|identifier| get_proxy(identifier)}
|
625
625
|
end
|
626
626
|
|
627
|
-
# Returns the current DataSource
|
627
|
+
# Returns the current DataSource.
|
628
628
|
def self.data_source
|
629
629
|
DataSource.get
|
630
630
|
end
|
631
631
|
|
632
|
+
# Raises an UnknownTimezone exception.
|
632
633
|
def raise_unknown_timezone
|
633
634
|
raise UnknownTimezone, 'TZInfo::Timezone constructed directly'
|
634
635
|
end
|
@@ -9,14 +9,14 @@ module TZInfo
|
|
9
9
|
# A ZoneinfoDirectoryNotFound exception is raised if no valid zoneinfo
|
10
10
|
# directory could be found when checking the paths listed in
|
11
11
|
# ZoneinfoDataSource.search_path. A valid zoneinfo directory is one that
|
12
|
-
# contains
|
13
|
-
# timezone
|
12
|
+
# contains timezone files, a country code index file named iso3166.tab and a
|
13
|
+
# timezone index file named zone1970.tab or zone.tab.
|
14
14
|
class ZoneinfoDirectoryNotFound < StandardError
|
15
15
|
end
|
16
16
|
|
17
17
|
# A DataSource that loads data from a 'zoneinfo' directory containing
|
18
|
-
# compiled "TZif" version
|
19
|
-
#
|
18
|
+
# compiled "TZif" version 3 (or earlier) files in addition to iso3166.tab and
|
19
|
+
# zone1970.tab or zone.tab index files.
|
20
20
|
#
|
21
21
|
# To have TZInfo load the system zoneinfo files, call TZInfo::DataSource.set
|
22
22
|
# as follows:
|
@@ -141,21 +141,22 @@ module TZInfo
|
|
141
141
|
# If zoneinfo_dir is specified, it will be checked and used as the source
|
142
142
|
# of zoneinfo files.
|
143
143
|
#
|
144
|
-
# The directory must contain iso3166.tab and
|
145
|
-
# either
|
146
|
-
#
|
147
|
-
# the case on Solaris.
|
144
|
+
# The directory must contain a file named iso3166.tab and a file named
|
145
|
+
# either zone1970.tab or zone.tab. These may either be included in the root
|
146
|
+
# of the directory or in a 'tab' sub-directory and named 'country.tab' and
|
147
|
+
# 'zone_sun.tab' respectively (as is the case on Solaris.
|
148
148
|
#
|
149
149
|
# Additionally, the path to iso3166.tab can be overridden using the
|
150
150
|
# alternate_iso3166_tab_path parameter.
|
151
151
|
#
|
152
|
-
# InvalidZoneinfoDirectory will be raised if the iso3166.tab and
|
153
|
-
# files cannot be found using the zoneinfo_dir and
|
154
|
-
# parameters.
|
152
|
+
# InvalidZoneinfoDirectory will be raised if the iso3166.tab and
|
153
|
+
# zone1970.tab or zone.tab files cannot be found using the zoneinfo_dir and
|
154
|
+
# alternate_iso3166_tab_path parameters.
|
155
155
|
#
|
156
156
|
# If zoneinfo_dir is not specified or nil, the paths referenced in
|
157
157
|
# search_path are searched in order to find a valid zoneinfo directory
|
158
|
-
# (one that contains zone.tab and iso3166.tab files as
|
158
|
+
# (one that contains zone1970.tab or zone.tab and iso3166.tab files as
|
159
|
+
# above).
|
159
160
|
#
|
160
161
|
# The paths referenced in alternate_iso3166_tab_search_path are also
|
161
162
|
# searched to find an iso3166.tab file if one of the searched zoneinfo
|
@@ -168,7 +169,7 @@ module TZInfo
|
|
168
169
|
iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(zoneinfo_dir, alternate_iso3166_tab_path)
|
169
170
|
|
170
171
|
unless iso3166_tab_path && zone_tab_path
|
171
|
-
raise InvalidZoneinfoDirectory, "#{zoneinfo_dir} is not a directory or doesn't contain iso3166.tab and zone.tab
|
172
|
+
raise InvalidZoneinfoDirectory, "#{zoneinfo_dir} is not a directory or doesn't contain a iso3166.tab file and a zone1970.tab or zone.tab file."
|
172
173
|
end
|
173
174
|
|
174
175
|
@zoneinfo_dir = zoneinfo_dir
|
@@ -277,7 +278,8 @@ module TZInfo
|
|
277
278
|
end
|
278
279
|
|
279
280
|
# Validates a zoneinfo directory and returns the paths to the iso3166.tab
|
280
|
-
# and zone.tab files if valid. If the directory is not
|
281
|
+
# and zone1970.tab or zone.tab files if valid. If the directory is not
|
282
|
+
# valid, returns nil.
|
281
283
|
#
|
282
284
|
# The path to the iso3166.tab file may be overriden by passing in a path.
|
283
285
|
# This is treated as either absolute or relative to the current working
|
@@ -287,11 +289,11 @@ module TZInfo
|
|
287
289
|
if iso3166_tab_path
|
288
290
|
return nil unless File.file?(iso3166_tab_path)
|
289
291
|
else
|
290
|
-
iso3166_tab_path = resolve_tab_path(path, 'iso3166.tab', 'country.tab')
|
292
|
+
iso3166_tab_path = resolve_tab_path(path, ['iso3166.tab'], 'country.tab')
|
291
293
|
return nil unless iso3166_tab_path
|
292
294
|
end
|
293
295
|
|
294
|
-
zone_tab_path = resolve_tab_path(path, 'zone.tab', 'zone_sun.tab')
|
296
|
+
zone_tab_path = resolve_tab_path(path, ['zone1970.tab', 'zone.tab'], 'zone_sun.tab')
|
295
297
|
return nil unless zone_tab_path
|
296
298
|
|
297
299
|
[iso3166_tab_path, zone_tab_path]
|
@@ -300,11 +302,13 @@ module TZInfo
|
|
300
302
|
end
|
301
303
|
end
|
302
304
|
|
303
|
-
# Attempts to resolve the path to a tab file given its standard
|
305
|
+
# Attempts to resolve the path to a tab file given its standard names and
|
304
306
|
# tab sub-directory name (as used on Solaris).
|
305
|
-
def resolve_tab_path(zoneinfo_path,
|
306
|
-
|
307
|
-
|
307
|
+
def resolve_tab_path(zoneinfo_path, standard_names, tab_name)
|
308
|
+
standard_names.each do |standard_name|
|
309
|
+
path = File.join(zoneinfo_path, standard_name)
|
310
|
+
return path if File.file?(path)
|
311
|
+
end
|
308
312
|
|
309
313
|
path = File.join(zoneinfo_path, 'tab', tab_name)
|
310
314
|
return path if File.file?(path)
|
@@ -372,8 +376,8 @@ module TZInfo
|
|
372
376
|
end
|
373
377
|
end
|
374
378
|
|
375
|
-
# Uses the iso3166.tab and zone.tab files to build an index
|
376
|
-
# available countries and their timezones.
|
379
|
+
# Uses the iso3166.tab and zone1970.tab or zone.tab files to build an index
|
380
|
+
# of the available countries and their timezones.
|
377
381
|
def load_country_index(iso3166_tab_path, zone_tab_path)
|
378
382
|
|
379
383
|
# Handle standard 3 to 4 column zone.tab files as well as the 4 to 5
|
@@ -390,6 +394,19 @@ module TZInfo
|
|
390
394
|
# Since the last column is optional in both formats, testing for the
|
391
395
|
# Solaris format is done in two passes. The first pass identifies if there
|
392
396
|
# are any lines using 5 columns.
|
397
|
+
|
398
|
+
|
399
|
+
# The first column is allowed to be a comma separated list of country
|
400
|
+
# codes, as used in zone1970.tab (introduced in tzdata 2014f).
|
401
|
+
#
|
402
|
+
# The first country code in the comma-separated list is the country that
|
403
|
+
# contains the city the zone identifer is based on. The first country
|
404
|
+
# code on each line is considered to be primary with the others
|
405
|
+
# secondary.
|
406
|
+
#
|
407
|
+
# The zones for each country are ordered primary first, then secondary.
|
408
|
+
# Within the primary and secondary groups, the zones are ordered by their
|
409
|
+
# order in the file.
|
393
410
|
|
394
411
|
file_is_5_column = false
|
395
412
|
zone_tab = []
|
@@ -398,8 +415,8 @@ module TZInfo
|
|
398
415
|
file.each_line do |line|
|
399
416
|
line.chomp!
|
400
417
|
|
401
|
-
if line =~ /\A([A-Z]{2})\t(?:([+\-])(\d{2})(\d{2})([+\-])(\d{3})(\d{2})|([+\-])(\d{2})(\d{2})(\d{2})([+\-])(\d{3})(\d{2})(\d{2}))\t([^\t]+)(?:\t([^\t]+))?(?:\t([^\t]+))?\z/
|
402
|
-
|
418
|
+
if line =~ /\A([A-Z]{2}(?:,[A-Z]{2})*)\t(?:([+\-])(\d{2})(\d{2})([+\-])(\d{3})(\d{2})|([+\-])(\d{2})(\d{2})(\d{2})([+\-])(\d{3})(\d{2})(\d{2}))\t([^\t]+)(?:\t([^\t]+))?(?:\t([^\t]+))?\z/
|
419
|
+
codes = $1
|
403
420
|
|
404
421
|
if $2
|
405
422
|
latitude = dms_to_rational($2, $3, $4)
|
@@ -415,17 +432,25 @@ module TZInfo
|
|
415
432
|
|
416
433
|
file_is_5_column = true if column5
|
417
434
|
|
418
|
-
zone_tab << [
|
435
|
+
zone_tab << [codes.split(','), zone_identifier, latitude, longitude, column4, column5]
|
419
436
|
end
|
420
437
|
end
|
421
438
|
end
|
422
439
|
|
423
|
-
|
440
|
+
primary_zones = {}
|
441
|
+
secondary_zones = {}
|
424
442
|
|
425
|
-
zone_tab.each do |
|
443
|
+
zone_tab.each do |codes, zone_identifier, latitude, longitude, column4, column5|
|
426
444
|
description = file_is_5_column ? column5 : column4
|
427
|
-
|
428
|
-
|
445
|
+
country_timezone = CountryTimezone.new(zone_identifier, latitude, longitude, description)
|
446
|
+
|
447
|
+
# codes will always have at least one element
|
448
|
+
|
449
|
+
(primary_zones[codes.first] ||= []) << country_timezone
|
450
|
+
|
451
|
+
codes[1..-1].each do |code|
|
452
|
+
(secondary_zones[code] ||= []) << country_timezone
|
453
|
+
end
|
429
454
|
end
|
430
455
|
|
431
456
|
countries = {}
|
@@ -441,7 +466,9 @@ module TZInfo
|
|
441
466
|
if line =~ /\A([A-Z]{2})(?:\t[A-Z]{3}\t[0-9]{3})?\t(.+)\z/
|
442
467
|
code = $1
|
443
468
|
name = $2
|
444
|
-
|
469
|
+
zones = (primary_zones[code] || []) + (secondary_zones[code] || [])
|
470
|
+
|
471
|
+
countries[code] = ZoneinfoCountryInfo.new(code, name, zones)
|
445
472
|
end
|
446
473
|
end
|
447
474
|
end
|
data/test/tc_data_source.rb
CHANGED
@@ -127,6 +127,20 @@ class TCDataSource < Minitest::Test
|
|
127
127
|
assert_equal(dir, data_source.zoneinfo_dir)
|
128
128
|
end
|
129
129
|
end
|
130
|
+
|
131
|
+
def test_set_standard_zoneinfo_search_zone1970
|
132
|
+
Dir.mktmpdir('tzinfo_test_dir') do |dir|
|
133
|
+
FileUtils.touch(File.join(dir, 'iso3166.tab'))
|
134
|
+
FileUtils.touch(File.join(dir, 'zone1970.tab'))
|
135
|
+
|
136
|
+
ZoneinfoDataSource.search_path = [dir]
|
137
|
+
|
138
|
+
DataSource.set(:zoneinfo)
|
139
|
+
data_source = DataSource.get
|
140
|
+
assert_kind_of(ZoneinfoDataSource, data_source)
|
141
|
+
assert_equal(dir, data_source.zoneinfo_dir)
|
142
|
+
end
|
143
|
+
end
|
130
144
|
|
131
145
|
def test_set_standard_zoneinfo_explicit
|
132
146
|
Dir.mktmpdir('tzinfo_test_dir') do |dir|
|
@@ -139,6 +153,18 @@ class TCDataSource < Minitest::Test
|
|
139
153
|
assert_equal(dir, data_source.zoneinfo_dir)
|
140
154
|
end
|
141
155
|
end
|
156
|
+
|
157
|
+
def test_set_standard_zoneinfo_explicit_zone1970
|
158
|
+
Dir.mktmpdir('tzinfo_test_dir') do |dir|
|
159
|
+
FileUtils.touch(File.join(dir, 'iso3166.tab'))
|
160
|
+
FileUtils.touch(File.join(dir, 'zone.tab'))
|
161
|
+
|
162
|
+
DataSource.set(:zoneinfo, dir)
|
163
|
+
data_source = DataSource.get
|
164
|
+
assert_kind_of(ZoneinfoDataSource, data_source)
|
165
|
+
assert_equal(dir, data_source.zoneinfo_dir)
|
166
|
+
end
|
167
|
+
end
|
142
168
|
|
143
169
|
def test_set_standard_zoneinfo_explicit_alternate_iso3166
|
144
170
|
Dir.mktmpdir('tzinfo_test_dir') do |dir|
|
@@ -4,10 +4,10 @@ include TZInfo
|
|
4
4
|
|
5
5
|
class TCTimezoneMelbourne < Minitest::Test
|
6
6
|
def test_2004
|
7
|
-
#Australia/Melbourne Sat Mar 27 15:59:59 2004 UTC = Sun Mar 28 02:59:59 2004
|
8
|
-
#Australia/Melbourne Sat Mar 27 16:00:00 2004 UTC = Sun Mar 28 02:00:00 2004
|
9
|
-
#Australia/Melbourne Sat Oct 30 15:59:59 2004 UTC = Sun Oct 31 01:59:59 2004
|
10
|
-
#Australia/Melbourne Sat Oct 30 16:00:00 2004 UTC = Sun Oct 31 03:00:00 2004
|
7
|
+
#Australia/Melbourne Sat Mar 27 15:59:59 2004 UTC = Sun Mar 28 02:59:59 2004 AEDT isdst=1 gmtoff=39600
|
8
|
+
#Australia/Melbourne Sat Mar 27 16:00:00 2004 UTC = Sun Mar 28 02:00:00 2004 AEST isdst=0 gmtoff=36000
|
9
|
+
#Australia/Melbourne Sat Oct 30 15:59:59 2004 UTC = Sun Oct 31 01:59:59 2004 AEST isdst=0 gmtoff=36000
|
10
|
+
#Australia/Melbourne Sat Oct 30 16:00:00 2004 UTC = Sun Oct 31 03:00:00 2004 AEDT isdst=1 gmtoff=39600
|
11
11
|
|
12
12
|
tz = Timezone.get('Australia/Melbourne')
|
13
13
|
assert_equal(DateTime.new(2004,3,28,2,59,59), tz.utc_to_local(DateTime.new(2004,3,27,15,59,59)))
|
@@ -25,17 +25,17 @@ class TCTimezoneMelbourne < Minitest::Test
|
|
25
25
|
assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,10,31,2,0,0)) }
|
26
26
|
assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,3,28,2,0,0)) }
|
27
27
|
|
28
|
-
assert_equal(:
|
29
|
-
assert_equal(:
|
30
|
-
assert_equal(:
|
31
|
-
assert_equal(:
|
28
|
+
assert_equal(:AEDT, tz.period_for_utc(DateTime.new(2004,3,27,15,59,59)).zone_identifier)
|
29
|
+
assert_equal(:AEST, tz.period_for_utc(DateTime.new(2004,3,27,16,0,0)).zone_identifier)
|
30
|
+
assert_equal(:AEST, tz.period_for_utc(DateTime.new(2004,10,30,15,59,59)).zone_identifier)
|
31
|
+
assert_equal(:AEDT, tz.period_for_utc(DateTime.new(2004,10,30,16,0,0)).zone_identifier)
|
32
32
|
|
33
|
-
assert_equal(:
|
34
|
-
assert_equal(:
|
35
|
-
assert_equal(:
|
36
|
-
assert_equal(:
|
37
|
-
assert_equal(:
|
38
|
-
assert_equal(:
|
33
|
+
assert_equal(:AEDT, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), true).zone_identifier)
|
34
|
+
assert_equal(:AEST, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), false).zone_identifier)
|
35
|
+
assert_equal(:AEDT, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), true).zone_identifier)
|
36
|
+
assert_equal(:AEST, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), false).zone_identifier)
|
37
|
+
assert_equal(:AEST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).zone_identifier)
|
38
|
+
assert_equal(:AEDT, tz.period_for_local(DateTime.new(2004,10,31,3,0,0)).zone_identifier)
|
39
39
|
|
40
40
|
assert_equal(39600, tz.period_for_utc(DateTime.new(2004,3,27,15,59,59)).utc_total_offset)
|
41
41
|
assert_equal(36000, tz.period_for_utc(DateTime.new(2004,3,27,16,0,0)).utc_total_offset)
|
@@ -52,14 +52,14 @@ class TCTimezoneMelbourne < Minitest::Test
|
|
52
52
|
transitions = tz.transitions_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0))
|
53
53
|
assert_equal(2, transitions.length)
|
54
54
|
assert_equal(TimeOrDateTime.new(DateTime.new(2004,3,27,16,0,0)), transitions[0].at)
|
55
|
-
assert_equal(TimezoneOffset.new(36000, 3600, :
|
56
|
-
assert_equal(TimezoneOffset.new(36000, 0, :
|
55
|
+
assert_equal(TimezoneOffset.new(36000, 3600, :AEDT), transitions[0].previous_offset)
|
56
|
+
assert_equal(TimezoneOffset.new(36000, 0, :AEST), transitions[0].offset)
|
57
57
|
assert_equal(TimeOrDateTime.new(DateTime.new(2004,10,30,16,0,0)), transitions[1].at)
|
58
|
-
assert_equal(TimezoneOffset.new(36000, 0, :
|
59
|
-
assert_equal(TimezoneOffset.new(36000, 3600, :
|
58
|
+
assert_equal(TimezoneOffset.new(36000, 0, :AEST), transitions[1].previous_offset)
|
59
|
+
assert_equal(TimezoneOffset.new(36000, 3600, :AEDT), transitions[1].offset)
|
60
60
|
|
61
61
|
offsets = tz.offsets_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0))
|
62
|
-
assert_array_same_items([TimezoneOffset.new(36000, 0, :
|
62
|
+
assert_array_same_items([TimezoneOffset.new(36000, 0, :AEST), TimezoneOffset.new(36000, 3600, :AEDT)], offsets)
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_1942
|
@@ -68,10 +68,10 @@ class TCTimezoneMelbourne < Minitest::Test
|
|
68
68
|
# because it relates to the year 1942.
|
69
69
|
|
70
70
|
if !DataSource.get.kind_of?(ZoneinfoDataSource) || RubyCoreSupport.time_supports_negative
|
71
|
-
#Australia/Melbourne Sat Mar 28 14:59:59 1942 UTC = Sun Mar 29 01:59:59 1942
|
72
|
-
#Australia/Melbourne Sat Mar 28 15:00:00 1942 UTC = Sun Mar 29 01:00:00 1942
|
73
|
-
#Australia/Melbourne Sat Sep 26 15:59:59 1942 UTC = Sun Sep 27 01:59:59 1942
|
74
|
-
#Australia/Melbourne Sat Sep 26 16:00:00 1942 UTC = Sun Sep 27 03:00:00 1942
|
71
|
+
#Australia/Melbourne Sat Mar 28 14:59:59 1942 UTC = Sun Mar 29 01:59:59 1942 AEDT isdst=1 gmtoff=39600
|
72
|
+
#Australia/Melbourne Sat Mar 28 15:00:00 1942 UTC = Sun Mar 29 01:00:00 1942 AEST isdst=0 gmtoff=36000
|
73
|
+
#Australia/Melbourne Sat Sep 26 15:59:59 1942 UTC = Sun Sep 27 01:59:59 1942 AEST isdst=0 gmtoff=36000
|
74
|
+
#Australia/Melbourne Sat Sep 26 16:00:00 1942 UTC = Sun Sep 27 03:00:00 1942 AEDT isdst=1 gmtoff=39600
|
75
75
|
|
76
76
|
tz = Timezone.get('Australia/Melbourne')
|
77
77
|
assert_equal(DateTime.new(1942,3,29,1,59,59), tz.utc_to_local(DateTime.new(1942,3,28,14,59,59)))
|
@@ -89,17 +89,17 @@ class TCTimezoneMelbourne < Minitest::Test
|
|
89
89
|
assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(1942,9,27,2,0,0)) }
|
90
90
|
assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(1942,3,29,1,0,0)) }
|
91
91
|
|
92
|
-
assert_equal(:
|
93
|
-
assert_equal(:
|
94
|
-
assert_equal(:
|
95
|
-
assert_equal(:
|
92
|
+
assert_equal(:AEDT, tz.period_for_utc(DateTime.new(1942,3,28,14,59,59)).zone_identifier)
|
93
|
+
assert_equal(:AEST, tz.period_for_utc(DateTime.new(1942,3,28,15,0,0)).zone_identifier)
|
94
|
+
assert_equal(:AEST, tz.period_for_utc(DateTime.new(1942,9,26,15,59,59)).zone_identifier)
|
95
|
+
assert_equal(:AEDT, tz.period_for_utc(DateTime.new(1942,9,26,16,0,0)).zone_identifier)
|
96
96
|
|
97
|
-
assert_equal(:
|
98
|
-
assert_equal(:
|
99
|
-
assert_equal(:
|
100
|
-
assert_equal(:
|
101
|
-
assert_equal(:
|
102
|
-
assert_equal(:
|
97
|
+
assert_equal(:AEDT, tz.period_for_local(DateTime.new(1942,3,29,1,59,59), true).zone_identifier)
|
98
|
+
assert_equal(:AEST, tz.period_for_local(DateTime.new(1942,3,29,1,59,59), false).zone_identifier)
|
99
|
+
assert_equal(:AEDT, tz.period_for_local(DateTime.new(1942,3,29,1,0,0), true).zone_identifier)
|
100
|
+
assert_equal(:AEST, tz.period_for_local(DateTime.new(1942,3,29,1,0,0), false).zone_identifier)
|
101
|
+
assert_equal(:AEST, tz.period_for_local(DateTime.new(1942,9,27,1,59,59)).zone_identifier)
|
102
|
+
assert_equal(:AEDT, tz.period_for_local(DateTime.new(1942,9,27,3,0,0)).zone_identifier)
|
103
103
|
|
104
104
|
assert_equal(39600, tz.period_for_utc(DateTime.new(1942,3,28,14,59,59)).utc_total_offset)
|
105
105
|
assert_equal(36000, tz.period_for_utc(DateTime.new(1942,3,28,15,0,0)).utc_total_offset)
|
@@ -116,20 +116,20 @@ class TCTimezoneMelbourne < Minitest::Test
|
|
116
116
|
transitions = tz.transitions_up_to(DateTime.new(1943,1,1,0,0,0), DateTime.new(1942,1,1,0,0,0))
|
117
117
|
assert_equal(2, transitions.length)
|
118
118
|
assert_equal(TimeOrDateTime.new(DateTime.new(1942,3,28,15,0,0)), transitions[0].at)
|
119
|
-
assert_equal(TimezoneOffset.new(36000, 3600, :
|
120
|
-
assert_equal(TimezoneOffset.new(36000, 0, :
|
119
|
+
assert_equal(TimezoneOffset.new(36000, 3600, :AEDT), transitions[0].previous_offset)
|
120
|
+
assert_equal(TimezoneOffset.new(36000, 0, :AEST), transitions[0].offset)
|
121
121
|
assert_equal(TimeOrDateTime.new(DateTime.new(1942,9,26,16,0,0)), transitions[1].at)
|
122
|
-
assert_equal(TimezoneOffset.new(36000, 0, :
|
123
|
-
assert_equal(TimezoneOffset.new(36000, 3600, :
|
122
|
+
assert_equal(TimezoneOffset.new(36000, 0, :AEST), transitions[1].previous_offset)
|
123
|
+
assert_equal(TimezoneOffset.new(36000, 3600, :AEDT), transitions[1].offset)
|
124
124
|
|
125
125
|
offsets = tz.offsets_up_to(DateTime.new(1943,1,1,0,0,0), DateTime.new(1942,1,1,0,0,0))
|
126
|
-
assert_array_same_items([TimezoneOffset.new(36000, 0, :
|
126
|
+
assert_array_same_items([TimezoneOffset.new(36000, 0, :AEST), TimezoneOffset.new(36000, 3600, :AEDT)], offsets)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_time_boundary
|
131
|
-
#Australia/Melbourne Sat Mar 25 15:00:00 1944 UTC = Sun Mar 26 01:00:00 1944
|
132
|
-
#Australia/Melbourne Sat Oct 30 15:59:59 1971 UTC = Sun Oct 31 01:59:59 1971
|
131
|
+
#Australia/Melbourne Sat Mar 25 15:00:00 1944 UTC = Sun Mar 26 01:00:00 1944 AEST isdst=0 gmtoff=36000
|
132
|
+
#Australia/Melbourne Sat Oct 30 15:59:59 1971 UTC = Sun Oct 31 01:59:59 1971 AEST isdst=0 gmtoff=36000
|
133
133
|
|
134
134
|
tz = Timezone.get('Australia/Melbourne')
|
135
135
|
assert_equal(DateTime.new(1970,1,1,10,0,0), tz.utc_to_local(DateTime.new(1970,1,1,0,0,0)))
|