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.

Files changed (427) hide show
  1. data/CHANGES +94 -58
  2. data/LICENSE +19 -0
  3. data/README +1 -1
  4. data/Rakefile +75 -0
  5. data/lib/tzinfo.rb +14 -14
  6. data/lib/tzinfo/country.rb +38 -6
  7. data/lib/tzinfo/definitions/Africa/Abidjan.rb +2 -2
  8. data/lib/tzinfo/definitions/Africa/Accra.rb +16 -16
  9. data/lib/tzinfo/definitions/Africa/Addis_Ababa.rb +3 -3
  10. data/lib/tzinfo/definitions/Africa/Algiers.rb +35 -35
  11. data/lib/tzinfo/definitions/Africa/Asmera.rb +4 -4
  12. data/lib/tzinfo/definitions/Africa/Bamako.rb +4 -4
  13. data/lib/tzinfo/definitions/Africa/Bangui.rb +2 -2
  14. data/lib/tzinfo/definitions/Africa/Banjul.rb +4 -4
  15. data/lib/tzinfo/definitions/Africa/Bissau.rb +3 -3
  16. data/lib/tzinfo/definitions/Africa/Blantyre.rb +2 -2
  17. data/lib/tzinfo/definitions/Africa/Brazzaville.rb +2 -2
  18. data/lib/tzinfo/definitions/Africa/Bujumbura.rb +2 -2
  19. data/lib/tzinfo/definitions/Africa/Cairo.rb +192 -191
  20. data/lib/tzinfo/definitions/Africa/Casablanca.rb +20 -20
  21. data/lib/tzinfo/definitions/Africa/Ceuta.rb +146 -145
  22. data/lib/tzinfo/definitions/Africa/Conakry.rb +4 -4
  23. data/lib/tzinfo/definitions/Africa/Dakar.rb +3 -3
  24. data/lib/tzinfo/definitions/Africa/Dar_es_Salaam.rb +4 -4
  25. data/lib/tzinfo/definitions/Africa/Djibouti.rb +2 -2
  26. data/lib/tzinfo/definitions/Africa/Douala.rb +2 -2
  27. data/lib/tzinfo/definitions/Africa/El_Aaiun.rb +3 -3
  28. data/lib/tzinfo/definitions/Africa/Freetown.rb +32 -32
  29. data/lib/tzinfo/definitions/Africa/Gaborone.rb +4 -4
  30. data/lib/tzinfo/definitions/Africa/Harare.rb +2 -2
  31. data/lib/tzinfo/definitions/Africa/Johannesburg.rb +7 -7
  32. data/lib/tzinfo/definitions/Africa/Kampala.rb +5 -5
  33. data/lib/tzinfo/definitions/Africa/Khartoum.rb +35 -35
  34. data/lib/tzinfo/definitions/Africa/Kigali.rb +2 -2
  35. data/lib/tzinfo/definitions/Africa/Kinshasa.rb +2 -2
  36. data/lib/tzinfo/definitions/Africa/Lagos.rb +2 -2
  37. data/lib/tzinfo/definitions/Africa/Libreville.rb +2 -2
  38. data/lib/tzinfo/definitions/Africa/Lome.rb +2 -2
  39. data/lib/tzinfo/definitions/Africa/Luanda.rb +3 -3
  40. data/lib/tzinfo/definitions/Africa/Lubumbashi.rb +2 -2
  41. data/lib/tzinfo/definitions/Africa/Lusaka.rb +2 -2
  42. data/lib/tzinfo/definitions/Africa/Malabo.rb +3 -3
  43. data/lib/tzinfo/definitions/Africa/Maputo.rb +2 -2
  44. data/lib/tzinfo/definitions/Africa/Maseru.rb +4 -4
  45. data/lib/tzinfo/definitions/Africa/Mbabane.rb +2 -2
  46. data/lib/tzinfo/definitions/Africa/Mogadishu.rb +4 -4
  47. data/lib/tzinfo/definitions/Africa/Monrovia.rb +4 -4
  48. data/lib/tzinfo/definitions/Africa/Nairobi.rb +5 -5
  49. data/lib/tzinfo/definitions/Africa/Ndjamena.rb +4 -4
  50. data/lib/tzinfo/definitions/Africa/Niamey.rb +4 -4
  51. data/lib/tzinfo/definitions/Africa/Nouakchott.rb +4 -4
  52. data/lib/tzinfo/definitions/Africa/Ouagadougou.rb +2 -2
  53. data/lib/tzinfo/definitions/Africa/Porto__m__Novo.rb +3 -3
  54. data/lib/tzinfo/definitions/Africa/Sao_Tome.rb +3 -3
  55. data/lib/tzinfo/definitions/Africa/Tripoli.rb +30 -30
  56. data/lib/tzinfo/definitions/Africa/Tunis.rb +29 -29
  57. data/lib/tzinfo/definitions/Africa/Windhoek.rb +110 -110
  58. data/lib/tzinfo/definitions/America/Adak.rb +164 -163
  59. data/lib/tzinfo/definitions/America/Anchorage.rb +164 -163
  60. data/lib/tzinfo/definitions/America/Anguilla.rb +2 -2
  61. data/lib/tzinfo/definitions/America/Antigua.rb +3 -3
  62. data/lib/tzinfo/definitions/America/Araguaina.rb +53 -53
  63. data/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +58 -58
  64. data/lib/tzinfo/definitions/America/Argentina/Catamarca.rb +60 -60
  65. data/lib/tzinfo/definitions/America/Argentina/Cordoba.rb +58 -58
  66. data/lib/tzinfo/definitions/America/Argentina/Jujuy.rb +59 -59
  67. data/lib/tzinfo/definitions/America/Argentina/La_Rioja.rb +61 -61
  68. data/lib/tzinfo/definitions/America/Argentina/Mendoza.rb +60 -60
  69. data/lib/tzinfo/definitions/America/Argentina/Rio_Gallegos.rb +60 -60
  70. data/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +61 -61
  71. data/lib/tzinfo/definitions/America/Argentina/Tucuman.rb +60 -60
  72. data/lib/tzinfo/definitions/America/Argentina/Ushuaia.rb +60 -60
  73. data/lib/tzinfo/definitions/America/Aruba.rb +3 -3
  74. data/lib/tzinfo/definitions/America/Asuncion.rb +146 -145
  75. data/lib/tzinfo/definitions/America/Bahia.rb +61 -61
  76. data/lib/tzinfo/definitions/America/Barbados.rb +11 -11
  77. data/lib/tzinfo/definitions/America/Belem.rb +31 -31
  78. data/lib/tzinfo/definitions/America/Belize.rb +56 -56
  79. data/lib/tzinfo/definitions/America/Boa_Vista.rb +36 -36
  80. data/lib/tzinfo/definitions/America/Bogota.rb +5 -5
  81. data/lib/tzinfo/definitions/America/Boise.rb +167 -166
  82. data/lib/tzinfo/definitions/America/Cambridge_Bay.rb +143 -142
  83. data/lib/tzinfo/definitions/America/Campo_Grande.rb +145 -144
  84. data/lib/tzinfo/definitions/America/Cancun.rb +104 -103
  85. data/lib/tzinfo/definitions/America/Caracas.rb +4 -4
  86. data/lib/tzinfo/definitions/America/Cayenne.rb +3 -3
  87. data/lib/tzinfo/definitions/America/Cayman.rb +3 -3
  88. data/lib/tzinfo/definitions/America/Chicago.rb +256 -255
  89. data/lib/tzinfo/definitions/America/Chihuahua.rb +109 -108
  90. data/lib/tzinfo/definitions/America/Coral_Harbour.rb +9 -9
  91. data/lib/tzinfo/definitions/America/Costa_Rica.rb +11 -11
  92. data/lib/tzinfo/definitions/America/Cuiaba.rb +145 -144
  93. data/lib/tzinfo/definitions/America/Curacao.rb +3 -3
  94. data/lib/tzinfo/definitions/America/Danmarkshavn.rb +35 -35
  95. data/lib/tzinfo/definitions/America/Dawson.rb +143 -142
  96. data/lib/tzinfo/definitions/America/Dawson_Creek.rb +59 -59
  97. data/lib/tzinfo/definitions/America/Denver.rb +178 -177
  98. data/lib/tzinfo/definitions/America/Detroit.rb +158 -157
  99. data/lib/tzinfo/definitions/America/Dominica.rb +2 -2
  100. data/lib/tzinfo/definitions/America/Edmonton.rb +170 -169
  101. data/lib/tzinfo/definitions/America/Eirunepe.rb +35 -35
  102. data/lib/tzinfo/definitions/America/El_Salvador.rb +6 -6
  103. data/lib/tzinfo/definitions/America/Fortaleza.rb +44 -44
  104. data/lib/tzinfo/definitions/America/Glace_Bay.rb +160 -159
  105. data/lib/tzinfo/definitions/America/Godthab.rb +134 -133
  106. data/lib/tzinfo/definitions/America/Goose_Bay.rb +225 -224
  107. data/lib/tzinfo/definitions/America/Grand_Turk.rb +137 -136
  108. data/lib/tzinfo/definitions/America/Grenada.rb +2 -2
  109. data/lib/tzinfo/definitions/America/Guadeloupe.rb +2 -2
  110. data/lib/tzinfo/definitions/America/Guatemala.rb +8 -8
  111. data/lib/tzinfo/definitions/America/Guayaquil.rb +3 -3
  112. data/lib/tzinfo/definitions/America/Guyana.rb +5 -5
  113. data/lib/tzinfo/definitions/America/Halifax.rb +248 -247
  114. data/lib/tzinfo/definitions/America/Havana.rb +175 -174
  115. data/lib/tzinfo/definitions/America/Hermosillo.rb +17 -17
  116. data/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +121 -120
  117. data/lib/tzinfo/definitions/America/Indiana/Knox.rb +172 -171
  118. data/lib/tzinfo/definitions/America/Indiana/Marengo.rb +123 -122
  119. data/lib/tzinfo/definitions/America/Indiana/Vevay.rb +100 -99
  120. data/lib/tzinfo/definitions/America/Inuvik.rb +143 -142
  121. data/lib/tzinfo/definitions/America/Iqaluit.rb +142 -141
  122. data/lib/tzinfo/definitions/America/Jamaica.rb +23 -23
  123. data/lib/tzinfo/definitions/America/Juneau.rb +163 -162
  124. data/lib/tzinfo/definitions/America/Kentucky/Louisville.rb +198 -197
  125. data/lib/tzinfo/definitions/America/Kentucky/Monticello.rb +166 -165
  126. data/lib/tzinfo/definitions/America/La_Paz.rb +4 -4
  127. data/lib/tzinfo/definitions/America/Lima.rb +17 -17
  128. data/lib/tzinfo/definitions/America/Los_Angeles.rb +204 -203
  129. data/lib/tzinfo/definitions/America/Maceio.rb +48 -48
  130. data/lib/tzinfo/definitions/America/Managua.rb +15 -15
  131. data/lib/tzinfo/definitions/America/Manaus.rb +35 -35
  132. data/lib/tzinfo/definitions/America/Martinique.rb +5 -5
  133. data/lib/tzinfo/definitions/America/Mazatlan.rb +110 -109
  134. data/lib/tzinfo/definitions/America/Menominee.rb +160 -159
  135. data/lib/tzinfo/definitions/America/Merida.rb +104 -103
  136. data/lib/tzinfo/definitions/America/Mexico_City.rb +116 -115
  137. data/lib/tzinfo/definitions/America/Miquelon.rb +122 -121
  138. data/lib/tzinfo/definitions/America/Monterrey.rb +106 -105
  139. data/lib/tzinfo/definitions/America/Montevideo.rb +69 -67
  140. data/lib/tzinfo/definitions/America/Montreal.rb +253 -252
  141. data/lib/tzinfo/definitions/America/Montserrat.rb +2 -2
  142. data/lib/tzinfo/definitions/America/Nassau.rb +166 -165
  143. data/lib/tzinfo/definitions/America/New_York.rb +256 -255
  144. data/lib/tzinfo/definitions/America/Nipigon.rb +151 -150
  145. data/lib/tzinfo/definitions/America/Nome.rb +164 -163
  146. data/lib/tzinfo/definitions/America/Noronha.rb +44 -44
  147. data/lib/tzinfo/definitions/America/North_Dakota/Center.rb +166 -165
  148. data/lib/tzinfo/definitions/America/Panama.rb +3 -3
  149. data/lib/tzinfo/definitions/America/Pangnirtung.rb +142 -141
  150. data/lib/tzinfo/definitions/America/Paramaribo.rb +6 -6
  151. data/lib/tzinfo/definitions/America/Phoenix.rb +14 -14
  152. data/lib/tzinfo/definitions/America/Port__m__au__m__Prince.rb +35 -35
  153. data/lib/tzinfo/definitions/America/Port_of_Spain.rb +2 -2
  154. data/lib/tzinfo/definitions/America/Porto_Velho.rb +31 -31
  155. data/lib/tzinfo/definitions/America/Puerto_Rico.rb +4 -4
  156. data/lib/tzinfo/definitions/America/Rainy_River.rb +151 -150
  157. data/lib/tzinfo/definitions/America/Rankin_Inlet.rb +142 -141
  158. data/lib/tzinfo/definitions/America/Recife.rb +44 -44
  159. data/lib/tzinfo/definitions/America/Regina.rb +53 -53
  160. data/lib/tzinfo/definitions/America/Rio_Branco.rb +31 -31
  161. data/lib/tzinfo/definitions/America/Santiago.rb +175 -174
  162. data/lib/tzinfo/definitions/America/Santo_Domingo.rb +18 -18
  163. data/lib/tzinfo/definitions/America/Sao_Paulo.rb +146 -145
  164. data/lib/tzinfo/definitions/America/Scoresbysund.rb +134 -133
  165. data/lib/tzinfo/definitions/America/St_Johns.rb +259 -258
  166. data/lib/tzinfo/definitions/America/St_Kitts.rb +2 -2
  167. data/lib/tzinfo/definitions/America/St_Lucia.rb +3 -3
  168. data/lib/tzinfo/definitions/America/St_Thomas.rb +2 -2
  169. data/lib/tzinfo/definitions/America/St_Vincent.rb +3 -3
  170. data/lib/tzinfo/definitions/America/Swift_Current.rb +23 -23
  171. data/lib/tzinfo/definitions/America/Tegucigalpa.rb +6 -6
  172. data/lib/tzinfo/definitions/America/Thule.rb +112 -111
  173. data/lib/tzinfo/definitions/America/Thunder_Bay.rb +159 -158
  174. data/lib/tzinfo/definitions/America/Tijuana.rb +171 -170
  175. data/lib/tzinfo/definitions/America/Toronto.rb +252 -251
  176. data/lib/tzinfo/definitions/America/Tortola.rb +2 -2
  177. data/lib/tzinfo/definitions/America/Vancouver.rb +206 -205
  178. data/lib/tzinfo/definitions/America/Whitehorse.rb +143 -142
  179. data/lib/tzinfo/definitions/America/Winnipeg.rb +202 -201
  180. data/lib/tzinfo/definitions/America/Yakutat.rb +163 -162
  181. data/lib/tzinfo/definitions/America/Yellowknife.rb +142 -141
  182. data/lib/tzinfo/definitions/Antarctica/Casey.rb +2 -2
  183. data/lib/tzinfo/definitions/Antarctica/Davis.rb +4 -4
  184. data/lib/tzinfo/definitions/Antarctica/DumontDUrville.rb +4 -4
  185. data/lib/tzinfo/definitions/Antarctica/Mawson.rb +2 -2
  186. data/lib/tzinfo/definitions/Antarctica/McMurdo.rb +145 -144
  187. data/lib/tzinfo/definitions/Antarctica/Palmer.rb +147 -146
  188. data/lib/tzinfo/definitions/Antarctica/Rothera.rb +2 -2
  189. data/lib/tzinfo/definitions/Antarctica/Syowa.rb +2 -2
  190. data/lib/tzinfo/definitions/Antarctica/Vostok.rb +2 -2
  191. data/lib/tzinfo/definitions/Asia/Aden.rb +2 -2
  192. data/lib/tzinfo/definitions/Asia/Almaty.rb +52 -52
  193. data/lib/tzinfo/definitions/Asia/Amman.rb +136 -135
  194. data/lib/tzinfo/definitions/Asia/Anadyr.rb +134 -133
  195. data/lib/tzinfo/definitions/Asia/Aqtau.rb +52 -52
  196. data/lib/tzinfo/definitions/Asia/Aqtobe.rb +52 -52
  197. data/lib/tzinfo/definitions/Asia/Ashgabat.rb +27 -27
  198. data/lib/tzinfo/definitions/Asia/Baghdad.rb +131 -130
  199. data/lib/tzinfo/definitions/Asia/Bahrain.rb +3 -3
  200. data/lib/tzinfo/definitions/Asia/Baku.rb +130 -129
  201. data/lib/tzinfo/definitions/Asia/Bangkok.rb +3 -3
  202. data/lib/tzinfo/definitions/Asia/Beirut.rb +158 -157
  203. data/lib/tzinfo/definitions/Asia/Bishkek.rb +52 -131
  204. data/lib/tzinfo/definitions/Asia/Brunei.rb +3 -3
  205. data/lib/tzinfo/definitions/Asia/Calcutta.rb +6 -6
  206. data/lib/tzinfo/definitions/Asia/Choibalsan.rb +125 -124
  207. data/lib/tzinfo/definitions/Asia/Chongqing.rb +15 -15
  208. data/lib/tzinfo/definitions/Asia/Colombo.rb +8 -8
  209. data/lib/tzinfo/definitions/Asia/Damascus.rb +168 -167
  210. data/lib/tzinfo/definitions/Asia/Dhaka.rb +7 -7
  211. data/lib/tzinfo/definitions/Asia/Dili.rb +6 -6
  212. data/lib/tzinfo/definitions/Asia/Dubai.rb +2 -2
  213. data/lib/tzinfo/definitions/Asia/Dushanbe.rb +25 -25
  214. data/lib/tzinfo/definitions/Asia/Gaza.rb +162 -161
  215. data/lib/tzinfo/definitions/Asia/Harbin.rb +18 -18
  216. data/lib/tzinfo/definitions/Asia/Hong_Kong.rb +70 -70
  217. data/lib/tzinfo/definitions/Asia/Hovd.rb +125 -124
  218. data/lib/tzinfo/definitions/Asia/Irkutsk.rb +135 -134
  219. data/lib/tzinfo/definitions/Asia/Jakarta.rb +9 -9
  220. data/lib/tzinfo/definitions/Asia/Jayapura.rb +4 -4
  221. data/lib/tzinfo/definitions/Asia/Jerusalem.rb +144 -144
  222. data/lib/tzinfo/definitions/Asia/Kabul.rb +3 -3
  223. data/lib/tzinfo/definitions/Asia/Kamchatka.rb +134 -133
  224. data/lib/tzinfo/definitions/Asia/Karachi.rb +8 -8
  225. data/lib/tzinfo/definitions/Asia/Kashgar.rb +16 -16
  226. data/lib/tzinfo/definitions/Asia/Katmandu.rb +3 -3
  227. data/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +134 -133
  228. data/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +9 -9
  229. data/lib/tzinfo/definitions/Asia/Kuching.rb +20 -20
  230. data/lib/tzinfo/definitions/Asia/Kuwait.rb +2 -2
  231. data/lib/tzinfo/definitions/Asia/Macau.rb +43 -43
  232. data/lib/tzinfo/definitions/Asia/Magadan.rb +134 -133
  233. data/lib/tzinfo/definitions/Asia/Makassar.rb +5 -5
  234. data/lib/tzinfo/definitions/Asia/Manila.rb +11 -11
  235. data/lib/tzinfo/definitions/Asia/Muscat.rb +2 -2
  236. data/lib/tzinfo/definitions/Asia/Nicosia.rb +145 -144
  237. data/lib/tzinfo/definitions/Asia/Novosibirsk.rb +135 -134
  238. data/lib/tzinfo/definitions/Asia/Omsk.rb +134 -133
  239. data/lib/tzinfo/definitions/Asia/Oral.rb +52 -52
  240. data/lib/tzinfo/definitions/Asia/Phnom_Penh.rb +5 -5
  241. data/lib/tzinfo/definitions/Asia/Pontianak.rb +9 -9
  242. data/lib/tzinfo/definitions/Asia/Pyongyang.rb +7 -7
  243. data/lib/tzinfo/definitions/Asia/Qatar.rb +3 -3
  244. data/lib/tzinfo/definitions/Asia/Qyzylorda.rb +53 -53
  245. data/lib/tzinfo/definitions/Asia/Rangoon.rb +5 -5
  246. data/lib/tzinfo/definitions/Asia/Riyadh.rb +2 -2
  247. data/lib/tzinfo/definitions/Asia/Saigon.rb +5 -5
  248. data/lib/tzinfo/definitions/Asia/Sakhalin.rb +135 -134
  249. data/lib/tzinfo/definitions/Asia/Samarkand.rb +30 -30
  250. data/lib/tzinfo/definitions/Asia/Seoul.rb +14 -14
  251. data/lib/tzinfo/definitions/Asia/Shanghai.rb +19 -19
  252. data/lib/tzinfo/definitions/Asia/Singapore.rb +10 -10
  253. data/lib/tzinfo/definitions/Asia/Taipei.rb +42 -42
  254. data/lib/tzinfo/definitions/Asia/Tashkent.rb +30 -30
  255. data/lib/tzinfo/definitions/Asia/Tbilisi.rb +137 -136
  256. data/lib/tzinfo/definitions/Asia/Tehran.rb +105 -105
  257. data/lib/tzinfo/definitions/Asia/Thimphu.rb +3 -3
  258. data/lib/tzinfo/definitions/Asia/Tokyo.rb +12 -12
  259. data/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +125 -124
  260. data/lib/tzinfo/definitions/Asia/Urumqi.rb +15 -15
  261. data/lib/tzinfo/definitions/Asia/Vientiane.rb +5 -5
  262. data/lib/tzinfo/definitions/Asia/Vladivostok.rb +134 -133
  263. data/lib/tzinfo/definitions/Asia/Yakutsk.rb +134 -133
  264. data/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +134 -133
  265. data/lib/tzinfo/definitions/Asia/Yerevan.rb +133 -132
  266. data/lib/tzinfo/definitions/Atlantic/Azores.rb +238 -237
  267. data/lib/tzinfo/definitions/Atlantic/Bermuda.rb +146 -145
  268. data/lib/tzinfo/definitions/Atlantic/Canary.rb +136 -135
  269. data/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +5 -5
  270. data/lib/tzinfo/definitions/Atlantic/Faeroe.rb +133 -132
  271. data/lib/tzinfo/definitions/Atlantic/Madeira.rb +238 -237
  272. data/lib/tzinfo/definitions/Atlantic/Reykjavik.rb +66 -66
  273. data/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +2 -2
  274. data/lib/tzinfo/definitions/Atlantic/St_Helena.rb +3 -3
  275. data/lib/tzinfo/definitions/Atlantic/Stanley.rb +141 -141
  276. data/lib/tzinfo/definitions/Australia/Adelaide.rb +161 -160
  277. data/lib/tzinfo/definitions/Australia/Brisbane.rb +19 -19
  278. data/lib/tzinfo/definitions/Australia/Broken_Hill.rb +163 -162
  279. data/lib/tzinfo/definitions/Australia/Currie.rb +161 -160
  280. data/lib/tzinfo/definitions/Australia/Darwin.rb +11 -11
  281. data/lib/tzinfo/definitions/Australia/Hobart.rb +169 -168
  282. data/lib/tzinfo/definitions/Australia/Lindeman.rb +24 -24
  283. data/lib/tzinfo/definitions/Australia/Lord_Howe.rb +132 -131
  284. data/lib/tzinfo/definitions/Australia/Melbourne.rb +160 -159
  285. data/lib/tzinfo/definitions/Australia/Perth.rb +15 -15
  286. data/lib/tzinfo/definitions/Australia/Sydney.rb +160 -159
  287. data/lib/tzinfo/definitions/CET.rb +151 -150
  288. data/lib/tzinfo/definitions/EET.rb +139 -138
  289. data/lib/tzinfo/definitions/Etc/GMT.rb +1 -1
  290. data/lib/tzinfo/definitions/Etc/GMT__m__1.rb +1 -1
  291. data/lib/tzinfo/definitions/Etc/GMT__m__10.rb +1 -1
  292. data/lib/tzinfo/definitions/Etc/GMT__m__11.rb +1 -1
  293. data/lib/tzinfo/definitions/Etc/GMT__m__12.rb +1 -1
  294. data/lib/tzinfo/definitions/Etc/GMT__m__13.rb +1 -1
  295. data/lib/tzinfo/definitions/Etc/GMT__m__14.rb +1 -1
  296. data/lib/tzinfo/definitions/Etc/GMT__m__2.rb +1 -1
  297. data/lib/tzinfo/definitions/Etc/GMT__m__3.rb +1 -1
  298. data/lib/tzinfo/definitions/Etc/GMT__m__4.rb +1 -1
  299. data/lib/tzinfo/definitions/Etc/GMT__m__5.rb +1 -1
  300. data/lib/tzinfo/definitions/Etc/GMT__m__6.rb +1 -1
  301. data/lib/tzinfo/definitions/Etc/GMT__m__7.rb +1 -1
  302. data/lib/tzinfo/definitions/Etc/GMT__m__8.rb +1 -1
  303. data/lib/tzinfo/definitions/Etc/GMT__m__9.rb +1 -1
  304. data/lib/tzinfo/definitions/Etc/GMT__p__1.rb +1 -1
  305. data/lib/tzinfo/definitions/Etc/GMT__p__10.rb +1 -1
  306. data/lib/tzinfo/definitions/Etc/GMT__p__11.rb +1 -1
  307. data/lib/tzinfo/definitions/Etc/GMT__p__12.rb +1 -1
  308. data/lib/tzinfo/definitions/Etc/GMT__p__2.rb +1 -1
  309. data/lib/tzinfo/definitions/Etc/GMT__p__3.rb +1 -1
  310. data/lib/tzinfo/definitions/Etc/GMT__p__4.rb +1 -1
  311. data/lib/tzinfo/definitions/Etc/GMT__p__5.rb +1 -1
  312. data/lib/tzinfo/definitions/Etc/GMT__p__6.rb +1 -1
  313. data/lib/tzinfo/definitions/Etc/GMT__p__7.rb +1 -1
  314. data/lib/tzinfo/definitions/Etc/GMT__p__8.rb +1 -1
  315. data/lib/tzinfo/definitions/Etc/GMT__p__9.rb +1 -1
  316. data/lib/tzinfo/definitions/Etc/UCT.rb +1 -1
  317. data/lib/tzinfo/definitions/Etc/UTC.rb +1 -1
  318. data/lib/tzinfo/definitions/Europe/Amsterdam.rb +197 -196
  319. data/lib/tzinfo/definitions/Europe/Andorra.rb +125 -124
  320. data/lib/tzinfo/definitions/Europe/Athens.rb +156 -155
  321. data/lib/tzinfo/definitions/Europe/Belgrade.rb +136 -135
  322. data/lib/tzinfo/definitions/Europe/Berlin.rb +161 -160
  323. data/lib/tzinfo/definitions/Europe/Brussels.rb +203 -202
  324. data/lib/tzinfo/definitions/Europe/Bucharest.rb +156 -155
  325. data/lib/tzinfo/definitions/Europe/Budapest.rb +170 -169
  326. data/lib/tzinfo/definitions/Europe/Chisinau.rb +159 -158
  327. data/lib/tzinfo/definitions/Europe/Copenhagen.rb +152 -151
  328. data/lib/tzinfo/definitions/Europe/Dublin.rb +246 -245
  329. data/lib/tzinfo/definitions/Europe/Gibraltar.rb +216 -215
  330. data/lib/tzinfo/definitions/Europe/Helsinki.rb +136 -135
  331. data/lib/tzinfo/definitions/Europe/Istanbul.rb +190 -189
  332. data/lib/tzinfo/definitions/Europe/Kaliningrad.rb +148 -147
  333. data/lib/tzinfo/definitions/Europe/Kiev.rb +138 -137
  334. data/lib/tzinfo/definitions/Europe/Lisbon.rb +239 -238
  335. data/lib/tzinfo/definitions/Europe/London.rb +260 -259
  336. data/lib/tzinfo/definitions/Europe/Luxembourg.rb +200 -199
  337. data/lib/tzinfo/definitions/Europe/Madrid.rb +182 -181
  338. data/lib/tzinfo/definitions/Europe/Malta.rb +187 -186
  339. data/lib/tzinfo/definitions/Europe/Minsk.rb +136 -135
  340. data/lib/tzinfo/definitions/Europe/Monaco.rb +203 -202
  341. data/lib/tzinfo/definitions/Europe/Moscow.rb +147 -146
  342. data/lib/tzinfo/definitions/Europe/Oslo.rb +158 -157
  343. data/lib/tzinfo/definitions/Europe/Paris.rb +201 -200
  344. data/lib/tzinfo/definitions/Europe/Prague.rb +159 -158
  345. data/lib/tzinfo/definitions/Europe/Riga.rb +145 -144
  346. data/lib/tzinfo/definitions/Europe/Rome.rb +189 -188
  347. data/lib/tzinfo/definitions/Europe/Samara.rb +134 -133
  348. data/lib/tzinfo/definitions/Europe/Simferopol.rb +140 -139
  349. data/lib/tzinfo/definitions/Europe/Sofia.rb +146 -145
  350. data/lib/tzinfo/definitions/Europe/Stockholm.rb +138 -137
  351. data/lib/tzinfo/definitions/Europe/Tallinn.rb +141 -140
  352. data/lib/tzinfo/definitions/Europe/Tirane.rb +151 -150
  353. data/lib/tzinfo/definitions/Europe/Uzhgorod.rb +142 -141
  354. data/lib/tzinfo/definitions/Europe/Vaduz.rb +133 -132
  355. data/lib/tzinfo/definitions/Europe/Vienna.rb +159 -158
  356. data/lib/tzinfo/definitions/Europe/Vilnius.rb +137 -136
  357. data/lib/tzinfo/definitions/Europe/Warsaw.rb +184 -183
  358. data/lib/tzinfo/definitions/Europe/Zaporozhye.rb +139 -138
  359. data/lib/tzinfo/definitions/Europe/Zurich.rb +140 -139
  360. data/lib/tzinfo/definitions/Indian/Antananarivo.rb +4 -4
  361. data/lib/tzinfo/definitions/Indian/Chagos.rb +3 -3
  362. data/lib/tzinfo/definitions/Indian/Christmas.rb +2 -2
  363. data/lib/tzinfo/definitions/Indian/Cocos.rb +2 -2
  364. data/lib/tzinfo/definitions/Indian/Comoro.rb +2 -2
  365. data/lib/tzinfo/definitions/Indian/Kerguelen.rb +2 -2
  366. data/lib/tzinfo/definitions/Indian/Mahe.rb +2 -2
  367. data/lib/tzinfo/definitions/Indian/Maldives.rb +3 -3
  368. data/lib/tzinfo/definitions/Indian/Mauritius.rb +2 -2
  369. data/lib/tzinfo/definitions/Indian/Mayotte.rb +2 -2
  370. data/lib/tzinfo/definitions/Indian/Reunion.rb +2 -2
  371. data/lib/tzinfo/definitions/MET.rb +151 -150
  372. data/lib/tzinfo/definitions/Pacific/Apia.rb +4 -4
  373. data/lib/tzinfo/definitions/Pacific/Auckland.rb +173 -172
  374. data/lib/tzinfo/definitions/Pacific/Chatham.rb +145 -144
  375. data/lib/tzinfo/definitions/Pacific/Easter.rb +163 -162
  376. data/lib/tzinfo/definitions/Pacific/Efate.rb +22 -22
  377. data/lib/tzinfo/definitions/Pacific/Enderbury.rb +4 -4
  378. data/lib/tzinfo/definitions/Pacific/Fakaofo.rb +2 -2
  379. data/lib/tzinfo/definitions/Pacific/Fiji.rb +6 -6
  380. data/lib/tzinfo/definitions/Pacific/Funafuti.rb +2 -2
  381. data/lib/tzinfo/definitions/Pacific/Galapagos.rb +3 -3
  382. data/lib/tzinfo/definitions/Pacific/Gambier.rb +2 -2
  383. data/lib/tzinfo/definitions/Pacific/Guadalcanal.rb +2 -2
  384. data/lib/tzinfo/definitions/Pacific/Guam.rb +4 -4
  385. data/lib/tzinfo/definitions/Pacific/Honolulu.rb +6 -6
  386. data/lib/tzinfo/definitions/Pacific/Johnston.rb +1 -1
  387. data/lib/tzinfo/definitions/Pacific/Kiritimati.rb +4 -4
  388. data/lib/tzinfo/definitions/Pacific/Kosrae.rb +4 -4
  389. data/lib/tzinfo/definitions/Pacific/Kwajalein.rb +4 -4
  390. data/lib/tzinfo/definitions/Pacific/Majuro.rb +3 -3
  391. data/lib/tzinfo/definitions/Pacific/Marquesas.rb +2 -2
  392. data/lib/tzinfo/definitions/Pacific/Midway.rb +6 -6
  393. data/lib/tzinfo/definitions/Pacific/Nauru.rb +5 -5
  394. data/lib/tzinfo/definitions/Pacific/Niue.rb +4 -4
  395. data/lib/tzinfo/definitions/Pacific/Norfolk.rb +3 -3
  396. data/lib/tzinfo/definitions/Pacific/Noumea.rb +8 -8
  397. data/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +6 -6
  398. data/lib/tzinfo/definitions/Pacific/Palau.rb +2 -2
  399. data/lib/tzinfo/definitions/Pacific/Pitcairn.rb +3 -3
  400. data/lib/tzinfo/definitions/Pacific/Ponape.rb +2 -2
  401. data/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +3 -3
  402. data/lib/tzinfo/definitions/Pacific/Rarotonga.rb +28 -28
  403. data/lib/tzinfo/definitions/Pacific/Saipan.rb +5 -5
  404. data/lib/tzinfo/definitions/Pacific/Tahiti.rb +2 -2
  405. data/lib/tzinfo/definitions/Pacific/Tarawa.rb +2 -2
  406. data/lib/tzinfo/definitions/Pacific/Tongatapu.rb +10 -10
  407. data/lib/tzinfo/definitions/Pacific/Truk.rb +2 -2
  408. data/lib/tzinfo/definitions/Pacific/Wake.rb +2 -2
  409. data/lib/tzinfo/definitions/Pacific/Wallis.rb +2 -2
  410. data/lib/tzinfo/definitions/WET.rb +139 -138
  411. data/lib/tzinfo/timezone.rb +170 -175
  412. data/lib/tzinfo/timezone_period.rb +175 -0
  413. data/lib/tzinfo/timezone_period_list.rb +225 -0
  414. data/lib/tzinfo/tzdataparser.rb +99 -26
  415. data/test/tc_timezone.rb +231 -1
  416. data/test/tc_timezone_london.rb +13 -6
  417. data/test/tc_timezone_melbourne.rb +13 -6
  418. data/test/tc_timezone_new_york.rb +13 -6
  419. data/test/tc_timezone_period.rb +1 -1
  420. data/test/tc_timezone_period_list.rb +288 -0
  421. metadata +14 -12
  422. data/lib/tzinfo/definitions/Asia/Riyadh87.rb +0 -349
  423. data/lib/tzinfo/definitions/Asia/Riyadh88.rb +0 -350
  424. data/lib/tzinfo/definitions/Asia/Riyadh89.rb +0 -350
  425. data/lib/tzinfo/definitions/Mideast/Riyadh87.rb +0 -11
  426. data/lib/tzinfo/definitions/Mideast/Riyadh88.rb +0 -11
  427. data/lib/tzinfo/definitions/Mideast/Riyadh89.rb +0 -11
