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.

Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGES.md +33 -0
  5. data/LICENSE +1 -1
  6. data/README.md +36 -31
  7. data/Rakefile +17 -23
  8. data/lib/tzinfo.rb +0 -22
  9. data/lib/tzinfo/country.rb +3 -22
  10. data/lib/tzinfo/country_index_definition.rb +0 -22
  11. data/lib/tzinfo/country_info.rb +0 -22
  12. data/lib/tzinfo/country_timezone.rb +46 -31
  13. data/lib/tzinfo/data_source.rb +7 -24
  14. data/lib/tzinfo/data_timezone.rb +7 -22
  15. data/lib/tzinfo/data_timezone_info.rb +0 -22
  16. data/lib/tzinfo/info_timezone.rb +0 -22
  17. data/lib/tzinfo/linked_timezone.rb +7 -22
  18. data/lib/tzinfo/linked_timezone_info.rb +0 -22
  19. data/lib/tzinfo/offset_rationals.rb +0 -22
  20. data/lib/tzinfo/ruby_core_support.rb +14 -22
  21. data/lib/tzinfo/ruby_country_info.rb +3 -25
  22. data/lib/tzinfo/ruby_data_source.rb +1 -23
  23. data/lib/tzinfo/time_or_datetime.rb +13 -27
  24. data/lib/tzinfo/timezone.rb +51 -23
  25. data/lib/tzinfo/timezone_definition.rb +0 -22
  26. data/lib/tzinfo/timezone_index_definition.rb +0 -22
  27. data/lib/tzinfo/timezone_info.rb +0 -22
  28. data/lib/tzinfo/timezone_offset.rb +0 -22
  29. data/lib/tzinfo/timezone_period.rb +1 -23
  30. data/lib/tzinfo/timezone_proxy.rb +6 -23
  31. data/lib/tzinfo/timezone_transition.rb +2 -24
  32. data/lib/tzinfo/timezone_transition_definition.rb +1 -23
  33. data/lib/tzinfo/transition_data_timezone_info.rb +0 -22
  34. data/lib/tzinfo/zoneinfo_country_info.rb +1 -23
  35. data/lib/tzinfo/zoneinfo_data_source.rb +177 -61
  36. data/lib/tzinfo/zoneinfo_timezone_info.rb +0 -22
  37. data/test/tc_country.rb +6 -24
  38. data/test/tc_country_index_definition.rb +1 -23
  39. data/test/tc_country_info.rb +1 -23
  40. data/test/tc_country_timezone.rb +82 -62
  41. data/test/tc_data_source.rb +22 -24
  42. data/test/tc_data_timezone.rb +12 -24
  43. data/test/tc_data_timezone_info.rb +1 -23
  44. data/test/tc_info_timezone.rb +1 -23
  45. data/test/tc_linked_timezone.rb +37 -24
  46. data/test/tc_linked_timezone_info.rb +1 -23
  47. data/test/tc_offset_rationals.rb +1 -23
  48. data/test/tc_ruby_core_support.rb +84 -33
  49. data/test/tc_ruby_country_info.rb +5 -27
  50. data/test/tc_ruby_data_source.rb +1 -23
  51. data/test/tc_time_or_datetime.rb +44 -36
  52. data/test/tc_timezone.rb +32 -48
  53. data/test/tc_timezone_definition.rb +1 -23
  54. data/test/tc_timezone_index_definition.rb +1 -23
  55. data/test/tc_timezone_info.rb +1 -23
  56. data/test/tc_timezone_london.rb +1 -23
  57. data/test/tc_timezone_melbourne.rb +1 -23
  58. data/test/tc_timezone_new_york.rb +1 -23
  59. data/test/tc_timezone_offset.rb +1 -23
  60. data/test/tc_timezone_period.rb +5 -27
  61. data/test/tc_timezone_proxy.rb +34 -28
  62. data/test/tc_timezone_transition.rb +1 -23
  63. data/test/tc_timezone_transition_definition.rb +1 -23
  64. data/test/tc_timezone_utc.rb +1 -23
  65. data/test/tc_transition_data_timezone_info.rb +3 -25
  66. data/test/tc_zoneinfo_country_info.rb +13 -35
  67. data/test/tc_zoneinfo_data_source.rb +358 -34
  68. data/test/tc_zoneinfo_timezone_info.rb +3 -27
  69. data/test/test_utils.rb +26 -30
  70. data/test/ts_all.rb +0 -22
  71. data/test/ts_all_ruby.rb +0 -22
  72. data/test/ts_all_zoneinfo.rb +0 -22
  73. data/test/tzinfo-data/tzinfo/data.rb +0 -22
  74. data/test/tzinfo-data/tzinfo/data/version.rb +0 -22
  75. data/tzinfo.gemspec +2 -2
  76. metadata +80 -80
  77. metadata.gz.sig +1 -3
