timezone 0.6.0 → 0.99.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +99 -1
- data/.travis.yml +6 -3
- data/CHANGES.markdown +10 -0
- data/Gemfile +1 -1
- data/README.markdown +129 -89
- data/Rakefile +7 -4
- data/benchmark.rb +13 -13
- data/lib/timezone/active_support.rb +147 -134
- data/lib/timezone/configure.rb +131 -110
- data/lib/timezone/deprecate.rb +32 -0
- data/lib/timezone/error.rb +16 -5
- data/lib/timezone/loader.rb +19 -16
- data/lib/timezone/lookup/basic.rb +24 -2
- data/lib/timezone/lookup/geonames.rb +9 -5
- data/lib/timezone/lookup/google.rb +24 -15
- data/lib/timezone/lookup/test.rb +8 -8
- data/lib/timezone/lookup.rb +68 -0
- data/lib/timezone/net_http_client.rb +23 -9
- data/lib/timezone/nil_zone.rb +32 -0
- data/lib/timezone/parser.rb +10 -5
- data/lib/timezone/version.rb +2 -1
- data/lib/timezone/zone.rb +230 -99
- data/lib/timezone.rb +75 -1
- data/test/basic_lookup_test.rb +2 -2
- data/test/geonames_lookup_test.rb +13 -6
- data/test/google_lookup_test.rb +34 -24
- data/test/http_test_client.rb +7 -6
- data/test/test_lookup_test.rb +3 -1
- data/test/test_timezone.rb +59 -0
- data/test/timezone/lookup/test_geonames.rb +59 -0
- data/test/timezone/lookup/test_google.rb +94 -0
- data/test/timezone/lookup/test_test.rb +24 -0
- data/test/timezone/test_deprecate.rb +20 -0
- data/test/timezone/test_loader.rb +32 -0
- data/test/timezone/test_lookup.rb +53 -0
- data/test/timezone/test_nil_zone.rb +26 -0
- data/test/timezone/test_zone.rb +49 -0
- data/test/timezone_test.rb +64 -63
- data/timezone.gemspec +16 -15
- metadata +39 -38
- data/.rubocop_todo.yml +0 -235
@@ -1,142 +1,155 @@
|
|
1
|
+
require 'timezone/deprecate'
|
2
|
+
|
1
3
|
module Timezone
|
2
|
-
#
|
4
|
+
# @deprecated Will be removed in the next release of `timezone` gem.
|
3
5
|
class ActiveSupport
|
4
6
|
TIMEZONE_MAPPING = {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
7
|
+
'Pacific/Midway' => 'Midway Island',
|
8
|
+
'Pacific/Pago_Pago' => 'American Samoa',
|
9
|
+
'Pacific/Honolulu' => 'Hawaii',
|
10
|
+
'America/Juneau' => 'Alaska',
|
11
|
+
'America/Los_Angeles' => 'Pacific Time (US & Canada)',
|
12
|
+
'America/Tijuana' => 'Tijuana',
|
13
|
+
'America/Denver' => 'Mountain Time (US & Canada)',
|
14
|
+
'America/Phoenix' => 'Arizona',
|
15
|
+
'America/Chihuahua' => 'Chihuahua',
|
16
|
+
'America/Mazatlan' => 'Mazatlan',
|
17
|
+
'America/Chicago' => 'Central Time (US & Canada)',
|
18
|
+
'America/Regina' => 'Saskatchewan',
|
19
|
+
'America/Mexico_City' => 'Mexico City',
|
20
|
+
'America/Monterrey' => 'Monterrey',
|
21
|
+
'America/Guatemala' => 'Central America',
|
22
|
+
'America/New_York' => 'Eastern Time (US & Canada)',
|
23
|
+
'America/Indiana/Indianapolis' => 'Indiana (East)',
|
24
|
+
'America/Bogota' => 'Bogota',
|
25
|
+
'America/Lima' => 'Quito',
|
26
|
+
'America/Halifax' => 'Atlantic Time (Canada)',
|
27
|
+
'America/Caracas' => 'Caracas',
|
28
|
+
'America/La_Paz' => 'La Paz',
|
29
|
+
'America/Santiago' => 'Santiago',
|
30
|
+
'America/St_Johns' => 'Newfoundland',
|
31
|
+
'America/Sao_Paulo' => 'Brasilia',
|
32
|
+
'America/Argentina/Buenos_Aires' => 'Buenos Aires',
|
33
|
+
'America/Montevideo' => 'Montevideo',
|
34
|
+
'America/Guyana' => 'Georgetown',
|
35
|
+
'America/Godthab' => 'Greenland',
|
36
|
+
'Atlantic/South_Georgia' => 'Mid-Atlantic',
|
37
|
+
'Atlantic/Azores' => 'Azores',
|
38
|
+
'Atlantic/Cape_Verde' => 'Cape Verde Is.',
|
39
|
+
'Europe/Dublin' => 'Dublin',
|
40
|
+
'Europe/London' => 'London',
|
41
|
+
'Europe/Lisbon' => 'Lisbon',
|
42
|
+
'Africa/Casablanca' => 'Casablanca',
|
43
|
+
'Africa/Monrovia' => 'Monrovia',
|
44
|
+
'Etc/UTC' => 'UTC',
|
45
|
+
'Europe/Belgrade' => 'Belgrade',
|
46
|
+
'Europe/Bratislava' => 'Bratislava',
|
47
|
+
'Europe/Budapest' => 'Budapest',
|
48
|
+
'Europe/Ljubljana' => 'Ljubljana',
|
49
|
+
'Europe/Prague' => 'Prague',
|
50
|
+
'Europe/Sarajevo' => 'Sarajevo',
|
51
|
+
'Europe/Skopje' => 'Skopje',
|
52
|
+
'Europe/Warsaw' => 'Warsaw',
|
53
|
+
'Europe/Zagreb' => 'Zagreb',
|
54
|
+
'Europe/Brussels' => 'Brussels',
|
55
|
+
'Europe/Copenhagen' => 'Copenhagen',
|
56
|
+
'Europe/Madrid' => 'Madrid',
|
57
|
+
'Europe/Paris' => 'Paris',
|
58
|
+
'Europe/Amsterdam' => 'Amsterdam',
|
59
|
+
'Europe/Berlin' => 'Bern',
|
60
|
+
'Europe/Rome' => 'Rome',
|
61
|
+
'Europe/Stockholm' => 'Stockholm',
|
62
|
+
'Europe/Vienna' => 'Vienna',
|
63
|
+
'Africa/Algiers' => 'West Central Africa',
|
64
|
+
'Europe/Bucharest' => 'Bucharest',
|
65
|
+
'Africa/Cairo' => 'Cairo',
|
66
|
+
'Europe/Helsinki' => 'Helsinki',
|
67
|
+
'Europe/Kiev' => 'Kyiv',
|
68
|
+
'Europe/Riga' => 'Riga',
|
69
|
+
'Europe/Sofia' => 'Sofia',
|
70
|
+
'Europe/Tallinn' => 'Tallinn',
|
71
|
+
'Europe/Vilnius' => 'Vilnius',
|
72
|
+
'Europe/Athens' => 'Athens',
|
73
|
+
'Europe/Istanbul' => 'Istanbul',
|
74
|
+
'Europe/Minsk' => 'Minsk',
|
75
|
+
'Asia/Jerusalem' => 'Jerusalem',
|
76
|
+
'Africa/Harare' => 'Harare',
|
77
|
+
'Africa/Johannesburg' => 'Pretoria',
|
78
|
+
'Europe/Kaliningrad' => 'Kaliningrad',
|
79
|
+
'Europe/Moscow' => 'St. Petersburg',
|
80
|
+
'Europe/Volgograd' => 'Volgograd',
|
81
|
+
'Europe/Samara' => 'Samara',
|
82
|
+
'Asia/Kuwait' => 'Kuwait',
|
83
|
+
'Asia/Riyadh' => 'Riyadh',
|
84
|
+
'Africa/Nairobi' => 'Nairobi',
|
85
|
+
'Asia/Baghdad' => 'Baghdad',
|
86
|
+
'Asia/Tehran' => 'Tehran',
|
87
|
+
'Asia/Muscat' => 'Muscat',
|
88
|
+
'Asia/Baku' => 'Baku',
|
89
|
+
'Asia/Tbilisi' => 'Tbilisi',
|
90
|
+
'Asia/Yerevan' => 'Yerevan',
|
91
|
+
'Asia/Kabul' => 'Kabul',
|
92
|
+
'Asia/Yekaterinburg' => 'Ekaterinburg',
|
93
|
+
'Asia/Karachi' => 'Karachi',
|
94
|
+
'Asia/Tashkent' => 'Tashkent',
|
95
|
+
'Asia/Kolkata' => 'New Delhi',
|
96
|
+
'Asia/Kathmandu' => 'Kathmandu',
|
97
|
+
'Asia/Dhaka' => 'Dhaka',
|
98
|
+
'Asia/Colombo' => 'Sri Jayawardenepura',
|
99
|
+
'Asia/Almaty' => 'Almaty',
|
100
|
+
'Asia/Novosibirsk' => 'Novosibirsk',
|
101
|
+
'Asia/Rangoon' => 'Rangoon',
|
102
|
+
'Asia/Bangkok' => 'Hanoi',
|
103
|
+
'Asia/Jakarta' => 'Jakarta',
|
104
|
+
'Asia/Krasnoyarsk' => 'Krasnoyarsk',
|
105
|
+
'Asia/Shanghai' => 'Beijing',
|
106
|
+
'Asia/Chongqing' => 'Chongqing',
|
107
|
+
'Asia/Hong_Kong' => 'Hong Kong',
|
108
|
+
'Asia/Urumqi' => 'Urumqi',
|
109
|
+
'Asia/Kuala_Lumpur' => 'Kuala Lumpur',
|
110
|
+
'Asia/Singapore' => 'Singapore',
|
111
|
+
'Asia/Taipei' => 'Taipei',
|
112
|
+
'Australia/Perth' => 'Perth',
|
113
|
+
'Asia/Irkutsk' => 'Irkutsk',
|
114
|
+
'Asia/Ulaanbaatar' => 'Ulaanbaatar',
|
115
|
+
'Asia/Seoul' => 'Seoul',
|
116
|
+
'Asia/Tokyo' => 'Tokyo',
|
117
|
+
'Asia/Yakutsk' => 'Yakutsk',
|
118
|
+
'Australia/Darwin' => 'Darwin',
|
119
|
+
'Australia/Adelaide' => 'Adelaide',
|
120
|
+
'Australia/Melbourne' => 'Melbourne',
|
121
|
+
'Australia/Sydney' => 'Sydney',
|
122
|
+
'Australia/Brisbane' => 'Brisbane',
|
123
|
+
'Australia/Hobart' => 'Hobart',
|
124
|
+
'Asia/Vladivostok' => 'Vladivostok',
|
125
|
+
'Pacific/Guam' => 'Guam',
|
126
|
+
'Pacific/Port_Moresby' => 'Port Moresby',
|
127
|
+
'Asia/Magadan' => 'Magadan',
|
128
|
+
'Asia/Srednekolymsk' => 'Srednekolymsk',
|
129
|
+
'Pacific/Guadalcanal' => 'Solomon Is.',
|
130
|
+
'Pacific/Noumea' => 'New Caledonia',
|
131
|
+
'Pacific/Fiji' => 'Fiji',
|
132
|
+
'Asia/Kamchatka' => 'Kamchatka',
|
133
|
+
'Pacific/Majuro' => 'Marshall Is.',
|
134
|
+
'Pacific/Auckland' => 'Wellington',
|
135
|
+
'Pacific/Tongatapu' => "Nuku'alofa",
|
136
|
+
'Pacific/Fakaofo' => 'Tokelau Is.',
|
137
|
+
'Pacific/Chatham' => 'Chatham Is.',
|
138
|
+
'Pacific/Apia' => 'Samoa'
|
137
139
|
}.freeze
|
138
140
|
|
139
|
-
|
141
|
+
# @deprecated Will be removed in the next release of `timezone gem.
|
142
|
+
def self.format(zone, internal = false)
|
143
|
+
unless internal
|
144
|
+
Deprecate.call(
|
145
|
+
self,
|
146
|
+
:format,
|
147
|
+
'[DEPRECATE] `Timezone::ActiveSupport::format` will be ' \
|
148
|
+
'removed in the next release of the `timezone` gem. There ' \
|
149
|
+
'will be no replacement.'.freeze
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
140
153
|
TIMEZONE_MAPPING[zone] || zone
|
141
154
|
end
|
142
155
|
end
|