@@ -0,0 +1,175 @@
1
+ #--
2
+ # Copyright (c) 2005 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
+ module TZInfo
24
+ # A period of time in a timezone where the same offset from UTC applies.
25
+ class TimezonePeriod
26
+
27
+ # A cache of pre-reduced Rationals for each half-hour between -12 and +12.
28
+ # This is used to save time when loading a TimezonePeriod.
29
+ @@rational_cache = {
30
+ -43200 => Rational.new!(-1,2),
31
+ -41400 => Rational.new!(-23,48),
32
+ -39600 => Rational.new!(-11,24),
33
+ -37800 => Rational.new!(-7,16),
34
+ -36000 => Rational.new!(-5,12),
35
+ -34200 => Rational.new!(-19,48),
36
+ -32400 => Rational.new!(-3,8),
37
+ -30600 => Rational.new!(-17,48),
38
+ -28800 => Rational.new!(-1,3),
39
+ -27000 => Rational.new!(-5,16),
40
+ -25200 => Rational.new!(-7,24),
41
+ -23400 => Rational.new!(-13,48),
42
+ -21600 => Rational.new!(-1,4),
43
+ -19800 => Rational.new!(-11,48),
44
+ -18000 => Rational.new!(-5,24),
45
+ -16200 => Rational.new!(-3,16),
46
+ -14400 => Rational.new!(-1,6),
47
+ -12600 => Rational.new!(-7,48),
48
+ -10800 => Rational.new!(-1,8),
49
+ -9000 => Rational.new!(-5,48),
50
+ -7200 => Rational.new!(-1,12),
51
+ -5400 => Rational.new!(-1,16),
52
+ -3600 => Rational.new!(-1,24),
53
+ -1800 => Rational.new!(-1,48),
54
+ 0 => Rational.new!(0,1),
55
+ 1800 => Rational.new!(1,48),
56
+ 3600 => Rational.new!(1,24),
57
+ 5400 => Rational.new!(1,16),
58
+ 7200 => Rational.new!(1,12),
59
+ 9000 => Rational.new!(5,48),
60
+ 10800 => Rational.new!(1,8),
61
+ 12600 => Rational.new!(7,48),
62
+ 14400 => Rational.new!(1,6),
63
+ 16200 => Rational.new!(3,16),
64
+ 18000 => Rational.new!(5,24),
65
+ 19800 => Rational.new!(11,48),
66
+ 21600 => Rational.new!(1,4),
67
+ 23400 => Rational.new!(13,48),
68
+ 25200 => Rational.new!(7,24),
69
+ 27000 => Rational.new!(5,16),
70
+ 28800 => Rational.new!(1,3),
71
+ 30600 => Rational.new!(17,48),
72
+ 32400 => Rational.new!(3,8),
73
+ 34200 => Rational.new!(19,48),
74
+ 36000 => Rational.new!(5,12),
75
+ 37800 => Rational.new!(7,16),
76
+ 39600 => Rational.new!(11,24),
77
+ 41400 => Rational.new!(23,48),
78
+ 43200 => Rational.new!(1,2)}
79
+
80
+ # Start time of the period (UTC). May be nil if unbounded.
81
+ attr_reader :utc_start
82
+
83
+ # End time of the period (UTC). May be nil if unbounded.
84
+ attr_reader :utc_end
85
+
86
+ # Base offset of the timezone from UTC (seconds).
87
+ attr_reader :utc_offset
88
+
89
+ # Offset from the local time where daylight savings is in effect (seconds).
90
+ # E.g.: utc_offset could be -5 hours. Normally, std_offset would be 0.
91
+ # During daylight savings, std_offset would become +1 hours.
92
+ attr_reader :std_offset
93
+
94
+ # The identifier of this period, e.g. "GMT" (Greenwich Mean Time) or "BST"
95
+ # (British Summer Time) for "Europe/London". The returned identifier is a
96
+ # symbol.
97
+ attr_reader :zone_identifier
98
+
99
+ # Start time of the period (local time). May be nil if unbounded.
100
+ attr_reader :local_start
101
+
102
+ # End time of the period (local time). May be nil if unbounded.
103
+ attr_reader :local_end
104
+
105
+ # Initializes a new TimezonePeriod.
106
+ def initialize(utc_start, utc_end, utc_offset, std_offset, zone_identifier)
107
+ @utc_start = utc_start
108
+ @utc_end = utc_end
109
+ @utc_offset = utc_offset
110
+ @std_offset = std_offset
111
+ @zone_identifier = zone_identifier
112
+ @utc_total_offset = utc_offset + std_offset
113
+ @utc_total_offset_rational = @@rational_cache[utc_total_offset]
114
+ @utc_total_offset_rational = Rational(utc_total_offset, 86400) if @utc_total_offset_rational.nil?
115
+
116
+ @local_start = utc_start.nil? ? nil : to_local(utc_start)
117
+ @local_end = utc_end.nil? ? nil : to_local(utc_end)
118
+ end
119
+
120
+ # Total offset from UTC (seconds). Equal to utc_offset + std_offset.
121
+ def utc_total_offset
122
+ @utc_total_offset
123
+ end
124
+
125
+ # Total offset from UTC (days). Result is a Rational.
126
+ def utc_total_offset_rational
127
+ @utc_total_offset_rational
128
+ end
129
+
130
+ # true if daylight savings is in effect for this period; otherwise false.
131
+ def dst?
132
+ std_offset != 0
133
+ end
134
+
135
+ # true if this period is valid for the given utc DateTime; otherwise false.
136
+ def valid_for_utc?(utc)
137
+ utc_after_start?(utc) && utc_before_end?(utc)
138
+ end
139
+
140
+ # true if the given utc DateTime is after the start of the period (inclusive); otherwise false.
141
+ def utc_after_start?(utc)
142
+ @utc_start.nil? || @utc_start <= utc
143
+ end
144
+
145
+ # true if the given utc DateTime is before the end of the period (exclusive); otherwise false.
146
+ def utc_before_end?(utc)
147
+ @utc_end.nil? || @utc_end > utc
148
+ end
149
+
150
+ # true if this period is valid for the given local DateTime; otherwise false.
151
+ def valid_for_local?(local)
152
+ local_after_start?(local) && local_before_end?(local)
153
+ end
154
+
155
+ # true if the given local DateTime is after the start of the period (inclusive); otherwise false.
156
+ def local_after_start?(local)
157
+ @local_start.nil? || @local_start <= local
158
+ end
159
+
160
+ # true if the given local DateTime is before the end of the period (exclusive); otherwise false.
161
+ def local_before_end?(local)
162
+ @local_end.nil? || @local_end > local
163
+ end
164
+
165
+ # Converts a UTC DateTime to local time based on the offset of this period.
166
+ def to_local(utc)
167
+ utc + utc_total_offset_rational
168
+ end
169
+
170
+ # Converts a local DateTime to UTC based on the offset of this period.
171
+ def to_utc(local)
172
+ local - utc_total_offset_rational
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,225 @@
1
+ #--
2
+ # Copyright (c) 2005 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
+ require 'tzinfo/timezone_period'
24
+
25
+ module TZInfo
26
+ # Thrown to indicate that no TimezonePeriod matching a given time could be found.
27
+ class PeriodNotFound < StandardError
28
+ end
29
+
30
+ # A list of TimezonePeriod instances defining a Timezone.
31
+ class TimezonePeriodList
32
+ # Initializes a new TimezonePeriodList
33
+ def initialize
34
+ @list = nil
35
+ @last_year = nil
36
+ @last_month = nil
37
+ @start_year = nil
38
+ @start_month = nil
39
+ @unbounded_start = nil
40
+ end
41
+
42
+ # One unbounded start period can be defined. This must be set before any
43
+ # calls to add.
44
+ #
45
+ # ArgumentError will be thrown if add or add_unbounded_start has already
46
+ # been called.
47
+ def add_unbounded_start(&block)
48
+ raise ArgumentError, 'add_unbounded_start has already been called' if !@unbounded_start.nil?
49
+ raise ArgumentError, 'add has already been called' if !@list.nil?
50
+ @unbounded_start = block
51
+ end
52
+
53
+ # Adds a new TimezonePeriod to the list. utc_start_year and utc_start_month
54
+ # are the year and month in which the period starts in UTC. A block must
55
+ # be passed in that will return the TimezonePeriod when called with no
56
+ # arguments.
57
+ #
58
+ # If the start year and month are less than the previously encountered
59
+ # year and month ArgumentError will be thrown.
60
+ #
61
+ # Blocks must be added in order of increasing UTC start date.
62
+ def add(utc_start_year, utc_start_month, &block)
63
+ if @list.nil?
64
+ @list = [block]
65
+ @start_year = utc_start_year
66
+ @start_month = utc_start_month
67
+ else
68
+ if utc_start_year < @last_year || (utc_start_year == @last_year && utc_start_month < @last_month)
69
+ raise ArgumentError, 'Calls to add must be in increasing start date order'
70
+ end
71
+
72
+ index = index_for_utc(utc_start_year, utc_start_month)
73
+ if @list[index].nil?
74
+ @list[index] = block
75
+ elsif @list[index].is_a?(Array)
76
+ @list[index] << block
77
+ else
78
+ @list[index] = [@list[index], block]
79
+ end
80
+ end
81
+
82
+ @last_year = utc_start_year
83
+ @last_month = utc_start_month
84
+ end
85
+
86
+ # Returns the period for the given utc time.
87
+ # If no period is found for the given time, PeriodNotFound is thrown.
88
+ def period_for_utc(utc)
89
+ raise PeriodNotFound, 'No periods defined' if @list.nil?
90
+ index = index_for_utc(utc.year, utc.mon)
91
+ index = 0 if index < 0
92
+ index = @list.length - 1 if index >= @list.length
93
+
94
+ result = nil
95
+ index.downto(0) {|i|
96
+ contents = get_contents(i)
97
+
98
+ if contents.is_a?(Array)
99
+ (contents.length - 1).downto(0) {|j|
100
+ if contents[j].valid_for_utc?(utc)
101
+ result = contents[j]
102
+ break
103
+ end
104
+ }
105
+ break unless result.nil?
106
+ elsif !contents.nil? && contents.valid_for_utc?(utc)
107
+ result = contents
108
+ break
109
+ end
110
+ }
111
+
112
+ if result.nil?
113
+ unbounded_start = get_unbounded_start
114
+ if !unbounded_start.nil? && unbounded_start.valid_for_utc?(utc)
115
+ unbounded_start
116
+ else
117
+ raise PeriodNotFound, "No period found for utc: #{utc}"
118
+ end
119
+ else
120
+ result
121
+ end
122
+ end
123
+
124
+ # Returns the set of periods for the given local time as an array.
125
+ # If no period is found for the given time, PeriodNotFound is thrown.
126
+ # Results returned are ordered by increasing UTC start date.
127
+ def periods_for_local(local)
128
+ raise PeriodNotFound, 'No periods defined' if @list.nil?
129
+
130
+ # add one to the index because the periods are indexed by UTC start
131
+ # and the period we are looking for could therefore be in the next
132
+ # half of the year
133
+ index = index_for_utc(local.year, local.mon) + 1
134
+ index = 0 if index < 0
135
+ index = @list.length - 1 if index >= @list.length
136
+
137
+ result = []
138
+
139
+ # found_first is used to avoid searching back to far
140
+ # the search will be limited at the next half year block after discovering
141
+ # the first match
142
+ found_first = nil
143
+
144
+ index.downto(0) {|i|
145
+ contents = get_contents(i)
146
+
147
+ if contents.is_a?(Array)
148
+ (contents.length - 1).downto(0) {|j|
149
+ if contents[j].valid_for_local?(local)
150
+ result << contents[j]
151
+ found_first = i if found_first.nil?
152
+ end
153
+ }
154
+
155
+ if !found_first.nil? && i < found_first
156
+ # searched far enough
157
+ break
158
+ end
159
+ elsif !contents.nil? && contents.valid_for_local?(local)
160
+ result << contents
161
+ end
162
+ }
163
+
164
+ if result.empty? || found_first == 0
165
+ unbounded_start = get_unbounded_start
166
+ result << unbounded_start if !unbounded_start.nil? && unbounded_start.valid_for_local?(local)
167
+ end
168
+
169
+ if result.empty?
170
+ raise PeriodNotFound, "No period found for utc: #{local}"
171
+ else
172
+ result.reverse!
173
+ result
174
+ end
175
+ end
176
+
177
+ private
178
+ # Returns the index into the @list array for a given utc year and month.
179
+ def index_for_utc(year, month)
180
+ index = (year - @start_year) * 2
181
+ index += 1 if month > 6
182
+ index -= 1 if @start_month > 6
183
+ index
184
+ end
185
+
186
+ # Returns the contents of any 6 month period, exapanding any blocks to
187
+ # TimezonePeriods first.
188
+ def get_contents(index)
189
+ contents = @list[index]
190
+ if contents.nil?
191
+ nil
192
+ elsif contents.is_a?(TimezonePeriod)
193
+ contents
194
+ elsif contents.is_a?(Array)
195
+ if contents.first.is_a?(TimezonePeriod)
196
+ contents
197
+ else
198
+ contents = contents.collect {|proc|
199
+ proc.call
200
+ }
201
+ @list[index] = contents
202
+ contents
203
+ end
204
+ elsif contents.is_a?(Proc)
205
+ contents = contents.call
206
+ @list[index] = contents
207
+ contents
208
+ end
209
+ end
210
+
211
+ # Expands unbounded_start if it is defined.
212
+ def get_unbounded_start
213
+ contents = @unbounded_start
214
+ if contents.nil?
215
+ nil
216
+ elsif contents.is_a?(TimezonePeriod)
217
+ contents
218
+ else
219
+ contents = contents.call
220
+ @unbounded_start = contents
221
+ contents
222
+ end
223
+ end
224
+ end
225
+ end
@@ -1,3 +1,26 @@
1
+ #--
2
+ # Copyright (c) 2005 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
+ require 'date'
1
24
  require 'fileutils'