@@ -1,25 +1,3 @@
1
- #--
2
- # Copyright (c) 2012-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'
24
2
 
25
3
  module TZInfo
@@ -81,6 +59,7 @@ module TZInfo
81
59
  # TZInfo::DataSource.set(:ruby)
82
60
  # TZInfo::DataSource.set(:zoneinfo)
83
61
  # TZInfo::DataSource.set(:zoneinfo, zoneinfo_dir)
62
+ # TZInfo::DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_tab_file)
84
63
  #
85
64
  # \DataSource.set(:zoneinfo) will automatically search for the zoneinfo
86
65
  # directory by checking the paths specified in
@@ -91,6 +70,11 @@ module TZInfo
91
70
  # directory as the data source. If the directory is not a valid zoneinfo
92
71
  # directory, an InvalidZoneinfoDirectory exception will be raised.
93
72
  #
73
+ # \DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_tab_file) uses the
74
+ # specified zoneinfo directory as the data source, but loads the iso3166.tab
75
+ # file from an alternate path. If the directory is not a valid zoneinfo
76
+ # directory, an InvalidZoneinfoDirectory exception will be raised.
77
+ #
94
78
  # Custom data sources can be created by subclassing TZInfo::DataSource and
95
79
  # implementing the following methods:
96
80
  #
@@ -120,7 +104,6 @@ module TZInfo
120
104
  elsif data_source_or_type == :ruby
121
105
  @@instance = RubyDataSource.new
122
106
  elsif data_source_or_type == :zoneinfo
123
- raise ArgumentError, "wrong number of arguments #{args.length} for 1" if args.length > 1
124
107
  @@instance = ZoneinfoDataSource.new(*args)
125
108
  else
126
109
  raise ArgumentError, 'data_source_or_type must be a DataSource instance or a data source type (:ruby)'
@@ -196,7 +179,7 @@ module TZInfo
196
179
  begin
197
180
  return ZoneinfoDataSource.new
198
181
  rescue ZoneinfoDirectoryNotFound
199
- raise DataSourceNotFound, 'No timezone data source could be found. To resolve this, either install TZInfo::Data (e.g. by running `gem install tzinfo-data`) or specify a zoneinfo directory using `TZInfo::DataSource.set(:zoneinfo, zoneinfo_path)`.'
182
+ raise DataSourceNotFound, "No source of timezone data could be found.\nPlease refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error."
200
183
  end
201
184
  end
202
185
  end
@@ -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
 
25
3
  # A Timezone based on a DataTimezoneInfo.
@@ -69,5 +47,12 @@ module TZInfo
69
47
  def transitions_up_to(utc_to, utc_from = nil)
70
48
  info.transitions_up_to(utc_to, utc_from)
71
49
  end
50
+
51
+ # Returns the canonical zone for this Timezone.
52
+ #
53
+ # For a DataTimezone, this is always self.
54
+ def canonical_zone
55
+ self
56
+ end
72
57
  end
73
58
  end
@@ -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 defined timezone containing transition data.
25
3
  class DataTimezoneInfo < TimezoneInfo
@@ -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
 
25
3
  # A Timezone based on a TimezoneInfo.
@@ -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
 
25
3
  # A Timezone based on a LinkedTimezoneInfo.
@@ -69,6 +47,13 @@ module TZInfo
69
47
  @linked_timezone.transitions_up_to(utc_to, utc_from)
70
48
  end
71
49
 
50
+ # Returns the canonical zone for this Timezone.
51
+ #
52
+ # For a LinkedTimezone, this is the canonical zone of the link target.
53
+ def canonical_zone
54
+ @linked_timezone.canonical_zone
55
+ end
56
+
72
57
  protected
73
58
  def setup(info)
74
59
  super(info)
@@ -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
  # Represents a timezone that is defined as a link or alias to another zone.
25
3
  class LinkedTimezoneInfo < TimezoneInfo
@@ -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
  require 'rational' unless defined?(Rational)
24
2
 
25
3
  module TZInfo
@@ -1,25 +1,3 @@
1
- #--
2
- # Copyright (c) 2008-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 'date'
24
2
  require 'rational' unless defined?(Rational)
25
3
 
@@ -150,5 +128,19 @@ module TZInfo
150
128
  str
151
129
  end
152
130
  end
131
+
132
+
133
+ # Wrapper for File.open that supports passing hash options for specifying
134
+ # encodings on Ruby 1.9+. The options are ignored on earlier versions of
135
+ # Ruby.
136
+ if RUBY_VERSION =~ /\A1\.[0-8]\./
137
+ def self.open_file(file_name, mode, opts, &block)
138
+ File.open(file_name, mode, &block)
139
+ end
140
+ else
141
+ def self.open_file(file_name, mode, opts, &block)
142
+ File.open(file_name, mode, opts, &block)
143
+ end
144
+ end
153
145
  end
154
146
  end
