timezone 0.6.0 → 0.99.0

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