2
25
 
3
26
  module TZInfo
@@ -10,6 +33,33 @@ module TZInfo
10
33
  #
11
34
  # This process is extremely slow (optimization is required).
12
35
  class TZDataParser
36
+ # Whether to generate zone definitions (set to false to stop zones being
37
+ # generated).
38
+ attr_accessor :generate_zones
39
+
40
+ # Whether to generate country definitions (set to false to stop countries
41
+ # being generated).
42
+ attr_accessor :generate_countries
43
+
44
+ # Limit the set of zones to generate (set to an array containing zone
45
+ # identifiers).
46
+ attr_accessor :only_zones
47
+
48
+ # Limit the set of countries to generate (set to an array containing
49
+ # country codes).
50
+ attr_accessor :only_countries
51
+
52
+ # Zones to exclude from generation when not using only_zones (set to an
53
+ # array containing zone identifiers). Defaults to:
54
+ #
55
+ # ['Asia/Riyadh87', 'Asia/Riyadh88', 'Asia/Riyadh89',
56
+ # 'Mideast/Riyadh87', 'Mideast/Riyadh88', 'Mideast/Ruyadh89']
57
+ attr_accessor :exclude_zones
58
+
59
+ # Countries to exclude from generation when not using only_countries (set
60
+ # to an array containing country codes).
61
+ attr_accessor :exclude_countries
62
+
13
63
  # Initializes a new TZDataParser. input_dir must contain the extracted