@@ -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
  # Represents information about a country returned by RubyDataSource.
25
3
  #
@@ -38,7 +16,7 @@ module TZInfo
38
16
  # Returns a frozen array of all the zone identifiers for the country. These
39
17
  # are in the order they were added using the timezone method.
40
18
  def zone_identifiers
41
- # Thread-safey: It is possible that the value of @zone_identifiers may be
19
+ # Thread-safety: It is possible that the value of @zone_identifiers may be
42
20
  # calculated multiple times in concurrently executing threads. It is not
43
21
  # worth the overhead of locking to ensure that @zone_identifiers is only
44
22
  # calculated once.
@@ -54,7 +32,7 @@ module TZInfo
54
32
  # CountryTimezone instances. These are in the order they were added using
55
33
  # the timezone method.
56
34
  def zones
57
- # Thread-safey: It is possible that the value of @zones may be
35
+ # Thread-safety: It is possible that the value of @zones may be
58
36
  # calculated multiple times in concurrently executing threads. It is not
59
37
  # worth the overhead of locking to ensure that @zones is only
60
38
  # calculated once.
@@ -83,7 +61,7 @@ module TZInfo
83
61
  # Called by the index data to define a timezone for the country.
84
62
  def timezone(identifier, latitude_numerator, latitude_denominator,
85
63
  longitude_numerator, longitude_denominator, description = nil)
86
- @list << CountryTimezone.new(identifier, latitude_numerator,
64
+ @list << CountryTimezone.new!(identifier, latitude_numerator,
87
65
  latitude_denominator, longitude_numerator, longitude_denominator,
88
66
  description)
89
67
  end
@@ -1,25 +1,3 @@
1
- #--
2
- # Copyright (c) 2012-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 DataSource that loads data from the set of Ruby modules included in the
25
3
  # TZInfo::Data library (tzinfo-data gem).
@@ -59,7 +37,7 @@ module TZInfo
59
37
  m = m.const_get(part)
60
38
  }
61
39
 
62
- info = m.get
40
+ m.get
63
41
  rescue LoadError, NameError => e
64
42
  raise InvalidTimezoneIdentifier, e.message
65
43
  end
@@ -1,27 +1,5 @@
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
  require 'date'
24
- require 'rational'
2
+ require 'rational' unless defined?(Rational)
25
3
  require 'time'
26
4
 
27
5
  module TZInfo
@@ -48,7 +26,7 @@ module TZInfo
48
26
  nsec = RubyCoreSupport.time_nsec(@time)
49
27
  usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000)
50
28
 
51
- @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.zone == 'UTC'
29
+ @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc?
52
30
  @orig = @time
53
31
  elsif timeOrDateTime.is_a?(DateTime)
54
32
  @datetime = timeOrDateTime
@@ -70,7 +48,7 @@ module TZInfo
70
48
  # When converting from a DateTime, the result is truncated to microsecond
71
49
  # precision.
72
50
  def to_time
73
- # Thread-safey: It is possible that the value of @time may be
51
+ # Thread-safety: It is possible that the value of @time may be
74
52
  # calculated multiple times in concurrently executing threads. It is not
75
53
  # worth the overhead of locking to ensure that @time is only
76
54
  # calculated once.
@@ -91,7 +69,7 @@ module TZInfo
91
69
  # When converting from a Time, the result is truncated to microsecond
92
70
  # precision.
93
71
  def to_datetime
94
- # Thread-safey: It is possible that the value of @datetime may be
72
+ # Thread-safety: It is possible that the value of @datetime may be
95
73
  # calculated multiple times in concurrently executing threads. It is not
96
74
  # worth the overhead of locking to ensure that @datetime is only
97
75
  # calculated once.
@@ -108,7 +86,7 @@ module TZInfo
108
86
 
109
87
  # Returns the time as an integer timestamp.
110
88
  def to_i
111
- # Thread-safey: It is possible that the value of @timestamp may be
89
+ # Thread-safety: It is possible that the value of @timestamp may be
112
90
  # calculated multiple times in concurrently executing threads. It is not
113
91
  # worth the overhead of locking to ensure that @timestamp is only
114
92
  # calculated once.
@@ -230,11 +208,19 @@ module TZInfo
230
208
  # whether the receiver is less than, equal to, or greater than
231
209
  # timeOrDateTime.
232
210
  #
211
+ # Returns nil if the passed in timeOrDateTime is not comparable with
212
+ # TimeOrDateTime instances.
213
+ #
233
214
  # Comparisons involving a DateTime will be performed using DateTime#<=>.
234
215
  # Comparisons that don't involve a DateTime, but include a Time will be
235
216
  # performed with Time#<=>. Otherwise comparisons will be performed with
236
217
  # Integer#<=>.
237
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
+
238
224
  unless timeOrDateTime.is_a?(TimeOrDateTime)
239
225
  timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime)
240
226
  end