tzinfo 1.1.0 → 1.2.0
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 +33 -0
- data/LICENSE +1 -1
- data/README.md +36 -31
- data/Rakefile +17 -23
- data/lib/tzinfo.rb +0 -22
- data/lib/tzinfo/country.rb +3 -22
- data/lib/tzinfo/country_index_definition.rb +0 -22
- data/lib/tzinfo/country_info.rb +0 -22
- data/lib/tzinfo/country_timezone.rb +46 -31
- data/lib/tzinfo/data_source.rb +7 -24
- data/lib/tzinfo/data_timezone.rb +7 -22
- data/lib/tzinfo/data_timezone_info.rb +0 -22
- data/lib/tzinfo/info_timezone.rb +0 -22
- data/lib/tzinfo/linked_timezone.rb +7 -22
- data/lib/tzinfo/linked_timezone_info.rb +0 -22
- data/lib/tzinfo/offset_rationals.rb +0 -22
- data/lib/tzinfo/ruby_core_support.rb +14 -22
- data/lib/tzinfo/ruby_country_info.rb +3 -25
- data/lib/tzinfo/ruby_data_source.rb +1 -23
- data/lib/tzinfo/time_or_datetime.rb +13 -27
- data/lib/tzinfo/timezone.rb +51 -23
- data/lib/tzinfo/timezone_definition.rb +0 -22
- data/lib/tzinfo/timezone_index_definition.rb +0 -22
- data/lib/tzinfo/timezone_info.rb +0 -22
- data/lib/tzinfo/timezone_offset.rb +0 -22
- data/lib/tzinfo/timezone_period.rb +1 -23
- data/lib/tzinfo/timezone_proxy.rb +6 -23
- data/lib/tzinfo/timezone_transition.rb +2 -24
- data/lib/tzinfo/timezone_transition_definition.rb +1 -23
- data/lib/tzinfo/transition_data_timezone_info.rb +0 -22
- data/lib/tzinfo/zoneinfo_country_info.rb +1 -23
- data/lib/tzinfo/zoneinfo_data_source.rb +177 -61
- data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -22
- data/test/tc_country.rb +6 -24
- data/test/tc_country_index_definition.rb +1 -23
- data/test/tc_country_info.rb +1 -23
- data/test/tc_country_timezone.rb +82 -62
- data/test/tc_data_source.rb +22 -24
- data/test/tc_data_timezone.rb +12 -24
- data/test/tc_data_timezone_info.rb +1 -23
- data/test/tc_info_timezone.rb +1 -23
- data/test/tc_linked_timezone.rb +37 -24
- data/test/tc_linked_timezone_info.rb +1 -23
- data/test/tc_offset_rationals.rb +1 -23
- data/test/tc_ruby_core_support.rb +84 -33
- data/test/tc_ruby_country_info.rb +5 -27
- data/test/tc_ruby_data_source.rb +1 -23
- data/test/tc_time_or_datetime.rb +44 -36
- data/test/tc_timezone.rb +32 -48
- data/test/tc_timezone_definition.rb +1 -23
- data/test/tc_timezone_index_definition.rb +1 -23
- data/test/tc_timezone_info.rb +1 -23
- data/test/tc_timezone_london.rb +1 -23
- data/test/tc_timezone_melbourne.rb +1 -23
- data/test/tc_timezone_new_york.rb +1 -23
- data/test/tc_timezone_offset.rb +1 -23
- data/test/tc_timezone_period.rb +5 -27
- data/test/tc_timezone_proxy.rb +34 -28
- data/test/tc_timezone_transition.rb +1 -23
- data/test/tc_timezone_transition_definition.rb +1 -23
- data/test/tc_timezone_utc.rb +1 -23
- data/test/tc_transition_data_timezone_info.rb +3 -25
- data/test/tc_zoneinfo_country_info.rb +13 -35
- data/test/tc_zoneinfo_data_source.rb +358 -34
- data/test/tc_zoneinfo_timezone_info.rb +3 -27
- data/test/test_utils.rb +26 -30
- data/test/ts_all.rb +0 -22
- data/test/ts_all_ruby.rb +0 -22
- data/test/ts_all_zoneinfo.rb +0 -22
- data/test/tzinfo-data/tzinfo/data.rb +0 -22
- data/test/tzinfo-data/tzinfo/data/version.rb +0 -22
- data/tzinfo.gemspec +2 -2
- metadata +80 -80
- metadata.gz.sig +1 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e48380a40bf9c0b26cf7b925cbe0eef6d198130c
|
4
|
+
data.tar.gz: d2fbd737fd05d0e56d8835ab85f1de51338971a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a631f6a845f0547389417def1880190f16d7d761d75dcbf940c9c15cc96b884f3f30f5afce7ac76ac64361ae020158615096fa7e48897e2b635e5249827be8a
|
7
|
+
data.tar.gz: e06467b2b159ce423db5d2ef55c5eab9f2ee3c7f912b58268ea160d1047da576af46613378aa6a2b7d579ca6a4365edb036597f7fa9e85a5261e4768578862c5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
Version 1.2.0 - 26-May-2014
|
2
|
+
---------------------------
|
3
|
+
|
4
|
+
* Raise the minimum supported Ruby version to 1.8.7.
|
5
|
+
* Support loading system zoneinfo data on FreeBSD, OpenBSD and Solaris.
|
6
|
+
Resolves #15.
|
7
|
+
* Add canonical_identifier and canonical_zone methods to Timezone. Resolves #16.
|
8
|
+
* Add a link to a DataSourceNotFound help page in the TZInfo::DataSourceNotFound
|
9
|
+
exception message.
|
10
|
+
* Load iso3166.tab and zone.tab files as UTF-8.
|
11
|
+
* Fix Timezone#local_to_utc returning local Time instances on systems using UTC
|
12
|
+
as the local time zone. Resolves #13.
|
13
|
+
* Fix == methods raising an exception when passed an instance of a different
|
14
|
+
class by making <=> return nil if passed a non-comparable argument.
|
15
|
+
* Eliminate "require 'rational'" warnings. Resolves #10.
|
16
|
+
* Eliminate "assigned but unused variable - info" warnings. Resolves #11.
|
17
|
+
* Switch to minitest v5 for unit tests. Resolves #18.
|
18
|
+
|
19
|
+
|
1
20
|
Version 1.1.0 - 25-Sep-2013
|
2
21
|
---------------------------
|
3
22
|
|
@@ -52,6 +71,20 @@ Version 1.0.0 - 2-Jun-2013
|
|
52
71
|
use other TimezonePeriod instance methods instead (issue #7655).
|
53
72
|
|
54
73
|
|
74
|
+
Version 0.3.39 (tzdata v2014a) - 9-Mar-2014
|
75
|
+
-------------------------------------------
|
76
|
+
|
77
|
+
* Updated to tzdata version 2014a
|
78
|
+
(http://mm.icann.org/pipermail/tz-announce/2014-March/000018.html).
|
79
|
+
|
80
|
+
|
81
|
+
Version 0.3.38 (tzdata v2013g) - 8-Oct-2013
|
82
|
+
-------------------------------------------
|
83
|
+
|
84
|
+
* Updated to tzdata version 2013g
|
85
|
+
(http://mm.icann.org/pipermail/tz-announce/2013-October/000015.html).
|
86
|
+
|
87
|
+
|
55
88
|
Version 0.3.37 (tzdata v2013b) - 11-Mar-2013
|
56
89
|
--------------------------------------------
|
57
90
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
TZInfo - Ruby Timezone Library
|
2
2
|
==============================
|
3
3
|
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/tzinfo.svg)](http://badge.fury.io/rb/tzinfo) [![Build Status](https://travis-ci.org/tzinfo/tzinfo.svg?branch=master)](https://travis-ci.org/tzinfo/tzinfo)
|
5
|
+
|
4
6
|
[TZInfo](http://tzinfo.github.io) provides daylight savings aware
|
5
7
|
transformations between times in different timezones.
|
6
8
|
|
@@ -17,17 +19,19 @@ TZInfo requires a source of timezone data. There are two built-in options:
|
|
17
19
|
[IANA Time Zone Database](http://www.iana.org/time-zones).
|
18
20
|
|
19
21
|
By default, TZInfo::Data will be used. If TZInfo::Data is not available (i.e.
|
20
|
-
if require 'tzinfo/data' fails), then TZInfo will search for a zoneinfo
|
22
|
+
if `require 'tzinfo/data'` fails), then TZInfo will search for a zoneinfo
|
21
23
|
directory instead (using the search path specified by
|
22
|
-
TZInfo::ZoneinfoDataSource::DEFAULT_SEARCH_PATH).
|
24
|
+
`TZInfo::ZoneinfoDataSource::DEFAULT_SEARCH_PATH`).
|
23
25
|
|
24
|
-
If no data source can be found, a TZInfo::DataSourceNotFound exception will be
|
25
|
-
raised when TZInfo is used.
|
26
|
+
If no data source can be found, a `TZInfo::DataSourceNotFound` exception will be
|
27
|
+
raised when TZInfo is used. Further information is available
|
28
|
+
[in the wiki](http://tzinfo.github.io/datasourcenotfound) to help with
|
29
|
+
resolving `TZInfo::DataSourceNotFound` errors.
|
26
30
|
|
27
31
|
The default data source selection can be overridden using
|
28
|
-
TZInfo::DataSource.set
|
32
|
+
`TZInfo::DataSource.set`.
|
29
33
|
|
30
|
-
Custom data sources can also be used. See TZInfo::DataSource.set for
|
34
|
+
Custom data sources can also be used. See `TZInfo::DataSource.set` for
|
31
35
|
further details.
|
32
36
|
|
33
37
|
|
@@ -48,24 +52,24 @@ Example Usage
|
|
48
52
|
-------------
|
49
53
|
|
50
54
|
The following code will obtain the America/New_York timezone (as an instance
|
51
|
-
of TZInfo::Timezone) and
|
55
|
+
of `TZInfo::Timezone`) and convert a time in UTC to local New York time:
|
52
56
|
|
53
57
|
require 'tzinfo'
|
54
58
|
|
55
59
|
tz = TZInfo::Timezone.get('America/New_York')
|
56
60
|
local = tz.utc_to_local(Time.utc(2005,8,29,15,35,0))
|
57
61
|
|
58
|
-
Note that the local Time returned will have a UTC timezone (local.zone will
|
59
|
-
return "UTC"). This is because the Ruby Time class only supports two timezones:
|
62
|
+
Note that the local Time returned will have a UTC timezone (`local.zone` will
|
63
|
+
return `"UTC"`). This is because the Ruby Time class only supports two timezones:
|
60
64
|
UTC and the current system local timezone.
|
61
65
|
|
62
|
-
To convert from a local time to UTC, the local_to_utc method can be used as
|
66
|
+
To convert from a local time to UTC, the `local_to_utc` method can be used as
|
63
67
|
follows:
|
64
68
|
|
65
69
|
utc = tz.local_to_utc(local)
|
66
70
|
|
67
71
|
Note that the timezone information of the local Time object is ignored (TZInfo
|
68
|
-
will just read the date and time and treat them as if there were in the
|
72
|
+
will just read the date and time and treat them as if there were in the `tz`
|
69
73
|
timezone). The following two lines will return the same result regardless of
|
70
74
|
the system's local timezone:
|
71
75
|
|
@@ -73,50 +77,51 @@ the system's local timezone:
|
|
73
77
|
tz.local_to_utc(Time.utc(2006,6,26,1,0,0))
|
74
78
|
|
75
79
|
To obtain information about the rules in force at a particular UTC or local
|
76
|
-
time, the TZInfo::Timezone.period_for_utc and
|
77
|
-
methods can be used. Both of these methods
|
78
|
-
objects. The following gets the identifier for
|
80
|
+
time, the `TZInfo::Timezone.period_for_utc` and
|
81
|
+
`TZInfo::Timezone.period_for_local` methods can be used. Both of these methods
|
82
|
+
return `TZInfo::TimezonePeriod` objects. The following gets the identifier for
|
83
|
+
the period (in this case EDT).
|
79
84
|
|
80
85
|
period = tz.period_for_utc(Time.utc(2005,8,29,15,35,0))
|
81
86
|
id = period.zone_identifier
|
82
87
|
|
83
|
-
The current local time in a Timezone can be obtained with the
|
84
|
-
TZInfo::Timezone#now method:
|
88
|
+
The current local time in a `Timezone` can be obtained with the
|
89
|
+
`TZInfo::Timezone#now` method:
|
85
90
|
|
86
91
|
now = tz.now
|
87
92
|
|
88
|
-
All methods in TZInfo that operate on a time can be used with either Time or
|
89
|
-
DateTime instances or with
|
90
|
-
The type of the values returned will match the the type passed in.
|
93
|
+
All methods in TZInfo that operate on a time can be used with either `Time` or
|
94
|
+
`DateTime` instances or with nteger timestamps (i.e. as returned by
|
95
|
+
`Time#to_i`). The type of the values returned will match the the type passed in.
|
91
96
|
|
92
|
-
A list of all the available
|
93
|
-
TZInfo::Timezone.all_identifiers method. TZInfo::Timezone.all can be called
|
94
|
-
to get an Array of all the TZInfo::Timezone instances.
|
97
|
+
A list of all the available timezone identifiers can be obtained using the
|
98
|
+
`TZInfo::Timezone.all_identifiers` method. `TZInfo::Timezone.all` can be called
|
99
|
+
to get an `Array` of all the `TZInfo::Timezone` instances.
|
95
100
|
|
96
101
|
Timezones can also be accessed by country (using an ISO 3166-1 alpha-2 country
|
97
|
-
code). The following code retrieves the TZInfo::Country instance representing
|
98
|
-
the USA (country code 'US') and then gets all the
|
102
|
+
code). The following code retrieves the `TZInfo::Country` instance representing
|
103
|
+
the USA (country code 'US') and then gets all the timezone identifiers used in
|
99
104
|
the USA.
|
100
105
|
|
101
106
|
us = TZInfo::Country.get('US')
|
102
107
|
timezones = us.zone_identifiers
|
103
108
|
|
104
|
-
The TZInfo::Country#zone_info method provides an additional description and
|
105
|
-
geographic location for each
|
109
|
+
The `TZInfo::Country#zone_info` method provides an additional description and
|
110
|
+
geographic location for each timezone in a country.
|
106
111
|
|
107
112
|
A list of all the available country codes can be obtained using the
|
108
|
-
TZInfo::Country.all_codes method. TZInfo::Country.all can be called to get
|
109
|
-
Array of all the Country instances.
|
113
|
+
`TZInfo::Country.all_codes` method. `TZInfo::Country.all` can be called to get
|
114
|
+
an `Array` of all the `Country` instances.
|
110
115
|
|
111
116
|
For further detail, please refer to the API documentation for the
|
112
|
-
TZInfo::Timezone and TZInfo::Country classes.
|
117
|
+
`TZInfo::Timezone` and `TZInfo::Country` classes.
|
113
118
|
|
114
119
|
|
115
120
|
Thread-Safety
|
116
121
|
-------------
|
117
122
|
|
118
|
-
The TZInfo::Country and TZInfo::Timezone classes are thread-safe. It is safe
|
119
|
-
use class and instance methods of TZInfo::Country and TZInfo::Timezone in
|
123
|
+
The `TZInfo::Country` and `TZInfo::Timezone` classes are thread-safe. It is safe
|
124
|
+
to use class and instance methods of `TZInfo::Country` and `TZInfo::Timezone` in
|
120
125
|
concurrently executing threads. Instances of both classes can be shared across
|
121
126
|
thread boundaries.
|
122
127
|
|
data/Rakefile
CHANGED
@@ -1,25 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2005-2013 Philip Ross
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
1
|
require 'rubygems'
|
24
2
|
require 'rubygems/package_task'
|
25
3
|
require 'fileutils'
|
@@ -53,7 +31,22 @@ class TZInfoPackageTask < Gem::PackageTask
|
|
53
31
|
end
|
54
32
|
end
|
55
33
|
|
56
|
-
|
34
|
+
def add_signing_key(spec)
|
35
|
+
# Attempt to find the private key and add options to sign the gem if found.
|
36
|
+
private_key_path = File.expand_path(File.join(BASE_DIR, '..', 'key', 'gem-private_key.pem'))
|
37
|
+
|
38
|
+
if File.exist?(private_key_path)
|
39
|
+
spec = spec.clone
|
40
|
+
spec.signing_key = private_key_path
|
41
|
+
spec.cert_chain = [File.join(BASE_DIR, 'gem-public_cert.pem')]
|
42
|
+
else
|
43
|
+
puts 'WARNING: Private key not found. Not signing gem file.'
|
44
|
+
end
|
45
|
+
|
46
|
+
spec
|
47
|
+
end
|
48
|
+
|
49
|
+
package_task = TZInfoPackageTask.new(add_signing_key(spec)) do |pkg|
|
57
50
|
pkg.need_zip = true
|
58
51
|
pkg.need_tar_gz = true
|
59
52
|
pkg.tar_command = '__tar_with_owner__'
|
@@ -99,6 +92,7 @@ end
|
|
99
92
|
def setup_tests(test_task, type)
|
100
93
|
test_task.libs = [File.join(BASE_DIR, 'lib')]
|
101
94
|
test_task.pattern = File.join(BASE_DIR, 'test', "ts_all_#{type}.rb")
|
95
|
+
test_task.warning = true
|
102
96
|
end
|
103
97
|
|
104
98
|
Rake::TestTask.new(:test_ruby) do |t|
|
data/lib/tzinfo.rb
CHANGED
@@ -1,25 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2005-2013 Philip Ross
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
1
|
# Top level module for TZInfo.
|
24
2
|
module TZInfo
|
25
3
|
end
|
data/lib/tzinfo/country.rb
CHANGED
@@ -1,25 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2005-2013 Philip Ross
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
1
|
require 'thread_safe'
|
24
2
|
|
25
3
|
module TZInfo
|
@@ -154,7 +132,10 @@ module TZInfo
|
|
154
132
|
|
155
133
|
# Compare two Countries based on their code. Returns -1 if c is less
|
156
134
|
# than self, 0 if c is equal to self and +1 if c is greater than self.
|
135
|
+
#
|
136
|
+
# Returns nil if c is not comparable with Country instances.
|
157
137
|
def <=>(c)
|
138
|
+
return nil unless c.is_a?(Country)
|
158
139
|
code <=> c.code
|
159
140
|
end
|
160
141
|
|
@@ -1,25 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2006-2013 Philip Ross
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
1
|
module TZInfo
|
24
2
|
# The country index file includes CountryIndexDefinition which provides
|
25
3
|
# a country method used to define each country in the index.
|
data/lib/tzinfo/country_info.rb
CHANGED
@@ -1,25 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2013 Philip Ross
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
1
|
module TZInfo
|
24
2
|
# Represents a country and references to its timezones as returned by a
|
25
3
|
# DataSource.
|
@@ -1,25 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2006-2013 Philip Ross
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in all
|
12
|
-
# copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#++
|
22
|
-
|
23
1
|
module TZInfo
|
24
2
|
# A Timezone within a Country. This contains extra information about the
|
25
3
|
# Timezone that is specific to the Country (a Timezone could be used by
|
@@ -33,19 +11,54 @@ module TZInfo
|
|
33
11
|
# Timezone.
|
34
12
|
attr_reader :description
|
35
13
|
|
14
|
+
class << self
|
15
|
+
# Creates a new CountryTimezone with a timezone identifier, latitude,
|
16
|
+
# longitude and description. The latitude and longitude are specified as
|
17
|
+
# rationals - a numerator and denominator. For performance reasons, the
|
18
|
+
# numerators and denominators must be specified in their lowest form.
|
19
|
+
#
|
20
|
+
# For use internally within TZInfo.
|
21
|
+
#
|
22
|
+
# @!visibility private
|
23
|
+
alias :new! :new
|
24
|
+
|
25
|
+
# Creates a new CountryTimezone with a timezone identifier, latitude,
|
26
|
+
# longitude and description. The latitude and longitude must be specified
|
27
|
+
# as instances of Rational.
|
28
|
+
#
|
29
|
+
# CountryTimezone instances should normally only be constructed when
|
30
|
+
# creating new DataSource implementations.
|
31
|
+
def new(identifier, latitude, longitude, description = nil)
|
32
|
+
super(identifier, latitude, nil, longitude, nil, description)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
36
|
# Creates a new CountryTimezone with a timezone identifier, latitude,
|
37
37
|
# longitude and description. The latitude and longitude are specified as
|
38
38
|
# rationals - a numerator and denominator. For performance reasons, the
|
39
39
|
# numerators and denominators must be specified in their lowest form.
|
40
40
|
#
|
41
|
-
#
|
41
|
+
# @!visibility private
|
42
42
|
def initialize(identifier, latitude_numerator, latitude_denominator,
|
43
43
|
longitude_numerator, longitude_denominator, description = nil) #:nodoc:
|
44
44
|
@identifier = identifier
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
|
46
|
+
if latitude_numerator.kind_of?(Rational)
|
47
|
+
@latitude = latitude_numerator
|
48
|
+
else
|
49
|
+
@latitude = nil
|
50
|
+
@latitude_numerator = latitude_numerator
|
51
|
+
@latitude_denominator = latitude_denominator
|
52
|
+
end
|
53
|
+
|
54
|
+
if longitude_numerator.kind_of?(Rational)
|
55
|
+
@longitude = longitude_numerator
|
56
|
+
else
|
57
|
+
@longitude = nil
|
58
|
+
@longitude_numerator = longitude_numerator
|
59
|
+
@longitude_denominator = longitude_denominator
|
60
|
+
end
|
61
|
+
|
49
62
|
@description = description
|
50
63
|
end
|
51
64
|
|
@@ -62,7 +75,7 @@ module TZInfo
|
|
62
75
|
|
63
76
|
# The latitude of this timezone in degrees as a Rational.
|
64
77
|
def latitude
|
65
|
-
# Thread-
|
78
|
+
# Thread-safety: It is possible that the value of @latitude may be
|
66
79
|
# calculated multiple times in concurrently executing threads. It is not
|
67
80
|
# worth the overhead of locking to ensure that @latitude is only
|
68
81
|
# calculated once.
|
@@ -71,7 +84,7 @@ module TZInfo
|
|
71
84
|
|
72
85
|
# The longitude of this timezone in degrees as a Rational.
|
73
86
|
def longitude
|
74
|
-
# Thread-
|
87
|
+
# Thread-safety: It is possible that the value of @longitude may be
|
75
88
|
# calculated multiple times in concurrently executing threads. It is not
|
76
89
|
# worth the overhead of locking to ensure that @longitude is only
|
77
90
|
# calculated once.
|
@@ -96,8 +109,10 @@ module TZInfo
|
|
96
109
|
|
97
110
|
# Returns a hash of this CountryTimezone.
|
98
111
|
def hash
|
99
|
-
@identifier.hash ^
|
100
|
-
@
|
112
|
+
@identifier.hash ^
|
113
|
+
(@latitude ? @latitude.numerator.hash ^ @latitude.denominator.hash : @latitude_numerator.hash ^ @latitude_denominator.hash) ^
|
114
|
+
(@longitude ? @longitude.numerator.hash ^ @longitude.denominator.hash : @longitude_numerator.hash ^ @longitude_denominator.hash) ^
|
115
|
+
@description.hash
|
101
116
|
end
|
102
117
|
|
103
118
|
# Returns internal object state as a programmer-readable string.
|