14
64
  # tzdata tarball. output_dir is the location to output the classes
15
65
  # (in countries and definitions directories).
@@ -21,6 +71,13 @@ module TZInfo
21
71
  @zones = {}
22
72
  @countries = {}
23
73
  @no_rules = TZDataNoRules.new
74
+ @generate_zones = true
75
+ @generate_countries = true
76
+ @only_zones = []
77
+ @only_countries = []
78
+ @exclude_zones = ['Asia/Riyadh87', 'Asia/Riyadh88', 'Asia/Riyadh89',
79
+ 'Mideast/Riyadh87', 'Mideast/Riyadh88', 'Mideast/Ruyadh89']
80
+ @exclude_countries = []
24
81
  end
25
82
 
26
83
  # Reads the tzdata source and generates the classes. Takes a long time
@@ -40,15 +97,27 @@ module TZInfo
40
97
 
41
98
  load_countries
42
99
 
43
- @zones.each_value {|zone|
44
- zone.write_class(@output_dir)
45
- }
100
+ if @generate_zones
101
+ if @only_zones.nil? || @only_zones.empty?
102
+ @zones.each_value {|zone|
103
+ zone.write_class(@output_dir) unless @exclude_zones.include?(zone.name)
104
+ }
105
+ else
106
+ @only_zones.each {|id| @zones[id].write_class(@output_dir) }
107
+ end
108
+ end
46
109
 
