timezone 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/timezone/configure.rb +1 -1
- data/lib/timezone/version.rb +1 -1
- data/lib/timezone/zone.rb +3 -3
- data/test/timezone_test.rb +28 -1
- metadata +5 -4
data/lib/timezone/configure.rb
CHANGED
data/lib/timezone/version.rb
CHANGED
data/lib/timezone/zone.rb
CHANGED
@@ -83,9 +83,9 @@ module Timezone
|
|
83
83
|
|
84
84
|
# Get a list of specified timezones and the basic information accompanying that zone
|
85
85
|
#
|
86
|
-
# zones = Timezone::Zone.
|
86
|
+
# zones = Timezone::Zone.list(*zones)
|
87
87
|
#
|
88
|
-
# zones - An array of timezone names. (i.e. Timezone::Zones.
|
88
|
+
# zones - An array of timezone names. (i.e. Timezone::Zones.list("America/Chicago", "Australia/Sydney"))
|
89
89
|
#
|
90
90
|
# The result is a Hash of timezones with their title, offset in seconds, UTC offset, and if it uses DST.
|
91
91
|
#
|
@@ -128,7 +128,7 @@ module Timezone
|
|
128
128
|
|
129
129
|
def _parsetime time #:nodoc:
|
130
130
|
begin
|
131
|
-
Time.strptime(time, "%Y-%m-%dT%H:%M:%
|
131
|
+
Time.strptime(time, "%Y-%m-%dT%H:%M:%S%Z")
|
132
132
|
rescue Exception => e
|
133
133
|
raise Timezone::Error::ParseTime, e.message
|
134
134
|
end
|
data/test/timezone_test.rb
CHANGED
@@ -95,6 +95,13 @@ class TimezoneTest < Test::Unit::TestCase
|
|
95
95
|
assert_equal 'Australia/Adelaide', timezone.zone
|
96
96
|
end
|
97
97
|
|
98
|
+
def test_using_old_ws_geonames_api
|
99
|
+
Timezone::Configure.begin { |c| c.url = 'ws.geonames.org' }
|
100
|
+
timezone = Timezone::Zone.new :latlon => [-34.92771808058, 138.477041423321]
|
101
|
+
assert_equal 'Australia/Adelaide', timezone.zone
|
102
|
+
Timezone::Configure.begin { |c| c.url = nil }
|
103
|
+
end
|
104
|
+
|
98
105
|
def test_australian_timezone_with_dst
|
99
106
|
timezone = Timezone::Zone.new :zone => 'Australia/Adelaide'
|
100
107
|
utc = Time.utc(2010, 12, 23, 19, 37, 15)
|
@@ -103,7 +110,7 @@ class TimezoneTest < Test::Unit::TestCase
|
|
103
110
|
end
|
104
111
|
|
105
112
|
def test_configure_url_default
|
106
|
-
assert_equal '
|
113
|
+
assert_equal 'api.geonames.org', Timezone::Configure.url
|
107
114
|
end
|
108
115
|
|
109
116
|
def test_configure_url_custom
|
@@ -113,4 +120,24 @@ class TimezoneTest < Test::Unit::TestCase
|
|
113
120
|
Timezone::Configure.begin { |c| c.url = nil }
|
114
121
|
end
|
115
122
|
|
123
|
+
def test_utc_offset_without_dst
|
124
|
+
timezone = Timezone::Zone.new :zone => 'Europe/Helsinki'
|
125
|
+
# just before DST starts
|
126
|
+
utc = Time.utc(2012, 3, 25, 0, 59, 59)
|
127
|
+
assert_equal timezone.utc_offset(utc), 7200
|
128
|
+
# on the second DST ends
|
129
|
+
utc = Time.utc(2012, 10, 28, 1, 0, 0)
|
130
|
+
assert_equal timezone.utc_offset(utc), 7200
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_utc_offset_with_dst
|
134
|
+
timezone = Timezone::Zone.new :zone => 'Europe/Helsinki'
|
135
|
+
# on the second DST starts
|
136
|
+
utc = Time.utc(2012, 3, 25, 1, 0, 0)
|
137
|
+
assert_equal timezone.utc_offset(utc), 10800
|
138
|
+
# right before DST end
|
139
|
+
utc = Time.utc(2012, 10, 28, 0, 59, 59)
|
140
|
+
assert_equal timezone.utc_offset(utc), 10800
|
141
|
+
end
|
142
|
+
|
116
143
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timezone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple way to get accurate current and historical timezone information
|
15
15
|
based on zone or latitude and longitude coordinates. This gem uses the tz database
|
@@ -515,9 +515,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
515
515
|
version: '0'
|
516
516
|
requirements: []
|
517
517
|
rubyforge_project: timezone
|
518
|
-
rubygems_version: 1.8.
|
518
|
+
rubygems_version: 1.8.22
|
519
519
|
signing_key:
|
520
520
|
specification_version: 3
|
521
|
-
summary: timezone-0.1.
|
521
|
+
summary: timezone-0.1.5
|
522
522
|
test_files:
|
523
523
|
- test/timezone_test.rb
|
524
|
+
has_rdoc:
|