tzinfo 0.0.4 → 0.1.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.
- data/CHANGES +94 -58
- data/LICENSE +19 -0
- data/README +1 -1
- data/Rakefile +75 -0
- data/lib/tzinfo.rb +14 -14
- data/lib/tzinfo/country.rb +38 -6
- data/lib/tzinfo/definitions/Africa/Abidjan.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Accra.rb +16 -16
- data/lib/tzinfo/definitions/Africa/Addis_Ababa.rb +3 -3
- data/lib/tzinfo/definitions/Africa/Algiers.rb +35 -35
- data/lib/tzinfo/definitions/Africa/Asmera.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Bamako.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Bangui.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Banjul.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Bissau.rb +3 -3
- data/lib/tzinfo/definitions/Africa/Blantyre.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Brazzaville.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Bujumbura.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Cairo.rb +192 -191
- data/lib/tzinfo/definitions/Africa/Casablanca.rb +20 -20
- data/lib/tzinfo/definitions/Africa/Ceuta.rb +146 -145
- data/lib/tzinfo/definitions/Africa/Conakry.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Dakar.rb +3 -3
- data/lib/tzinfo/definitions/Africa/Dar_es_Salaam.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Djibouti.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Douala.rb +2 -2
- data/lib/tzinfo/definitions/Africa/El_Aaiun.rb +3 -3
- data/lib/tzinfo/definitions/Africa/Freetown.rb +32 -32
- data/lib/tzinfo/definitions/Africa/Gaborone.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Harare.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Johannesburg.rb +7 -7
- data/lib/tzinfo/definitions/Africa/Kampala.rb +5 -5
- data/lib/tzinfo/definitions/Africa/Khartoum.rb +35 -35
- data/lib/tzinfo/definitions/Africa/Kigali.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Kinshasa.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Lagos.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Libreville.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Lome.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Luanda.rb +3 -3
- data/lib/tzinfo/definitions/Africa/Lubumbashi.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Lusaka.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Malabo.rb +3 -3
- data/lib/tzinfo/definitions/Africa/Maputo.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Maseru.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Mbabane.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Mogadishu.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Monrovia.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Nairobi.rb +5 -5
- data/lib/tzinfo/definitions/Africa/Ndjamena.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Niamey.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Nouakchott.rb +4 -4
- data/lib/tzinfo/definitions/Africa/Ouagadougou.rb +2 -2
- data/lib/tzinfo/definitions/Africa/Porto__m__Novo.rb +3 -3
- data/lib/tzinfo/definitions/Africa/Sao_Tome.rb +3 -3
- data/lib/tzinfo/definitions/Africa/Tripoli.rb +30 -30
- data/lib/tzinfo/definitions/Africa/Tunis.rb +29 -29
- data/lib/tzinfo/definitions/Africa/Windhoek.rb +110 -110
- data/lib/tzinfo/definitions/America/Adak.rb +164 -163
- data/lib/tzinfo/definitions/America/Anchorage.rb +164 -163
- data/lib/tzinfo/definitions/America/Anguilla.rb +2 -2
- data/lib/tzinfo/definitions/America/Antigua.rb +3 -3
- data/lib/tzinfo/definitions/America/Araguaina.rb +53 -53
- data/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +58 -58
- data/lib/tzinfo/definitions/America/Argentina/Catamarca.rb +60 -60
- data/lib/tzinfo/definitions/America/Argentina/Cordoba.rb +58 -58
- data/lib/tzinfo/definitions/America/Argentina/Jujuy.rb +59 -59
- data/lib/tzinfo/definitions/America/Argentina/La_Rioja.rb +61 -61
- data/lib/tzinfo/definitions/America/Argentina/Mendoza.rb +60 -60
- data/lib/tzinfo/definitions/America/Argentina/Rio_Gallegos.rb +60 -60
- data/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +61 -61
- data/lib/tzinfo/definitions/America/Argentina/Tucuman.rb +60 -60
- data/lib/tzinfo/definitions/America/Argentina/Ushuaia.rb +60 -60
- data/lib/tzinfo/definitions/America/Aruba.rb +3 -3
- data/lib/tzinfo/definitions/America/Asuncion.rb +146 -145
- data/lib/tzinfo/definitions/America/Bahia.rb +61 -61
- data/lib/tzinfo/definitions/America/Barbados.rb +11 -11
- data/lib/tzinfo/definitions/America/Belem.rb +31 -31
- data/lib/tzinfo/definitions/America/Belize.rb +56 -56
- data/lib/tzinfo/definitions/America/Boa_Vista.rb +36 -36
- data/lib/tzinfo/definitions/America/Bogota.rb +5 -5
- data/lib/tzinfo/definitions/America/Boise.rb +167 -166
- data/lib/tzinfo/definitions/America/Cambridge_Bay.rb +143 -142
- data/lib/tzinfo/definitions/America/Campo_Grande.rb +145 -144
- data/lib/tzinfo/definitions/America/Cancun.rb +104 -103
- data/lib/tzinfo/definitions/America/Caracas.rb +4 -4
- data/lib/tzinfo/definitions/America/Cayenne.rb +3 -3
- data/lib/tzinfo/definitions/America/Cayman.rb +3 -3
- data/lib/tzinfo/definitions/America/Chicago.rb +256 -255
- data/lib/tzinfo/definitions/America/Chihuahua.rb +109 -108
- data/lib/tzinfo/definitions/America/Coral_Harbour.rb +9 -9
- data/lib/tzinfo/definitions/America/Costa_Rica.rb +11 -11
- data/lib/tzinfo/definitions/America/Cuiaba.rb +145 -144
- data/lib/tzinfo/definitions/America/Curacao.rb +3 -3
- data/lib/tzinfo/definitions/America/Danmarkshavn.rb +35 -35
- data/lib/tzinfo/definitions/America/Dawson.rb +143 -142
- data/lib/tzinfo/definitions/America/Dawson_Creek.rb +59 -59
- data/lib/tzinfo/definitions/America/Denver.rb +178 -177
- data/lib/tzinfo/definitions/America/Detroit.rb +158 -157
- data/lib/tzinfo/definitions/America/Dominica.rb +2 -2
- data/lib/tzinfo/definitions/America/Edmonton.rb +170 -169
- data/lib/tzinfo/definitions/America/Eirunepe.rb +35 -35
- data/lib/tzinfo/definitions/America/El_Salvador.rb +6 -6
- data/lib/tzinfo/definitions/America/Fortaleza.rb +44 -44
- data/lib/tzinfo/definitions/America/Glace_Bay.rb +160 -159
- data/lib/tzinfo/definitions/America/Godthab.rb +134 -133
- data/lib/tzinfo/definitions/America/Goose_Bay.rb +225 -224
- data/lib/tzinfo/definitions/America/Grand_Turk.rb +137 -136
- data/lib/tzinfo/definitions/America/Grenada.rb +2 -2
- data/lib/tzinfo/definitions/America/Guadeloupe.rb +2 -2
- data/lib/tzinfo/definitions/America/Guatemala.rb +8 -8
- data/lib/tzinfo/definitions/America/Guayaquil.rb +3 -3
- data/lib/tzinfo/definitions/America/Guyana.rb +5 -5
- data/lib/tzinfo/definitions/America/Halifax.rb +248 -247
- data/lib/tzinfo/definitions/America/Havana.rb +175 -174
- data/lib/tzinfo/definitions/America/Hermosillo.rb +17 -17
- data/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +121 -120
- data/lib/tzinfo/definitions/America/Indiana/Knox.rb +172 -171
- data/lib/tzinfo/definitions/America/Indiana/Marengo.rb +123 -122
- data/lib/tzinfo/definitions/America/Indiana/Vevay.rb +100 -99
- data/lib/tzinfo/definitions/America/Inuvik.rb +143 -142
- data/lib/tzinfo/definitions/America/Iqaluit.rb +142 -141
- data/lib/tzinfo/definitions/America/Jamaica.rb +23 -23
- data/lib/tzinfo/definitions/America/Juneau.rb +163 -162
- data/lib/tzinfo/definitions/America/Kentucky/Louisville.rb +198 -197
- data/lib/tzinfo/definitions/America/Kentucky/Monticello.rb +166 -165
- data/lib/tzinfo/definitions/America/La_Paz.rb +4 -4
- data/lib/tzinfo/definitions/America/Lima.rb +17 -17
- data/lib/tzinfo/definitions/America/Los_Angeles.rb +204 -203
- data/lib/tzinfo/definitions/America/Maceio.rb +48 -48
- data/lib/tzinfo/definitions/America/Managua.rb +15 -15
- data/lib/tzinfo/definitions/America/Manaus.rb +35 -35
- data/lib/tzinfo/definitions/America/Martinique.rb +5 -5
- data/lib/tzinfo/definitions/America/Mazatlan.rb +110 -109
- data/lib/tzinfo/definitions/America/Menominee.rb +160 -159
- data/lib/tzinfo/definitions/America/Merida.rb +104 -103
- data/lib/tzinfo/definitions/America/Mexico_City.rb +116 -115
- data/lib/tzinfo/definitions/America/Miquelon.rb +122 -121
- data/lib/tzinfo/definitions/America/Monterrey.rb +106 -105
- data/lib/tzinfo/definitions/America/Montevideo.rb +69 -67
- data/lib/tzinfo/definitions/America/Montreal.rb +253 -252
- data/lib/tzinfo/definitions/America/Montserrat.rb +2 -2
- data/lib/tzinfo/definitions/America/Nassau.rb +166 -165
- data/lib/tzinfo/definitions/America/New_York.rb +256 -255
- data/lib/tzinfo/definitions/America/Nipigon.rb +151 -150
- data/lib/tzinfo/definitions/America/Nome.rb +164 -163
- data/lib/tzinfo/definitions/America/Noronha.rb +44 -44
- data/lib/tzinfo/definitions/America/North_Dakota/Center.rb +166 -165
- data/lib/tzinfo/definitions/America/Panama.rb +3 -3
- data/lib/tzinfo/definitions/America/Pangnirtung.rb +142 -141
- data/lib/tzinfo/definitions/America/Paramaribo.rb +6 -6
- data/lib/tzinfo/definitions/America/Phoenix.rb +14 -14
- data/lib/tzinfo/definitions/America/Port__m__au__m__Prince.rb +35 -35
- data/lib/tzinfo/definitions/America/Port_of_Spain.rb +2 -2
- data/lib/tzinfo/definitions/America/Porto_Velho.rb +31 -31
- data/lib/tzinfo/definitions/America/Puerto_Rico.rb +4 -4
- data/lib/tzinfo/definitions/America/Rainy_River.rb +151 -150
- data/lib/tzinfo/definitions/America/Rankin_Inlet.rb +142 -141
- data/lib/tzinfo/definitions/America/Recife.rb +44 -44
- data/lib/tzinfo/definitions/America/Regina.rb +53 -53
- data/lib/tzinfo/definitions/America/Rio_Branco.rb +31 -31
- data/lib/tzinfo/definitions/America/Santiago.rb +175 -174
- data/lib/tzinfo/definitions/America/Santo_Domingo.rb +18 -18
- data/lib/tzinfo/definitions/America/Sao_Paulo.rb +146 -145
- data/lib/tzinfo/definitions/America/Scoresbysund.rb +134 -133
- data/lib/tzinfo/definitions/America/St_Johns.rb +259 -258
- data/lib/tzinfo/definitions/America/St_Kitts.rb +2 -2
- data/lib/tzinfo/definitions/America/St_Lucia.rb +3 -3
- data/lib/tzinfo/definitions/America/St_Thomas.rb +2 -2
- data/lib/tzinfo/definitions/America/St_Vincent.rb +3 -3
- data/lib/tzinfo/definitions/America/Swift_Current.rb +23 -23
- data/lib/tzinfo/definitions/America/Tegucigalpa.rb +6 -6
- data/lib/tzinfo/definitions/America/Thule.rb +112 -111
- data/lib/tzinfo/definitions/America/Thunder_Bay.rb +159 -158
- data/lib/tzinfo/definitions/America/Tijuana.rb +171 -170
- data/lib/tzinfo/definitions/America/Toronto.rb +252 -251
- data/lib/tzinfo/definitions/America/Tortola.rb +2 -2
- data/lib/tzinfo/definitions/America/Vancouver.rb +206 -205
- data/lib/tzinfo/definitions/America/Whitehorse.rb +143 -142
- data/lib/tzinfo/definitions/America/Winnipeg.rb +202 -201
- data/lib/tzinfo/definitions/America/Yakutat.rb +163 -162
- data/lib/tzinfo/definitions/America/Yellowknife.rb +142 -141
- data/lib/tzinfo/definitions/Antarctica/Casey.rb +2 -2
- data/lib/tzinfo/definitions/Antarctica/Davis.rb +4 -4
- data/lib/tzinfo/definitions/Antarctica/DumontDUrville.rb +4 -4
- data/lib/tzinfo/definitions/Antarctica/Mawson.rb +2 -2
- data/lib/tzinfo/definitions/Antarctica/McMurdo.rb +145 -144
- data/lib/tzinfo/definitions/Antarctica/Palmer.rb +147 -146
- data/lib/tzinfo/definitions/Antarctica/Rothera.rb +2 -2
- data/lib/tzinfo/definitions/Antarctica/Syowa.rb +2 -2
- data/lib/tzinfo/definitions/Antarctica/Vostok.rb +2 -2
- data/lib/tzinfo/definitions/Asia/Aden.rb +2 -2
- data/lib/tzinfo/definitions/Asia/Almaty.rb +52 -52
- data/lib/tzinfo/definitions/Asia/Amman.rb +136 -135
- data/lib/tzinfo/definitions/Asia/Anadyr.rb +134 -133
- data/lib/tzinfo/definitions/Asia/Aqtau.rb +52 -52
- data/lib/tzinfo/definitions/Asia/Aqtobe.rb +52 -52
- data/lib/tzinfo/definitions/Asia/Ashgabat.rb +27 -27
- data/lib/tzinfo/definitions/Asia/Baghdad.rb +131 -130
- data/lib/tzinfo/definitions/Asia/Bahrain.rb +3 -3
- data/lib/tzinfo/definitions/Asia/Baku.rb +130 -129
- data/lib/tzinfo/definitions/Asia/Bangkok.rb +3 -3
- data/lib/tzinfo/definitions/Asia/Beirut.rb +158 -157
- data/lib/tzinfo/definitions/Asia/Bishkek.rb +52 -131
- data/lib/tzinfo/definitions/Asia/Brunei.rb +3 -3
- data/lib/tzinfo/definitions/Asia/Calcutta.rb +6 -6
- data/lib/tzinfo/definitions/Asia/Choibalsan.rb +125 -124
- data/lib/tzinfo/definitions/Asia/Chongqing.rb +15 -15
- data/lib/tzinfo/definitions/Asia/Colombo.rb +8 -8
- data/lib/tzinfo/definitions/Asia/Damascus.rb +168 -167
- data/lib/tzinfo/definitions/Asia/Dhaka.rb +7 -7
- data/lib/tzinfo/definitions/Asia/Dili.rb +6 -6
- data/lib/tzinfo/definitions/Asia/Dubai.rb +2 -2
- data/lib/tzinfo/definitions/Asia/Dushanbe.rb +25 -25
- data/lib/tzinfo/definitions/Asia/Gaza.rb +162 -161
- data/lib/tzinfo/definitions/Asia/Harbin.rb +18 -18
- data/lib/tzinfo/definitions/Asia/Hong_Kong.rb +70 -70
- data/lib/tzinfo/definitions/Asia/Hovd.rb +125 -124
- data/lib/tzinfo/definitions/Asia/Irkutsk.rb +135 -134
- data/lib/tzinfo/definitions/Asia/Jakarta.rb +9 -9
- data/lib/tzinfo/definitions/Asia/Jayapura.rb +4 -4
- data/lib/tzinfo/definitions/Asia/Jerusalem.rb +144 -144
- data/lib/tzinfo/definitions/Asia/Kabul.rb +3 -3
- data/lib/tzinfo/definitions/Asia/Kamchatka.rb +134 -133
- data/lib/tzinfo/definitions/Asia/Karachi.rb +8 -8
- data/lib/tzinfo/definitions/Asia/Kashgar.rb +16 -16
- data/lib/tzinfo/definitions/Asia/Katmandu.rb +3 -3
- data/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +134 -133
- data/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +9 -9
- data/lib/tzinfo/definitions/Asia/Kuching.rb +20 -20
- data/lib/tzinfo/definitions/Asia/Kuwait.rb +2 -2
- data/lib/tzinfo/definitions/Asia/Macau.rb +43 -43
- data/lib/tzinfo/definitions/Asia/Magadan.rb +134 -133
- data/lib/tzinfo/definitions/Asia/Makassar.rb +5 -5
- data/lib/tzinfo/definitions/Asia/Manila.rb +11 -11
- data/lib/tzinfo/definitions/Asia/Muscat.rb +2 -2
- data/lib/tzinfo/definitions/Asia/Nicosia.rb +145 -144
- data/lib/tzinfo/definitions/Asia/Novosibirsk.rb +135 -134
- data/lib/tzinfo/definitions/Asia/Omsk.rb +134 -133
- data/lib/tzinfo/definitions/Asia/Oral.rb +52 -52
- data/lib/tzinfo/definitions/Asia/Phnom_Penh.rb +5 -5
- data/lib/tzinfo/definitions/Asia/Pontianak.rb +9 -9
- data/lib/tzinfo/definitions/Asia/Pyongyang.rb +7 -7
- data/lib/tzinfo/definitions/Asia/Qatar.rb +3 -3
- data/lib/tzinfo/definitions/Asia/Qyzylorda.rb +53 -53
- data/lib/tzinfo/definitions/Asia/Rangoon.rb +5 -5
- data/lib/tzinfo/definitions/Asia/Riyadh.rb +2 -2
- data/lib/tzinfo/definitions/Asia/Saigon.rb +5 -5
- data/lib/tzinfo/definitions/Asia/Sakhalin.rb +135 -134
- data/lib/tzinfo/definitions/Asia/Samarkand.rb +30 -30
- data/lib/tzinfo/definitions/Asia/Seoul.rb +14 -14
- data/lib/tzinfo/definitions/Asia/Shanghai.rb +19 -19
- data/lib/tzinfo/definitions/Asia/Singapore.rb +10 -10
- data/lib/tzinfo/definitions/Asia/Taipei.rb +42 -42
- data/lib/tzinfo/definitions/Asia/Tashkent.rb +30 -30
- data/lib/tzinfo/definitions/Asia/Tbilisi.rb +137 -136
- data/lib/tzinfo/definitions/Asia/Tehran.rb +105 -105
- data/lib/tzinfo/definitions/Asia/Thimphu.rb +3 -3
- data/lib/tzinfo/definitions/Asia/Tokyo.rb +12 -12
- data/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +125 -124
- data/lib/tzinfo/definitions/Asia/Urumqi.rb +15 -15
- data/lib/tzinfo/definitions/Asia/Vientiane.rb +5 -5
- data/lib/tzinfo/definitions/Asia/Vladivostok.rb +134 -133
- data/lib/tzinfo/definitions/Asia/Yakutsk.rb +134 -133
- data/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +134 -133
- data/lib/tzinfo/definitions/Asia/Yerevan.rb +133 -132
- data/lib/tzinfo/definitions/Atlantic/Azores.rb +238 -237
- data/lib/tzinfo/definitions/Atlantic/Bermuda.rb +146 -145
- data/lib/tzinfo/definitions/Atlantic/Canary.rb +136 -135
- data/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +5 -5
- data/lib/tzinfo/definitions/Atlantic/Faeroe.rb +133 -132
- data/lib/tzinfo/definitions/Atlantic/Madeira.rb +238 -237
- data/lib/tzinfo/definitions/Atlantic/Reykjavik.rb +66 -66
- data/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +2 -2
- data/lib/tzinfo/definitions/Atlantic/St_Helena.rb +3 -3
- data/lib/tzinfo/definitions/Atlantic/Stanley.rb +141 -141
- data/lib/tzinfo/definitions/Australia/Adelaide.rb +161 -160
- data/lib/tzinfo/definitions/Australia/Brisbane.rb +19 -19
- data/lib/tzinfo/definitions/Australia/Broken_Hill.rb +163 -162
- data/lib/tzinfo/definitions/Australia/Currie.rb +161 -160
- data/lib/tzinfo/definitions/Australia/Darwin.rb +11 -11
- data/lib/tzinfo/definitions/Australia/Hobart.rb +169 -168
- data/lib/tzinfo/definitions/Australia/Lindeman.rb +24 -24
- data/lib/tzinfo/definitions/Australia/Lord_Howe.rb +132 -131
- data/lib/tzinfo/definitions/Australia/Melbourne.rb +160 -159
- data/lib/tzinfo/definitions/Australia/Perth.rb +15 -15
- data/lib/tzinfo/definitions/Australia/Sydney.rb +160 -159
- data/lib/tzinfo/definitions/CET.rb +151 -150
- data/lib/tzinfo/definitions/EET.rb +139 -138
- data/lib/tzinfo/definitions/Etc/GMT.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__1.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__10.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__11.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__12.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__13.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__14.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__2.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__3.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__4.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__5.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__6.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__7.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__8.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__m__9.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__1.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__10.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__11.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__12.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__2.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__3.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__4.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__5.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__6.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__7.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__8.rb +1 -1
- data/lib/tzinfo/definitions/Etc/GMT__p__9.rb +1 -1
- data/lib/tzinfo/definitions/Etc/UCT.rb +1 -1
- data/lib/tzinfo/definitions/Etc/UTC.rb +1 -1
- data/lib/tzinfo/definitions/Europe/Amsterdam.rb +197 -196
- data/lib/tzinfo/definitions/Europe/Andorra.rb +125 -124
- data/lib/tzinfo/definitions/Europe/Athens.rb +156 -155
- data/lib/tzinfo/definitions/Europe/Belgrade.rb +136 -135
- data/lib/tzinfo/definitions/Europe/Berlin.rb +161 -160
- data/lib/tzinfo/definitions/Europe/Brussels.rb +203 -202
- data/lib/tzinfo/definitions/Europe/Bucharest.rb +156 -155
- data/lib/tzinfo/definitions/Europe/Budapest.rb +170 -169
- data/lib/tzinfo/definitions/Europe/Chisinau.rb +159 -158
- data/lib/tzinfo/definitions/Europe/Copenhagen.rb +152 -151
- data/lib/tzinfo/definitions/Europe/Dublin.rb +246 -245
- data/lib/tzinfo/definitions/Europe/Gibraltar.rb +216 -215
- data/lib/tzinfo/definitions/Europe/Helsinki.rb +136 -135
- data/lib/tzinfo/definitions/Europe/Istanbul.rb +190 -189
- data/lib/tzinfo/definitions/Europe/Kaliningrad.rb +148 -147
- data/lib/tzinfo/definitions/Europe/Kiev.rb +138 -137
- data/lib/tzinfo/definitions/Europe/Lisbon.rb +239 -238
- data/lib/tzinfo/definitions/Europe/London.rb +260 -259
- data/lib/tzinfo/definitions/Europe/Luxembourg.rb +200 -199
- data/lib/tzinfo/definitions/Europe/Madrid.rb +182 -181
- data/lib/tzinfo/definitions/Europe/Malta.rb +187 -186
- data/lib/tzinfo/definitions/Europe/Minsk.rb +136 -135
- data/lib/tzinfo/definitions/Europe/Monaco.rb +203 -202
- data/lib/tzinfo/definitions/Europe/Moscow.rb +147 -146
- data/lib/tzinfo/definitions/Europe/Oslo.rb +158 -157
- data/lib/tzinfo/definitions/Europe/Paris.rb +201 -200
- data/lib/tzinfo/definitions/Europe/Prague.rb +159 -158
- data/lib/tzinfo/definitions/Europe/Riga.rb +145 -144
- data/lib/tzinfo/definitions/Europe/Rome.rb +189 -188
- data/lib/tzinfo/definitions/Europe/Samara.rb +134 -133
- data/lib/tzinfo/definitions/Europe/Simferopol.rb +140 -139
- data/lib/tzinfo/definitions/Europe/Sofia.rb +146 -145
- data/lib/tzinfo/definitions/Europe/Stockholm.rb +138 -137
- data/lib/tzinfo/definitions/Europe/Tallinn.rb +141 -140
- data/lib/tzinfo/definitions/Europe/Tirane.rb +151 -150
- data/lib/tzinfo/definitions/Europe/Uzhgorod.rb +142 -141
- data/lib/tzinfo/definitions/Europe/Vaduz.rb +133 -132
- data/lib/tzinfo/definitions/Europe/Vienna.rb +159 -158
- data/lib/tzinfo/definitions/Europe/Vilnius.rb +137 -136
- data/lib/tzinfo/definitions/Europe/Warsaw.rb +184 -183
- data/lib/tzinfo/definitions/Europe/Zaporozhye.rb +139 -138
- data/lib/tzinfo/definitions/Europe/Zurich.rb +140 -139
- data/lib/tzinfo/definitions/Indian/Antananarivo.rb +4 -4
- data/lib/tzinfo/definitions/Indian/Chagos.rb +3 -3
- data/lib/tzinfo/definitions/Indian/Christmas.rb +2 -2
- data/lib/tzinfo/definitions/Indian/Cocos.rb +2 -2
- data/lib/tzinfo/definitions/Indian/Comoro.rb +2 -2
- data/lib/tzinfo/definitions/Indian/Kerguelen.rb +2 -2
- data/lib/tzinfo/definitions/Indian/Mahe.rb +2 -2
- data/lib/tzinfo/definitions/Indian/Maldives.rb +3 -3
- data/lib/tzinfo/definitions/Indian/Mauritius.rb +2 -2
- data/lib/tzinfo/definitions/Indian/Mayotte.rb +2 -2
- data/lib/tzinfo/definitions/Indian/Reunion.rb +2 -2
- data/lib/tzinfo/definitions/MET.rb +151 -150
- data/lib/tzinfo/definitions/Pacific/Apia.rb +4 -4
- data/lib/tzinfo/definitions/Pacific/Auckland.rb +173 -172
- data/lib/tzinfo/definitions/Pacific/Chatham.rb +145 -144
- data/lib/tzinfo/definitions/Pacific/Easter.rb +163 -162
- data/lib/tzinfo/definitions/Pacific/Efate.rb +22 -22
- data/lib/tzinfo/definitions/Pacific/Enderbury.rb +4 -4
- data/lib/tzinfo/definitions/Pacific/Fakaofo.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Fiji.rb +6 -6
- data/lib/tzinfo/definitions/Pacific/Funafuti.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Galapagos.rb +3 -3
- data/lib/tzinfo/definitions/Pacific/Gambier.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Guadalcanal.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Guam.rb +4 -4
- data/lib/tzinfo/definitions/Pacific/Honolulu.rb +6 -6
- data/lib/tzinfo/definitions/Pacific/Johnston.rb +1 -1
- data/lib/tzinfo/definitions/Pacific/Kiritimati.rb +4 -4
- data/lib/tzinfo/definitions/Pacific/Kosrae.rb +4 -4
- data/lib/tzinfo/definitions/Pacific/Kwajalein.rb +4 -4
- data/lib/tzinfo/definitions/Pacific/Majuro.rb +3 -3
- data/lib/tzinfo/definitions/Pacific/Marquesas.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Midway.rb +6 -6
- data/lib/tzinfo/definitions/Pacific/Nauru.rb +5 -5
- data/lib/tzinfo/definitions/Pacific/Niue.rb +4 -4
- data/lib/tzinfo/definitions/Pacific/Norfolk.rb +3 -3
- data/lib/tzinfo/definitions/Pacific/Noumea.rb +8 -8
- data/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +6 -6
- data/lib/tzinfo/definitions/Pacific/Palau.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Pitcairn.rb +3 -3
- data/lib/tzinfo/definitions/Pacific/Ponape.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +3 -3
- data/lib/tzinfo/definitions/Pacific/Rarotonga.rb +28 -28
- data/lib/tzinfo/definitions/Pacific/Saipan.rb +5 -5
- data/lib/tzinfo/definitions/Pacific/Tahiti.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Tarawa.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Tongatapu.rb +10 -10
- data/lib/tzinfo/definitions/Pacific/Truk.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Wake.rb +2 -2
- data/lib/tzinfo/definitions/Pacific/Wallis.rb +2 -2
- data/lib/tzinfo/definitions/WET.rb +139 -138
- data/lib/tzinfo/timezone.rb +170 -175
- data/lib/tzinfo/timezone_period.rb +175 -0
- data/lib/tzinfo/timezone_period_list.rb +225 -0
- data/lib/tzinfo/tzdataparser.rb +99 -26
- data/test/tc_timezone.rb +231 -1
- data/test/tc_timezone_london.rb +13 -6
- data/test/tc_timezone_melbourne.rb +13 -6
- data/test/tc_timezone_new_york.rb +13 -6
- data/test/tc_timezone_period.rb +1 -1
- data/test/tc_timezone_period_list.rb +288 -0
- metadata +14 -12
- data/lib/tzinfo/definitions/Asia/Riyadh87.rb +0 -349
- data/lib/tzinfo/definitions/Asia/Riyadh88.rb +0 -350
- data/lib/tzinfo/definitions/Asia/Riyadh89.rb +0 -350
- data/lib/tzinfo/definitions/Mideast/Riyadh87.rb +0 -11
- data/lib/tzinfo/definitions/Mideast/Riyadh88.rb +0 -11
- data/lib/tzinfo/definitions/Mideast/Riyadh89.rb +0 -11
data/test/tc_timezone.rb
CHANGED
@@ -4,6 +4,9 @@ require 'tzinfo/timezone'
|
|
4
4
|
|
5
5
|
include TZInfo
|
6
6
|
|
7
|
+
class TCTimezoneBlockCalled < StandardError
|
8
|
+
end
|
9
|
+
|
7
10
|
class TCTimezone < Test::Unit::TestCase
|
8
11
|
def test_get_valid_1
|
9
12
|
tz = Timezone.get('Europe/London')
|
@@ -67,8 +70,9 @@ class TCTimezone < Test::Unit::TestCase
|
|
67
70
|
end
|
68
71
|
|
69
72
|
def test_get_case
|
73
|
+
Timezone.get('Europe/Prague')
|
70
74
|
assert_raise(InvalidTimezoneIdentifier) {
|
71
|
-
Timezone.get('Europe/
|
75
|
+
Timezone.get('Europe/prague')
|
72
76
|
}
|
73
77
|
end
|
74
78
|
|
@@ -195,6 +199,129 @@ class TCTimezone < Test::Unit::TestCase
|
|
195
199
|
assert_equal('UTC', Timezone.get('UTC').to_s)
|
196
200
|
end
|
197
201
|
|
202
|
+
def test_period_for_utc
|
203
|
+
dt = DateTime.new(2005,2,18,16,24,23)
|
204
|
+
t = Time.utc(2005,2,18,16,24,23)
|
205
|
+
|
206
|
+
dt_period = Timezone.get('Europe/London').period_for_utc(dt)
|
207
|
+
t_period = Timezone.get('Europe/London').period_for_utc(t)
|
208
|
+
|
209
|
+
assert_equal(DateTime.new(2004,10,31,1,0,0), dt_period.utc_start)
|
210
|
+
assert_equal(DateTime.new(2005,3,27,1,0,0), dt_period.utc_end)
|
211
|
+
|
212
|
+
assert_equal(DateTime.new(2004,10,31,1,0,0), t_period.utc_start)
|
213
|
+
assert_equal(DateTime.new(2005,3,27,1,0,0), t_period.utc_end)
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_period_for_local
|
217
|
+
dt = DateTime.new(2005,2,18,16,24,23)
|
218
|
+
t = Time.utc(2005,2,18,16,24,23)
|
219
|
+
|
220
|
+
dt_period = Timezone.get('Europe/London').period_for_local(dt)
|
221
|
+
t_period = Timezone.get('Europe/London').period_for_local(t)
|
222
|
+
|
223
|
+
assert_equal(DateTime.new(2004,10,31,1,0,0), dt_period.utc_start)
|
224
|
+
assert_equal(DateTime.new(2005,3,27,1,0,0), dt_period.utc_end)
|
225
|
+
|
226
|
+
assert_equal(DateTime.new(2004,10,31,1,0,0), t_period.utc_start)
|
227
|
+
assert_equal(DateTime.new(2005,3,27,1,0,0), t_period.utc_end)
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_period_for_local_invalid
|
231
|
+
assert_raise(PeriodNotFound) {
|
232
|
+
Timezone.get('America/New_York').period_for_local(DateTime.new(2004,4,4,2,30,0))
|
233
|
+
}
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_period_for_local_ambiguous
|
237
|
+
assert_raise(AmbiguousTime) {
|
238
|
+
Timezone.get('America/New_York').period_for_local(DateTime.new(2004,10,31,1,30,0))
|
239
|
+
}
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_period_for_local_dst_flag_resolved
|
243
|
+
dt = DateTime.new(2004,10,31,1,30,0)
|
244
|
+
tz = Timezone.get('America/New_York')
|
245
|
+
|
246
|
+
assert_period_for(DateTime.new(2004,4,4,7,0,0), DateTime.new(2004,10,31,6,0,0), true, tz.period_for_local(dt, true))
|
247
|
+
assert_period_for(DateTime.new(2004,10,31,6,0,0), DateTime.new(2005,4,3,7,0,0), false, tz.period_for_local(dt, false))
|
248
|
+
assert_period_for(DateTime.new(2004,4,4,7,0,0), DateTime.new(2004,10,31,6,0,0), true, tz.period_for_local(dt, true) {|periods| raise TCTimezoneBlockCalled, 'should not be called' })
|
249
|
+
assert_period_for(DateTime.new(2004,10,31,6,0,0), DateTime.new(2005,4,3,7,0,0), false, tz.period_for_local(dt, false) {|periods| raise TCTimezoneBlockCalled, 'should not be called' })
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_period_for_local_dst_block_called
|
253
|
+
dt = DateTime.new(2004,10,31,1,30,0)
|
254
|
+
tz = Timezone.get('America/New_York')
|
255
|
+
|
256
|
+
assert_raise(TCTimezoneBlockCalled) {
|
257
|
+
tz.period_for_local(dt) {|periods|
|
258
|
+
assert_equal(2, periods.size)
|
259
|
+
assert_period_for(DateTime.new(2004,4,4,7,0,0), DateTime.new(2004,10,31,6,0,0), true, periods[0])
|
260
|
+
assert_period_for(DateTime.new(2004,10,31,6,0,0), DateTime.new(2005,4,3,7,0,0), false, periods[1])
|
261
|
+
|
262
|
+
# raise exception to test that the block was called
|
263
|
+
raise TCTimezoneBlockCalled, 'should be raised'
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
assert_period_for(DateTime.new(2004,4,4,7,0,0), DateTime.new(2004,10,31,6,0,0), true, tz.period_for_local(dt) {|periods| periods.first})
|
268
|
+
assert_period_for(DateTime.new(2004,10,31,6,0,0), DateTime.new(2005,4,3,7,0,0), false, tz.period_for_local(dt) {|periods| periods.last})
|
269
|
+
assert_period_for(DateTime.new(2004,4,4,7,0,0), DateTime.new(2004,10,31,6,0,0), true, tz.period_for_local(dt) {|periods| [periods.first]})
|
270
|
+
assert_period_for(DateTime.new(2004,10,31,6,0,0), DateTime.new(2005,4,3,7,0,0), false, tz.period_for_local(dt) {|periods| [periods.last]})
|
271
|
+
end
|
272
|
+
|
273
|
+
def test_period_for_local_dst_cannot_resolve
|
274
|
+
# At midnight local time on Aug 5 1915 in Warsaw, the clocks were put back
|
275
|
+
# 24 minutes and both periods were non-DST. Hence the block should be
|
276
|
+
# called regardless of the value of the Boolean dst parameter.
|
277
|
+
|
278
|
+
dt = DateTime.new(1915,8,4,23,40,0)
|
279
|
+
tz = Timezone.get('Europe/Warsaw')
|
280
|
+
|
281
|
+
assert_raise(TCTimezoneBlockCalled) {
|
282
|
+
tz.period_for_local(dt, true) {|periods|
|
283
|
+
assert_equal(2, periods.size)
|
284
|
+
assert_equal(DateTime.new(1915,8,4,22,36,0), periods[0].utc_end)
|
285
|
+
assert_equal(false, periods[0].dst?)
|
286
|
+
assert_period_for(DateTime.new(1915,8,4,22,36,0), DateTime.new(1916,4,30,22,0,0), false, periods[1])
|
287
|
+
|
288
|
+
raise TCTimezoneBlockCalled, 'should be raised'
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
assert_raise(TCTimezoneBlockCalled) {
|
293
|
+
tz.period_for_local(dt, false) {|periods|
|
294
|
+
assert_equal(2, periods.size)
|
295
|
+
assert_equal(DateTime.new(1915,8,4,22,36,0), periods[0].utc_end)
|
296
|
+
assert_equal(false, periods[0].dst?)
|
297
|
+
assert_period_for(DateTime.new(1915,8,4,22,36,0), DateTime.new(1916,4,30,22,0,0), false, periods[1])
|
298
|
+
|
299
|
+
raise TCTimezoneBlockCalled, 'should be raised'
|
300
|
+
}
|
301
|
+
}
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_period_for_local_block_ambiguous
|
305
|
+
dt = DateTime.new(2004,10,31,1,30,0)
|
306
|
+
tz = Timezone.get('America/New_York')
|
307
|
+
|
308
|
+
assert_raise(AmbiguousTime) {
|
309
|
+
tz.period_for_local(dt) {|periods| nil}
|
310
|
+
}
|
311
|
+
|
312
|
+
assert_raise(AmbiguousTime) {
|
313
|
+
tz.period_for_local(dt) {|periods| periods}
|
314
|
+
}
|
315
|
+
|
316
|
+
assert_raise(AmbiguousTime) {
|
317
|
+
tz.period_for_local(dt) {|periods| []}
|
318
|
+
}
|
319
|
+
|
320
|
+
assert_raise(AmbiguousTime) {
|
321
|
+
tz.period_for_local(dt) {|periods| raise AmbiguousTime, 'Ambiguous time'}
|
322
|
+
}
|
323
|
+
end
|
324
|
+
|
198
325
|
def test_utc_to_local
|
199
326
|
dt = DateTime.new(2005,2,18,16,24,23)
|
200
327
|
t = Time.utc(2005,2,18,16,24,23)
|
@@ -215,6 +342,102 @@ class TCTimezone < Test::Unit::TestCase
|
|
215
342
|
assert_not_equal(dt, Timezone.get('Europe/London').local_to_utc(t))
|
216
343
|
end
|
217
344
|
|
345
|
+
def test_local_to_utc_invalid
|
346
|
+
assert_raise(PeriodNotFound) {
|
347
|
+
Timezone.get('America/New_York').local_to_utc(DateTime.new(2004,4,4,2,30,0))
|
348
|
+
}
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_local_to_utc_ambiguous
|
352
|
+
assert_raise(AmbiguousTime) {
|
353
|
+
Timezone.get('America/New_York').local_to_utc(DateTime.new(2004,10,31,1,30,0))
|
354
|
+
}
|
355
|
+
end
|
356
|
+
|
357
|
+
def test_local_to_utc_dst_flag_resolved
|
358
|
+
dt = DateTime.new(2004,10,31,1,30,0)
|
359
|
+
tz = Timezone.get('America/New_York')
|
360
|
+
|
361
|
+
assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt, true))
|
362
|
+
assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt, false))
|
363
|
+
assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt, true) {|periods| raise TCTimezoneBlockCalled, 'should not be called' })
|
364
|
+
assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt, false) {|periods| raise TCTimezoneBlockCalled, 'should not be called' })
|
365
|
+
end
|
366
|
+
|
367
|
+
def test_local_to_utc_dst_block_called
|
368
|
+
dt = DateTime.new(2004,10,31,1,30,0)
|
369
|
+
tz = Timezone.get('America/New_York')
|
370
|
+
|
371
|
+
assert_raise(TCTimezoneBlockCalled) {
|
372
|
+
tz.local_to_utc(dt) {|periods|
|
373
|
+
assert_equal(2, periods.size)
|
374
|
+
assert_period_for(DateTime.new(2004,4,4,7,0,0), DateTime.new(2004,10,31,6,0,0), true, periods[0])
|
375
|
+
assert_period_for(DateTime.new(2004,10,31,6,0,0), DateTime.new(2005,4,3,7,0,0), false, periods[1])
|
376
|
+
|
377
|
+
# raise exception to test that the block was called
|
378
|
+
raise TCTimezoneBlockCalled, 'should be raised'
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt) {|periods| periods.first})
|
383
|
+
assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt) {|periods| periods.last})
|
384
|
+
end
|
385
|
+
|
386
|
+
def test_local_to_utc_dst_cannot_resolve
|
387
|
+
# At midnight local time on Aug 5 1915 in Warsaw, the clocks were put back
|
388
|
+
# 24 minutes and both periods were non-DST. Hence the block should be
|
389
|
+
# called regardless of the value of the Boolean dst parameter.
|
390
|
+
|
391
|
+
dt = DateTime.new(1915,8,4,23,40,0)
|
392
|
+
tz = Timezone.get('Europe/Warsaw')
|
393
|
+
|
394
|
+
assert_raise(TCTimezoneBlockCalled) {
|
395
|
+
tz.local_to_utc(dt, true) {|periods|
|
396
|
+
assert_equal(2, periods.size)
|
397
|
+
assert_equal(DateTime.new(1915,8,4,22,36,0), periods[0].utc_end)
|
398
|
+
assert_equal(false, periods[0].dst?)
|
399
|
+
assert_period_for(DateTime.new(1915,8,4,22,36,0), DateTime.new(1916,4,30,22,0,0), false, periods[1])
|
400
|
+
|
401
|
+
raise TCTimezoneBlockCalled, 'should be raised'
|
402
|
+
}
|
403
|
+
}
|
404
|
+
|
405
|
+
assert_raise(TCTimezoneBlockCalled) {
|
406
|
+
tz.local_to_utc(dt, false) {|periods|
|
407
|
+
assert_equal(2, periods.size)
|
408
|
+
assert_equal(DateTime.new(1915,8,4,22,36,0), periods[0].utc_end)
|
409
|
+
assert_equal(false, periods[0].dst?)
|
410
|
+
assert_period_for(DateTime.new(1915,8,4,22,36,0), DateTime.new(1916,4,30,22,0,0), false, periods[1])
|
411
|
+
|
412
|
+
raise TCTimezoneBlockCalled, 'should be raised'
|
413
|
+
}
|
414
|
+
}
|
415
|
+
|
416
|
+
assert_equal(DateTime.new(1915,8,4,22,16,0), tz.local_to_utc(dt) {|periods| periods.first})
|
417
|
+
assert_equal(DateTime.new(1915,8,4,22,40,0), tz.local_to_utc(dt) {|periods| periods.last})
|
418
|
+
end
|
419
|
+
|
420
|
+
def test_local_to_utc_block_ambiguous
|
421
|
+
dt = DateTime.new(2004,10,31,1,30,0)
|
422
|
+
tz = Timezone.get('America/New_York')
|
423
|
+
|
424
|
+
assert_raise(AmbiguousTime) {
|
425
|
+
tz.local_to_utc(dt) {|periods| nil}
|
426
|
+
}
|
427
|
+
|
428
|
+
assert_raise(AmbiguousTime) {
|
429
|
+
tz.local_to_utc(dt) {|periods| periods}
|
430
|
+
}
|
431
|
+
|
432
|
+
assert_raise(AmbiguousTime) {
|
433
|
+
tz.local_to_utc(dt) {|periods| []}
|
434
|
+
}
|
435
|
+
|
436
|
+
assert_raise(AmbiguousTime) {
|
437
|
+
tz.local_to_utc(dt) {|periods| raise AmbiguousTime, 'Ambiguous time'}
|
438
|
+
}
|
439
|
+
end
|
440
|
+
|
218
441
|
def test_now
|
219
442
|
assert_kind_of(Time, Timezone.get('Europe/London').now)
|
220
443
|
end
|
@@ -259,4 +482,11 @@ class TCTimezone < Test::Unit::TestCase
|
|
259
482
|
assert((Timezone.get('America/New_York') <=> Timezone.get('Europe/Paris')) < 0)
|
260
483
|
assert((Timezone.get('Europe/Paris') <=> Timezone.get('America/New_York')) > 0)
|
261
484
|
end
|
485
|
+
|
486
|
+
private
|
487
|
+
def assert_period_for(utc_start, utc_end, dst, period)
|
488
|
+
assert_equal(utc_start, period.utc_start)
|
489
|
+
assert_equal(utc_end, period.utc_end)
|
490
|
+
assert_equal(dst, period.dst?)
|
491
|
+
end
|
262
492
|
end
|
data/test/tc_timezone_london.rb
CHANGED
@@ -19,10 +19,13 @@ class TCTimezoneLondon < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
assert_equal(DateTime.new(2004,3,28,0,59,59), tz.local_to_utc(DateTime.new(2004,3,28,0,59,59)))
|
21
21
|
assert_equal(DateTime.new(2004,3,28,1,0,0), tz.local_to_utc(DateTime.new(2004,3,28,2,0,0)))
|
22
|
-
assert_equal(DateTime.new(2004,10,31,0,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59)))
|
23
|
-
assert_equal(DateTime.new(2004,10,31,
|
22
|
+
assert_equal(DateTime.new(2004,10,31,0,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), true))
|
23
|
+
assert_equal(DateTime.new(2004,10,31,1,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), false))
|
24
|
+
assert_equal(DateTime.new(2004,10,31,0,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), true))
|
25
|
+
assert_equal(DateTime.new(2004,10,31,1,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), false))
|
24
26
|
|
25
27
|
assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,3,28,1,0,0)) }
|
28
|
+
assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) }
|
26
29
|
|
27
30
|
assert_equal(:GMT, tz.period_for_utc(DateTime.new(2004,3,28,0,59,59)).zone_identifier)
|
28
31
|
assert_equal(:BST, tz.period_for_utc(DateTime.new(2004,3,28,1,0,0)).zone_identifier)
|
@@ -31,8 +34,10 @@ class TCTimezoneLondon < Test::Unit::TestCase
|
|
31
34
|
|
32
35
|
assert_equal(:GMT, tz.period_for_local(DateTime.new(2004,3,28,0,59,59)).zone_identifier)
|
33
36
|
assert_equal(:BST, tz.period_for_local(DateTime.new(2004,3,28,2,0,0)).zone_identifier)
|
34
|
-
assert_equal(:BST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).zone_identifier)
|
35
|
-
assert_equal(:
|
37
|
+
assert_equal(:BST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).zone_identifier)
|
38
|
+
assert_equal(:GMT, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).zone_identifier)
|
39
|
+
assert_equal(:BST, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).zone_identifier)
|
40
|
+
assert_equal(:GMT, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).zone_identifier)
|
36
41
|
|
37
42
|
assert_equal(0, tz.period_for_utc(DateTime.new(2004,3,28,0,59,59)).utc_total_offset)
|
38
43
|
assert_equal(3600, tz.period_for_utc(DateTime.new(2004,3,28,1,0,0)).utc_total_offset)
|
@@ -41,7 +46,9 @@ class TCTimezoneLondon < Test::Unit::TestCase
|
|
41
46
|
|
42
47
|
assert_equal(0, tz.period_for_local(DateTime.new(2004,3,28,0,59,59)).utc_total_offset)
|
43
48
|
assert_equal(3600, tz.period_for_local(DateTime.new(2004,3,28,2,0,0)).utc_total_offset)
|
44
|
-
assert_equal(3600, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).utc_total_offset)
|
45
|
-
assert_equal(
|
49
|
+
assert_equal(3600, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).utc_total_offset)
|
50
|
+
assert_equal(0, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).utc_total_offset)
|
51
|
+
assert_equal(3600, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).utc_total_offset)
|
52
|
+
assert_equal(0, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).utc_total_offset)
|
46
53
|
end
|
47
54
|
end
|
@@ -17,20 +17,25 @@ class TCTimezoneMelbourne < Test::Unit::TestCase
|
|
17
17
|
assert_equal(DateTime.new(2004,10,31,1,59,59), tz.utc_to_local(DateTime.new(2004,10,30,15,59,59)))
|
18
18
|
assert_equal(DateTime.new(2004,10,31,3,0,0), tz.utc_to_local(DateTime.new(2004,10,30,16,0,0)))
|
19
19
|
|
20
|
-
assert_equal(DateTime.new(2004,3,27,15,59,59), tz.local_to_utc(DateTime.new(2004,3,28,2,59,59)))
|
21
|
-
assert_equal(DateTime.new(2004,3,27,
|
20
|
+
assert_equal(DateTime.new(2004,3,27,15,59,59), tz.local_to_utc(DateTime.new(2004,3,28,2,59,59), true))
|
21
|
+
assert_equal(DateTime.new(2004,3,27,16,59,59), tz.local_to_utc(DateTime.new(2004,3,28,2,59,59), false))
|
22
|
+
assert_equal(DateTime.new(2004,3,27,15,0,0), tz.local_to_utc(DateTime.new(2004,3,28,2,0,0), true))
|
23
|
+
assert_equal(DateTime.new(2004,3,27,16,0,0), tz.local_to_utc(DateTime.new(2004,3,28,2,0,0), false))
|
22
24
|
assert_equal(DateTime.new(2004,10,30,15,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59)))
|
23
25
|
assert_equal(DateTime.new(2004,10,30,16,0,0), tz.local_to_utc(DateTime.new(2004,10,31,3,0,0)))
|
24
26
|
|
25
27
|
assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,10,31,2,0,0)) }
|
28
|
+
assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,3,28,2,0,0)) }
|
26
29
|
|
27
30
|
assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,3,27,15,59,59)).zone_identifier)
|
28
31
|
assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,3,27,16,0,0)).zone_identifier)
|
29
32
|
assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,10,30,15,59,59)).zone_identifier)
|
30
33
|
assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,10,30,16,0,0)).zone_identifier)
|
31
34
|
|
32
|
-
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,3,28,2,59,59)).zone_identifier)
|
33
|
-
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,3,28,2,
|
35
|
+
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), true).zone_identifier)
|
36
|
+
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), false).zone_identifier)
|
37
|
+
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), true).zone_identifier)
|
38
|
+
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), false).zone_identifier)
|
34
39
|
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).zone_identifier)
|
35
40
|
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,10,31,3,0,0)).zone_identifier)
|
36
41
|
|
@@ -39,8 +44,10 @@ class TCTimezoneMelbourne < Test::Unit::TestCase
|
|
39
44
|
assert_equal(36000, tz.period_for_utc(DateTime.new(2004,10,30,15,59,59)).utc_total_offset)
|
40
45
|
assert_equal(39600, tz.period_for_utc(DateTime.new(2004,10,30,16,0,0)).utc_total_offset)
|
41
46
|
|
42
|
-
assert_equal(39600, tz.period_for_local(DateTime.new(2004,3,28,2,59,59)).utc_total_offset)
|
43
|
-
assert_equal(
|
47
|
+
assert_equal(39600, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), true).utc_total_offset)
|
48
|
+
assert_equal(36000, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), false).utc_total_offset)
|
49
|
+
assert_equal(39600, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), true).utc_total_offset)
|
50
|
+
assert_equal(36000, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), false).utc_total_offset)
|
44
51
|
assert_equal(36000, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).utc_total_offset)
|
45
52
|
assert_equal(39600, tz.period_for_local(DateTime.new(2004,10,31,3,0,0)).utc_total_offset)
|
46
53
|
end
|
@@ -19,10 +19,13 @@ class TCTimezoneNewYork < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
assert_equal(DateTime.new(2004,4,4,6,59,59), tz.local_to_utc(DateTime.new(2004,4,4,1,59,59)))
|
21
21
|
assert_equal(DateTime.new(2004,4,4,7,0,0), tz.local_to_utc(DateTime.new(2004,4,4,3,0,0)))
|
22
|
-
assert_equal(DateTime.new(2004,10,31,5,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59)))
|
23
|
-
assert_equal(DateTime.new(2004,10,31,
|
22
|
+
assert_equal(DateTime.new(2004,10,31,5,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), true))
|
23
|
+
assert_equal(DateTime.new(2004,10,31,6,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), false))
|
24
|
+
assert_equal(DateTime.new(2004,10,31,5,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), true))
|
25
|
+
assert_equal(DateTime.new(2004,10,31,6,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), false))
|
24
26
|
|
25
27
|
assert_raise(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,4,4,2,0,0)) }
|
28
|
+
assert_raise(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) }
|
26
29
|
|
27
30
|
assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,4,4,6,59,59)).zone_identifier)
|
28
31
|
assert_equal(:EDT, tz.period_for_utc(DateTime.new(2004,4,4,7,0,0)).zone_identifier)
|
@@ -31,8 +34,10 @@ class TCTimezoneNewYork < Test::Unit::TestCase
|
|
31
34
|
|
32
35
|
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,4,4,1,59,59)).zone_identifier)
|
33
36
|
assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,4,4,3,0,0)).zone_identifier)
|
34
|
-
assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).zone_identifier)
|
35
|
-
assert_equal(:
|
37
|
+
assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).zone_identifier)
|
38
|
+
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).zone_identifier)
|
39
|
+
assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).zone_identifier)
|
40
|
+
assert_equal(:EST, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).zone_identifier)
|
36
41
|
|
37
42
|
assert_equal(-18000, tz.period_for_utc(DateTime.new(2004,4,4,6,59,59)).utc_total_offset)
|
38
43
|
assert_equal(-14400, tz.period_for_utc(DateTime.new(2004,4,4,7,0,0)).utc_total_offset)
|
@@ -41,7 +46,9 @@ class TCTimezoneNewYork < Test::Unit::TestCase
|
|
41
46
|
|
42
47
|
assert_equal(-18000, tz.period_for_local(DateTime.new(2004,4,4,1,59,59)).utc_total_offset)
|
43
48
|
assert_equal(-14400, tz.period_for_local(DateTime.new(2004,4,4,3,0,0)).utc_total_offset)
|
44
|
-
assert_equal(-14400, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).utc_total_offset)
|
45
|
-
assert_equal(-
|
49
|
+
assert_equal(-14400, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).utc_total_offset)
|
50
|
+
assert_equal(-18000, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).utc_total_offset)
|
51
|
+
assert_equal(-14400, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).utc_total_offset)
|
52
|
+
assert_equal(-18000, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).utc_total_offset)
|
46
53
|
end
|
47
54
|
end
|
data/test/tc_timezone_period.rb
CHANGED
@@ -0,0 +1,288 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'test/unit'
|
3
|
+
require 'tzinfo/timezone_period_list'
|
4
|
+
|
5
|
+
include TZInfo
|
6
|
+
|
7
|
+
class TCTimezonePeriod < Test::Unit::TestCase
|
8
|
+
def test_add
|
9
|
+
# Just a test for no exception
|
10
|
+
|
11
|
+
list = TimezonePeriodList.new
|
12
|
+
list.add(2005, 1) { TimezonePeriod.new(DateTime.new(2005,1,1,1,0,0), DateTime.new(2005,3,1,1,0,0), 0, 0, :TEST) }
|
13
|
+
list.add(2005, 3) { TimezonePeriod.new(DateTime.new(2005,3,1,1,0,0), DateTime.new(2005,5,1,1,0,0), 0, 0, :TEST) }
|
14
|
+
list.add(2005, 5) { TimezonePeriod.new(DateTime.new(2005,5,1,1,0,0), DateTime.new(2005,5,2,1,0,0), 0, 0, :TEST) }
|
15
|
+
list.add(2005, 5) { TimezonePeriod.new(DateTime.new(2005,5,2,1,0,0), DateTime.new(2005,7,1,1,0,0), 0, 0, :TEST) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_add_incorrect_order
|
19
|
+
list = TimezonePeriodList.new
|
20
|
+
list.add(2005, 1) { TimezonePeriod.new(DateTime.new(2005,1,1,1,0,0), DateTime.new(2005,2,1,1,0,0), 0, 0, :TEST) }
|
21
|
+
list.add(2005, 3) { TimezonePeriod.new(DateTime.new(2005,3,1,1,0,0), DateTime.new(2005,5,1,1,0,0), 0, 0, :TEST) }
|
22
|
+
|
23
|
+
assert_raise(ArgumentError) {
|
24
|
+
list.add(2005, 2) { TimezonePeriod.new(DateTime.new(2005,2,1,1,0,0), DateTime.new(2005,3,1,1,0,0), 0, 0, :TEST) }
|
25
|
+
}
|
26
|
+
|
27
|
+
assert_raise(ArgumentError) {
|
28
|
+
list.add(2004, 12) { TimezonePeriod.new(DateTime.new(2004,12,1,1,0,0), DateTime.new(2005,1,1,1,0,0), 0, 0, :TEST) }
|
29
|
+
}
|
30
|
+
|
31
|
+
assert_raise(ArgumentError) {
|
32
|
+
list.add_unbounded_start { TimezonePeriod.new(nil, DateTime.new(2005,1,1,1,0,0), 0, 0, :TEST) }
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_add_incorrect_order_unbounded
|
37
|
+
list = TimezonePeriodList.new
|
38
|
+
list.add_unbounded_start { TimezonePeriod.new(nil, DateTime.new(2005,1,1,1,0,0), 0, 0, :TEST) }
|
39
|
+
|
40
|
+
assert_raise(ArgumentError) {
|
41
|
+
list.add_unbounded_start { TimezonePeriod.new(nil, DateTime.new(2005,1,1,1,0,0), 0, 0, :TEST) }
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_period_for_utc
|
46
|
+
list = TimezonePeriodList.new
|
47
|
+
list.add(2000, 4) { TimezonePeriod.new(DateTime.new(2000,4,1,1,0,0),DateTime.new(2000,10,1,1,0,0),-18000,3600,:'TESTD') }
|
48
|
+
list.add(2000, 10) { TimezonePeriod.new(DateTime.new(2000,10,1,1,0,0),DateTime.new(2001,3,1,1,0,0),-18000,0,:'TESTS') }
|
49
|
+
list.add(2001, 3) { TimezonePeriod.new(DateTime.new(2001,3,1,1,0,0),DateTime.new(2001,4,1,1,0,0),-18000,3600,:'TESTD') }
|
50
|
+
list.add(2001, 4) { TimezonePeriod.new(DateTime.new(2001,4,1,1,0,0),DateTime.new(2001,10,1,1,0,0),-21600,3600,:'TESTD') }
|
51
|
+
list.add(2001, 10) { TimezonePeriod.new(DateTime.new(2001,10,1,1,0,0),DateTime.new(2002,10,1,1,0,0),-18000,0,:'TESTS') }
|
52
|
+
list.add(2002, 10) { TimezonePeriod.new(DateTime.new(2002,10,1,1,0,0),DateTime.new(2003,2,1,1,0,0),-18000,0,:'TESTS') }
|
53
|
+
|
54
|
+
# TimezonePeriodList expands out blocks and caches the results
|
55
|
+
# run twice to ensure this is being done correctly
|
56
|
+
2.times {|i|
|
57
|
+
assert_raise(PeriodNotFound) {
|
58
|
+
list.period_for_utc(DateTime.new(1999,12,1,0,0,0))
|
59
|
+
}
|
60
|
+
assert_raise(PeriodNotFound) {
|
61
|
+
list.period_for_utc(DateTime.new(2000,4,1,0,59,59))
|
62
|
+
}
|
63
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2000,4,1,1,0,0),DateTime.new(2000,10,1,1,0,0),-18000,3600,:'TESTD'),
|
64
|
+
list.period_for_utc(DateTime.new(2000,4,1,1,0,0)))
|
65
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2000,4,1,1,0,0),DateTime.new(2000,10,1,1,0,0),-18000,3600,:'TESTD'),
|
66
|
+
list.period_for_utc(DateTime.new(2000,10,1,0,59,59)))
|
67
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2000,10,1,1,0,0),DateTime.new(2001,3,1,1,0,0),-18000,0,:'TESTS'),
|
68
|
+
list.period_for_utc(DateTime.new(2000,10,1,1,0,0)))
|
69
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2000,10,1,1,0,0),DateTime.new(2001,3,1,1,0,0),-18000,0,:'TESTS'),
|
70
|
+
list.period_for_utc(DateTime.new(2001,3,1,0,59,59)))
|
71
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,3,1,1,0,0),DateTime.new(2001,4,1,1,0,0),-18000,3600,:'TESTD'),
|
72
|
+
list.period_for_utc(DateTime.new(2001,3,1,1,0,0)))
|
73
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,3,1,1,0,0),DateTime.new(2001,4,1,1,0,0),-18000,3600,:'TESTD'),
|
74
|
+
list.period_for_utc(DateTime.new(2001,4,1,0,59,59)))
|
75
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,4,1,1,0,0),DateTime.new(2001,10,1,1,0,0),-21600,3600,:'TESTD'),
|
76
|
+
list.period_for_utc(DateTime.new(2001,4,1,1,0,0)))
|
77
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,4,1,1,0,0),DateTime.new(2001,10,1,1,0,0),-21600,3600,:'TESTD'),
|
78
|
+
list.period_for_utc(DateTime.new(2001,10,1,0,59,59)))
|
79
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,10,1,1,0,0),DateTime.new(2002,10,1,1,0,0),-18000,0,:'TESTS'),
|
80
|
+
list.period_for_utc(DateTime.new(2001,10,1,1,0,0)))
|
81
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,10,1,1,0,0),DateTime.new(2002,10,1,1,0,0),-18000,0,:'TESTS'),
|
82
|
+
list.period_for_utc(DateTime.new(2002,2,1,1,0,0)))
|
83
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,10,1,1,0,0),DateTime.new(2002,10,1,1,0,0),-18000,0,:'TESTS'),
|
84
|
+
list.period_for_utc(DateTime.new(2002,10,1,0,59,59)))
|
85
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2002,10,1,1,0,0),DateTime.new(2003,2,1,1,0,0),-18000,0,:'TESTS'),
|
86
|
+
list.period_for_utc(DateTime.new(2002,10,1,1,0,0)))
|
87
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2002,10,1,1,0,0),DateTime.new(2003,2,1,1,0,0),-18000,0,:'TESTS'),
|
88
|
+
list.period_for_utc(DateTime.new(2003,2,1,0,59,59)))
|
89
|
+
|
90
|
+
assert_raise(PeriodNotFound) {
|
91
|
+
list.period_for_utc(DateTime.new(2003,2,1,1,0,0))
|
92
|
+
}
|
93
|
+
assert_raise(PeriodNotFound) {
|
94
|
+
list.period_for_utc(DateTime.new(2004,1,1,1,0,0))
|
95
|
+
}
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_period_for_utc_unbounded
|
100
|
+
list = TimezonePeriodList.new
|
101
|
+
list.add_unbounded_start { TimezonePeriod.new(nil,DateTime.new(2000,10,1,1,0,0),-18000,3600,:'TESTD') }
|
102
|
+
list.add(2000, 10) { TimezonePeriod.new(DateTime.new(2000,10,1,1,0,0),DateTime.new(2001,3,1,1,0,0),-18000,0,:'TESTS') }
|
103
|
+
list.add(2001, 3) { TimezonePeriod.new(DateTime.new(2001,3,1,1,0,0),nil,-18000,3600,:'TESTD') }
|
104
|
+
|
105
|
+
assert_period_equal(TimezonePeriod.new(nil,DateTime.new(2000,10,1,1,0,0),-18000,3600,:'TESTD'),
|
106
|
+
list.period_for_utc(DateTime.new(1999,12,1,1,0,0)))
|
107
|
+
assert_period_equal(TimezonePeriod.new(nil,DateTime.new(2000,10,1,1,0,0),-18000,3600,:'TESTD'),
|
108
|
+
list.period_for_utc(DateTime.new(2000,10,1,0,59,59)))
|
109
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2000,10,1,1,0,0),DateTime.new(2001,3,1,1,0,0),-18000,0,:'TESTS'),
|
110
|
+
list.period_for_utc(DateTime.new(2000,10,1,1,0,0)))
|
111
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2000,10,1,1,0,0),DateTime.new(2001,3,1,1,0,0),-18000,0,:'TESTS'),
|
112
|
+
list.period_for_utc(DateTime.new(2001,3,1,0,59,59)))
|
113
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,3,1,1,0,0),nil,-18000,3600,:'TESTD'),
|
114
|
+
list.period_for_utc(DateTime.new(2001,3,1,1,0,0)))
|
115
|
+
assert_period_equal(TimezonePeriod.new(DateTime.new(2001,3,1,1,0,0),nil,-18000,3600,:'TESTD'),
|
116
|
+
list.period_for_utc(DateTime.new(2002,1,1,1,0,0)))
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_period_for_utc_gap
|
120
|
+
list = TimezonePeriodList.new
|
121
|
+
list.add(2000, 4) { TimezonePeriod.new(DateTime.new(2000,4,1,1,0,0),DateTime.new(2000,5,1,1,0,0),-18000,3600,:'TESTD') }
|
122
|
+
list.add(2000, 10) { TimezonePeriod.new(DateTime.new(2000,10,1,1,0,0),DateTime.new(2001,3,1,1,0,0),-18000,0,:'TESTS') }
|
123
|
+
|
124
|
+
assert_raise(PeriodNotFound) {
|
125
|
+
list.period_for_utc(DateTime.new(2005,5,1,1,0,0))
|
126
|
+
}
|
127
|
+
|
128
|
+
assert_raise(PeriodNotFound) {
|
129
|
+
list.period_for_utc(DateTime.new(2005,10,1,0,59,59))
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_period_for_utc_empty
|
134
|
+
list = TimezonePeriodList.new
|
135
|
+
assert_raise(PeriodNotFound) {
|
136
|
+
list.period_for_utc(DateTime.new(2005,1,1,0,0,0))
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_periods_for_local
|
141
|
+
list = TimezonePeriodList.new
|
142
|
+
list.add(2000, 4) { TimezonePeriod.new(DateTime.new(2000,4,2,1,0,0),DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD') }
|
143
|
+
list.add(2000, 10) { TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS') }
|
144
|
+
list.add(2001, 3) { TimezonePeriod.new(DateTime.new(2001,3,2,1,0,0),DateTime.new(2001,4,2,1,0,0),-18000,3600,:'TESTD') }
|
145
|
+
list.add(2001, 4) { TimezonePeriod.new(DateTime.new(2001,4,2,1,0,0),DateTime.new(2001,10,2,1,0,0),-21600,3600,:'TESTD') }
|
146
|
+
list.add(2001, 10) { TimezonePeriod.new(DateTime.new(2001,10,2,1,0,0),DateTime.new(2002,10,2,1,0,0),-18000,0,:'TESTS') }
|
147
|
+
list.add(2002, 10) { TimezonePeriod.new(DateTime.new(2002,10,2,1,0,0),DateTime.new(2003,2,2,1,0,0),-18000,0,:'TESTS') }
|
148
|
+
|
149
|
+
# TimezonePeriodList expands out blocks and caches the results
|
150
|
+
# run twice to ensure this is being done correctly
|
151
|
+
2.times {|i|
|
152
|
+
assert_raise(PeriodNotFound) {
|
153
|
+
list.periods_for_local(DateTime.new(1999,12,1,0,0,0))
|
154
|
+
}
|
155
|
+
assert_raise(PeriodNotFound) {
|
156
|
+
list.periods_for_local(DateTime.new(2000,4,1,20,59,59))
|
157
|
+
}
|
158
|
+
|
159
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,4,2,1,0,0),DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD')],
|
160
|
+
list.periods_for_local(DateTime.new(2000,4,1,21,0,0)))
|
161
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,4,2,1,0,0),DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD')],
|
162
|
+
list.periods_for_local(DateTime.new(2000,10,1,19,59,59)))
|
163
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,4,2,1,0,0),DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD'),
|
164
|
+
TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
165
|
+
list.periods_for_local(DateTime.new(2000,10,1,20,0,0)))
|
166
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,4,2,1,0,0),DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD'),
|
167
|
+
TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
168
|
+
list.periods_for_local(DateTime.new(2000,10,1,20,59,59)))
|
169
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
170
|
+
list.periods_for_local(DateTime.new(2000,10,1,21,0,0)))
|
171
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
172
|
+
list.periods_for_local(DateTime.new(2001,3,1,19,59,59)))
|
173
|
+
|
174
|
+
assert_raise(PeriodNotFound) {
|
175
|
+
list.periods_for_local(DateTime.new(2001,3,1,20,0,0))
|
176
|
+
}
|
177
|
+
assert_raise(PeriodNotFound) {
|
178
|
+
list.periods_for_local(DateTime.new(2001,3,1,20,59,59))
|
179
|
+
}
|
180
|
+
|
181
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,3,2,1,0,0),DateTime.new(2001,4,2,1,0,0),-18000,3600,:'TESTD')],
|
182
|
+
list.periods_for_local(DateTime.new(2001,3,1,21,0,0)))
|
183
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,3,2,1,0,0),DateTime.new(2001,4,2,1,0,0),-18000,3600,:'TESTD')],
|
184
|
+
list.periods_for_local(DateTime.new(2001,4,1,19,59,59)))
|
185
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,3,2,1,0,0),DateTime.new(2001,4,2,1,0,0),-18000,3600,:'TESTD'),
|
186
|
+
TimezonePeriod.new(DateTime.new(2001,4,2,1,0,0),DateTime.new(2001,10,2,1,0,0),-21600,3600,:'TESTD')],
|
187
|
+
list.periods_for_local(DateTime.new(2001,4,1,20,0,0)))
|
188
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,3,2,1,0,0),DateTime.new(2001,4,2,1,0,0),-18000,3600,:'TESTD'),
|
189
|
+
TimezonePeriod.new(DateTime.new(2001,4,2,1,0,0),DateTime.new(2001,10,2,1,0,0),-21600,3600,:'TESTD')],
|
190
|
+
list.periods_for_local(DateTime.new(2001,4,1,20,59,59)))
|
191
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,4,2,1,0,0),DateTime.new(2001,10,2,1,0,0),-21600,3600,:'TESTD')],
|
192
|
+
list.periods_for_local(DateTime.new(2001,4,1,21,0,0)))
|
193
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,4,2,1,0,0),DateTime.new(2001,10,2,1,0,0),-21600,3600,:'TESTD')],
|
194
|
+
list.periods_for_local(DateTime.new(2001,10,1,19,59,59)))
|
195
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,10,2,1,0,0),DateTime.new(2002,10,2,1,0,0),-18000,0,:'TESTS')],
|
196
|
+
list.periods_for_local(DateTime.new(2001,10,1,20,0,0)))
|
197
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,10,2,1,0,0),DateTime.new(2002,10,2,1,0,0),-18000,0,:'TESTS')],
|
198
|
+
list.periods_for_local(DateTime.new(2002,2,1,20,0,0)))
|
199
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,10,2,1,0,0),DateTime.new(2002,10,2,1,0,0),-18000,0,:'TESTS')],
|
200
|
+
list.periods_for_local(DateTime.new(2002,10,1,19,59,59)))
|
201
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2002,10,2,1,0,0),DateTime.new(2003,2,2,1,0,0),-18000,0,:'TESTS')],
|
202
|
+
list.periods_for_local(DateTime.new(2002,10,1,20,0,0)))
|
203
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2002,10,2,1,0,0),DateTime.new(2003,2,2,1,0,0),-18000,0,:'TESTS')],
|
204
|
+
list.periods_for_local(DateTime.new(2003,2,1,19,59,59)))
|
205
|
+
|
206
|
+
assert_raise(PeriodNotFound) {
|
207
|
+
list.periods_for_local(DateTime.new(2003,2,1,20,0,0))
|
208
|
+
}
|
209
|
+
assert_raise(PeriodNotFound) {
|
210
|
+
list.periods_for_local(DateTime.new(2004,1,1,20,0,0))
|
211
|
+
}
|
212
|
+
}
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_period_for_local_unbounded
|
216
|
+
list = TimezonePeriodList.new
|
217
|
+
list.add_unbounded_start { TimezonePeriod.new(nil,DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD') }
|
218
|
+
list.add(2000, 10) { TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS') }
|
219
|
+
list.add(2001, 3) { TimezonePeriod.new(DateTime.new(2001,3,2,1,0,0),nil,-18000,3600,:'TESTD') }
|
220
|
+
|
221
|
+
assert_periods_equal([TimezonePeriod.new(nil,DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD')],
|
222
|
+
list.periods_for_local(DateTime.new(1999,12,1,1,0,0)))
|
223
|
+
assert_periods_equal([TimezonePeriod.new(nil,DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD')],
|
224
|
+
list.periods_for_local(DateTime.new(2000,10,1,20,59,59)))
|
225
|
+
assert_periods_equal([TimezonePeriod.new(nil,DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD')],
|
226
|
+
list.periods_for_local(DateTime.new(2000,10,1,19,59,59)))
|
227
|
+
assert_periods_equal([TimezonePeriod.new(nil,DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD'),
|
228
|
+
TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
229
|
+
list.periods_for_local(DateTime.new(2000,10,1,20,0,0)))
|
230
|
+
assert_periods_equal([TimezonePeriod.new(nil,DateTime.new(2000,10,2,1,0,0),-18000,3600,:'TESTD'),
|
231
|
+
TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
232
|
+
list.periods_for_local(DateTime.new(2000,10,1,20,59,59)))
|
233
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
234
|
+
list.periods_for_local(DateTime.new(2000,10,1,21,0,0)))
|
235
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
236
|
+
list.periods_for_local(DateTime.new(2001,3,1,19,59,59)))
|
237
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,10,2,1,0,0),DateTime.new(2001,3,2,1,0,0),-18000,0,:'TESTS')],
|
238
|
+
list.periods_for_local(DateTime.new(2001,3,1,19,59,59)))
|
239
|
+
|
240
|
+
assert_raise(PeriodNotFound) {
|
241
|
+
list.periods_for_local(DateTime.new(2001,3,1,20,0,0))
|
242
|
+
}
|
243
|
+
assert_raise(PeriodNotFound) {
|
244
|
+
list.periods_for_local(DateTime.new(2001,3,1,20,59,59))
|
245
|
+
}
|
246
|
+
|
247
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,3,2,1,0,0),nil,-18000,3600,:'TESTD')],
|
248
|
+
list.periods_for_local(DateTime.new(2001,3,1,21,0,0)))
|
249
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2001,3,2,1,0,0),nil,-18000,3600,:'TESTD')],
|
250
|
+
list.periods_for_local(DateTime.new(2002,1,1,21,0,0)))
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_period_for_local_unbounded
|
254
|
+
list = TimezonePeriodList.new
|
255
|
+
list.add_unbounded_start { TimezonePeriod.new(nil,DateTime.new(2000,7,1,0,0,0),-3600,0,:'TESTD') }
|
256
|
+
list.add(2000, 7) { TimezonePeriod.new(DateTime.new(2000,7,1,0,0,0),nil,-3600,0,:'TESTS') }
|
257
|
+
|
258
|
+
# 2000-07-01 00:00:00 UTC is 2000-06-30 23:00:00 UTC-1
|
259
|
+
# hence to find periods for local times between 2000-06-30 23:00:00
|
260
|
+
# and 2000-07-01 00:00:00 a search has to be carried out in the next half
|
261
|
+
# year to the one containing the date we are looking for
|
262
|
+
|
263
|
+
assert_periods_equal([TimezonePeriod.new(nil,DateTime.new(2000,7,1,0,0,0),-3600,0,:'TESTD')],
|
264
|
+
list.periods_for_local(DateTime.new(2000,6,30,22,59,59)))
|
265
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,7,1,0,0,0),nil,-3600,0,:'TESTS')],
|
266
|
+
list.periods_for_local(DateTime.new(2000,6,30,23,0,0)))
|
267
|
+
assert_periods_equal([TimezonePeriod.new(DateTime.new(2000,7,1,0,0,0),nil,-3600,0,:'TESTS')],
|
268
|
+
list.periods_for_local(DateTime.new(2000,7,1,0,0,0)))
|
269
|
+
end
|
270
|
+
|
271
|
+
private
|
272
|
+
def assert_period_equal(expected, actual)
|
273
|
+
assert_equal(expected.utc_start, actual.utc_start)
|
274
|
+
assert_equal(expected.utc_end, actual.utc_end)
|
275
|
+
assert_equal(expected.utc_offset, actual.utc_offset)
|
276
|
+
assert_equal(expected.std_offset, actual.std_offset)
|
277
|
+
assert_equal(expected.zone_identifier, actual.zone_identifier)
|
278
|
+
assert_equal(expected.local_start, actual.local_start)
|
279
|
+
assert_equal(expected.local_end, actual.local_end)
|
280
|
+
end
|
281
|
+
|
282
|
+
def assert_periods_equal(expected, actual)
|
283
|
+
assert_equal(expected.length, actual.length)
|
284
|
+
(0..expected.length - 1).each {|i|
|
285
|
+
assert_period_equal(expected[i], actual[i])
|
286
|
+
}
|
287
|
+
end
|
288
|
+
end
|