47
- @countries.each_value {|country|
48
- country.write_class(@output_dir)
49
- }
110
+ if @generate_countries
111
+ if @only_countries.nil? || @only_countries.empty?
112
+ @countries.each_value {|country|
113
+ country.write_class(@output_dir) unless @exclude_countries.include?(country.code)
114
+ }
115
+ else
116
+ @only_countries.each {|code| @countries[code].write_class(@output_dir) }
117
+ end
50
118
 
51
- write_countries_index
119
+ write_countries_index
120
+ end
52
121
  end
53
122
 
54
123
  # Parses a month specified in the tz data and converts it to a number
@@ -243,7 +312,7 @@ module TZInfo
243
312
  end
244
313
 
245
314
  # Base class for all rule sets.
246
- class TZDataRules
315
+ class TZDataRules #:nodoc:
247
316
  # Name of the rule set, e.g. EU.
248
317
  attr_reader :name
249
318
 
@@ -262,7 +331,11 @@ module TZInfo
262
331
  zone_id = 'Unknown'
263
332
  end
264
333
 
265
- file.puts "add_period(TimezonePeriod.new(#{datetime_constructor(utc_start)},#{datetime_constructor(utc_end)},#{period.utc_offset.to_seconds},#{std_offset.to_seconds},:#{quote_str(zone_id)}))"
334
+ if utc_start.nil?
335
+ file.puts "add_unbounded_start_period {TimezonePeriod.new(nil,#{datetime_constructor(utc_end)},#{period.utc_offset.to_seconds},#{std_offset.to_seconds},:#{quote_str(zone_id)})}"
336
+ else
337
+ file.puts "add_period(#{utc_start.year},#{utc_start.mon}) {TimezonePeriod.new(#{datetime_constructor(utc_start)},#{datetime_constructor(utc_end)},#{period.utc_offset.to_seconds},#{std_offset.to_seconds},:#{quote_str(zone_id)})}"
338
+ end
266
339
  #puts "Period from #{utc_start} to #{utc_end}, utc_offset=#{period.utc_offset.to_seconds}, std_offset=#{std_offset.to_seconds}, name=#{period.format.expand(std_offset, letter)}"
267
340
  end
268
341
 
@@ -271,7 +344,7 @@ module TZInfo
271
344
  if datetime.nil?
272
345
  'nil'
273
346
  else
274
- "DateTime.new(#{datetime.year},#{datetime.mon},#{datetime.mday},#{datetime.hour},#{datetime.min},#{datetime.sec})"
347
+ "DateTime.new0(Rational.new!(#{datetime.ajd.numerator},#{datetime.ajd.denominator}),0,Date::ITALY)"
275
348
  end
276
349
  end
277
350
 
@@ -281,7 +354,7 @@ module TZInfo
281
354
  end
282
355
 
283
356
  # Empty rule set with a fixed daylight savings (std) offset.
284
- class TZDataFixedOffsetRules < TZDataRules
357
+ class TZDataFixedOffsetRules < TZDataRules #:nodoc:
285
358
  attr_reader :offset
286
359
 
287
360
  def initialize(offset)
@@ -302,7 +375,7 @@ module TZInfo
302
375
  end
303
376
 
304
377
  # An empty set of rules.
305
- class TZDataNoRules < TZDataRules
378
+ class TZDataNoRules < TZDataRules #:nodoc:
306
379
  def initialize
307
380
  super('-')
308
381
  end
@@ -322,7 +395,7 @@ module TZInfo
322
395
  end
323
396
 
324
397
  # A rule set (as defined by Rule name in the tz data).
325
- class TZDataRuleSet < TZDataRules
398
+ class TZDataRuleSet < TZDataRules #:nodoc:
326
399
  attr_reader :rules
327
400
 
328
401
  def initialize(name)
@@ -391,7 +464,7 @@ module TZInfo
391
464
 
392
465
  if earliest.nil?
393
466
  #puts 'found no earliest rule'
394
- write_period(file, utc_current, utc_end, period, std_offset, letter)
467
+ write_period(file, utc_current, unbounded_end ? nil : utc_end, period, std_offset, letter)
395
468
 
396
469
  [utc_end, std_offset]
397
470
  break
@@ -441,7 +514,7 @@ module TZInfo
441
514
  end
442
515
 
443
516
  # A rule in a RuleSet (a single Rule line in the tz data).
444
- class TZDataRule
517
+ class TZDataRule #:nodoc:
445
518
  attr_reader :from
446
519
  attr_reader :to
447
520
  attr_reader :type
@@ -593,7 +666,7 @@ module TZInfo
593
666
  end
594
667
 
595
668
  # Base class for Zones and Links.
596
- class TZDataDefinition
669
+ class TZDataDefinition #:nodoc:
597
670
  attr_reader :name
598
671
  attr_reader :name_for_class
599
672
 
@@ -646,7 +719,7 @@ module TZInfo
646
719
  end
647
720
 
648
721
  # A tz data Link.
649
- class TZDataLink < TZDataDefinition
722
+ class TZDataLink < TZDataDefinition #:nodoc:
650
723
  attr_reader :link_to
651
724
 
652
725
  def initialize(name, link_to)
@@ -676,7 +749,7 @@ module TZInfo
676
749
  end
677
750
 
678
751
  # A tz data Zone. Each line from the tz data is loaded as a TZDataPeriod.
679
- class TZDataZone < TZDataDefinition
752
+ class TZDataZone < TZDataDefinition #:nodoc:
680
753
  attr_reader :periods
681
754
 
682
755
  def initialize(name)
@@ -719,7 +792,7 @@ module TZInfo
719
792
  end
720
793
 
721
794
  # A period within a zone.
722
- class TZDataPeriod
795
+ class TZDataPeriod #:nodoc:
723
796
  attr_reader :utc_offset
724
797
  attr_reader :rule_set
725
798
  attr_reader :format
@@ -741,7 +814,7 @@ module TZInfo
741
814
 
742
815
  # A tz data time definition - an hour, minute, second and reference. Reference
743
816
  # is either :utc, :standard or :wall_clock.
744
- class TZDataTime
817
+ class TZDataTime #:nodoc:
745
818
  attr_reader :hour
746
819
  attr_reader :minute
747
820
  attr_reader :second
@@ -774,7 +847,7 @@ module TZInfo
774
847
  end
775
848
 
776
849
  # A tz data offset.
777
- class TZDataOffset
850
+ class TZDataOffset #:nodoc:
778
851
  attr_reader :hour
779
852
  attr_reader :minute
780
853
  attr_reader :second
@@ -817,7 +890,7 @@ module TZInfo
817
890
 
818
891
  # A tz data day of the month reference. Can either be an absolute day,
819
892
  # a last week day or a week day >= or <= than a specific day of month.
820
- class TZDataDayOfMonth
893
+ class TZDataDayOfMonth #:nodoc:
821
894
  attr_reader :type
822
895
  attr_reader :day_of_month
823
896
  attr_reader :day_of_week
@@ -896,7 +969,7 @@ module TZInfo
896
969
  end
897
970
 
898
971
  # A tz data Zone until reference.
899
- class TZDataUntil
972
+ class TZDataUntil #:nodoc:
900
973
  def initialize(spec)
901
974
  parts = spec.split(/\s+/)
902
975
  raise "Invalid until: #{spec}" if parts.length < 1
@@ -915,7 +988,7 @@ module TZInfo
915
988
 
916
989
  # A tz data Zone format string. Either alternate standard/daylight-savings
917
990
  # or substitution (%s) format.
918
- class TZDataFormat
991
+ class TZDataFormat #:nodoc:
919
992
  def initialize(spec)
920
993
  if spec =~ /([A-z]+)\/([A-z]+)/
921
994
  @type = :alternate
@@ -942,7 +1015,7 @@ module TZInfo
942
1015
  end
943
1016
 
944
1017
  # An ISO 3166 country.
945
- class TZDataCountry
1018
+ class TZDataCountry #:nodoc:
946
1019
  attr_reader :code
947
1020
  attr_reader :name
948
1021
  attr_reader :zones
@@ -987,4 +1060,4 @@ module TZInfo
987
1060
  }
988
1061
  end
989
1062
  end
990
- end
1063
+ end