tzinfo 0.1.2 → 0.2.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 (802) hide show
  1. data/CHANGES +24 -0
  2. data/LICENSE +1 -1
  3. data/Rakefile +5 -1
  4. data/lib/tzinfo/countries/AD.rb +12 -12
  5. data/lib/tzinfo/countries/AE.rb +12 -12
  6. data/lib/tzinfo/countries/AF.rb +12 -12
  7. data/lib/tzinfo/countries/AG.rb +12 -12
  8. data/lib/tzinfo/countries/AI.rb +12 -12
  9. data/lib/tzinfo/countries/AL.rb +12 -12
  10. data/lib/tzinfo/countries/AM.rb +12 -12
  11. data/lib/tzinfo/countries/AN.rb +12 -12
  12. data/lib/tzinfo/countries/AO.rb +12 -12
  13. data/lib/tzinfo/countries/AQ.rb +21 -21
  14. data/lib/tzinfo/countries/AR.rb +21 -21
  15. data/lib/tzinfo/countries/AS.rb +12 -12
  16. data/lib/tzinfo/countries/AT.rb +12 -12
  17. data/lib/tzinfo/countries/AU.rb +22 -22
  18. data/lib/tzinfo/countries/AW.rb +12 -12
  19. data/lib/tzinfo/countries/AX.rb +12 -12
  20. data/lib/tzinfo/countries/AZ.rb +12 -12
  21. data/lib/tzinfo/countries/BA.rb +12 -12
  22. data/lib/tzinfo/countries/BB.rb +12 -12
  23. data/lib/tzinfo/countries/BD.rb +12 -12
  24. data/lib/tzinfo/countries/BE.rb +12 -12
  25. data/lib/tzinfo/countries/BF.rb +12 -12
  26. data/lib/tzinfo/countries/BG.rb +12 -12
  27. data/lib/tzinfo/countries/BH.rb +12 -12
  28. data/lib/tzinfo/countries/BI.rb +12 -12
  29. data/lib/tzinfo/countries/BJ.rb +12 -12
  30. data/lib/tzinfo/countries/BM.rb +12 -12
  31. data/lib/tzinfo/countries/BN.rb +12 -12
  32. data/lib/tzinfo/countries/BO.rb +12 -12
  33. data/lib/tzinfo/countries/BR.rb +26 -26
  34. data/lib/tzinfo/countries/BS.rb +12 -12
  35. data/lib/tzinfo/countries/BT.rb +12 -12
  36. data/lib/tzinfo/countries/BV.rb +11 -11
  37. data/lib/tzinfo/countries/BW.rb +12 -12
  38. data/lib/tzinfo/countries/BY.rb +12 -12
  39. data/lib/tzinfo/countries/BZ.rb +12 -12
  40. data/lib/tzinfo/countries/CA.rb +36 -36
  41. data/lib/tzinfo/countries/CC.rb +12 -12
  42. data/lib/tzinfo/countries/CD.rb +13 -13
  43. data/lib/tzinfo/countries/CF.rb +12 -12
  44. data/lib/tzinfo/countries/CG.rb +12 -12
  45. data/lib/tzinfo/countries/CH.rb +12 -12
  46. data/lib/tzinfo/countries/CI.rb +12 -12
  47. data/lib/tzinfo/countries/CK.rb +12 -12
  48. data/lib/tzinfo/countries/CL.rb +13 -13
  49. data/lib/tzinfo/countries/CM.rb +12 -12
  50. data/lib/tzinfo/countries/CN.rb +16 -16
  51. data/lib/tzinfo/countries/CO.rb +12 -12
  52. data/lib/tzinfo/countries/CR.rb +12 -12
  53. data/lib/tzinfo/countries/CS.rb +12 -12
  54. data/lib/tzinfo/countries/CU.rb +12 -12
  55. data/lib/tzinfo/countries/CV.rb +12 -12
  56. data/lib/tzinfo/countries/CX.rb +12 -12
  57. data/lib/tzinfo/countries/CY.rb +12 -12
  58. data/lib/tzinfo/countries/CZ.rb +12 -12
  59. data/lib/tzinfo/countries/DE.rb +12 -12
  60. data/lib/tzinfo/countries/DJ.rb +12 -12
  61. data/lib/tzinfo/countries/DK.rb +12 -12
  62. data/lib/tzinfo/countries/DM.rb +12 -12
  63. data/lib/tzinfo/countries/DO.rb +12 -12
  64. data/lib/tzinfo/countries/DZ.rb +12 -12
  65. data/lib/tzinfo/countries/EC.rb +13 -13
  66. data/lib/tzinfo/countries/EE.rb +12 -12
  67. data/lib/tzinfo/countries/EG.rb +12 -12
  68. data/lib/tzinfo/countries/EH.rb +12 -12
  69. data/lib/tzinfo/countries/ER.rb +12 -12
  70. data/lib/tzinfo/countries/ES.rb +14 -14
  71. data/lib/tzinfo/countries/ET.rb +12 -12
  72. data/lib/tzinfo/countries/FI.rb +12 -12
  73. data/lib/tzinfo/countries/FJ.rb +12 -12
  74. data/lib/tzinfo/countries/FK.rb +12 -12
  75. data/lib/tzinfo/countries/FM.rb +14 -14
  76. data/lib/tzinfo/countries/FO.rb +12 -12
  77. data/lib/tzinfo/countries/FR.rb +12 -12
  78. data/lib/tzinfo/countries/GA.rb +12 -12
  79. data/lib/tzinfo/countries/GB.rb +12 -12
  80. data/lib/tzinfo/countries/GD.rb +12 -12
  81. data/lib/tzinfo/countries/GE.rb +12 -12
  82. data/lib/tzinfo/countries/GF.rb +12 -12
  83. data/lib/tzinfo/countries/GH.rb +12 -12
  84. data/lib/tzinfo/countries/GI.rb +12 -12
  85. data/lib/tzinfo/countries/GL.rb +15 -15
  86. data/lib/tzinfo/countries/GM.rb +12 -12
  87. data/lib/tzinfo/countries/GN.rb +12 -12
  88. data/lib/tzinfo/countries/GP.rb +12 -12
  89. data/lib/tzinfo/countries/GQ.rb +12 -12
  90. data/lib/tzinfo/countries/GR.rb +12 -12
  91. data/lib/tzinfo/countries/GS.rb +12 -12
  92. data/lib/tzinfo/countries/GT.rb +12 -12
  93. data/lib/tzinfo/countries/GU.rb +12 -12
  94. data/lib/tzinfo/countries/GW.rb +12 -12
  95. data/lib/tzinfo/countries/GY.rb +12 -12
  96. data/lib/tzinfo/countries/HK.rb +12 -12
  97. data/lib/tzinfo/countries/HM.rb +11 -11
  98. data/lib/tzinfo/countries/HN.rb +12 -12
  99. data/lib/tzinfo/countries/HR.rb +12 -12
  100. data/lib/tzinfo/countries/HT.rb +12 -12
  101. data/lib/tzinfo/countries/HU.rb +12 -12
  102. data/lib/tzinfo/countries/ID.rb +15 -15
  103. data/lib/tzinfo/countries/IE.rb +12 -12
  104. data/lib/tzinfo/countries/IL.rb +12 -12
  105. data/lib/tzinfo/countries/IN.rb +12 -12
  106. data/lib/tzinfo/countries/IO.rb +12 -12
  107. data/lib/tzinfo/countries/IQ.rb +12 -12
  108. data/lib/tzinfo/countries/IR.rb +12 -12
  109. data/lib/tzinfo/countries/IS.rb +12 -12
  110. data/lib/tzinfo/countries/IT.rb +12 -12
  111. data/lib/tzinfo/countries/JM.rb +12 -12
  112. data/lib/tzinfo/countries/JO.rb +12 -12
  113. data/lib/tzinfo/countries/JP.rb +12 -12
  114. data/lib/tzinfo/countries/KE.rb +12 -12
  115. data/lib/tzinfo/countries/KG.rb +12 -12
  116. data/lib/tzinfo/countries/KH.rb +12 -12
  117. data/lib/tzinfo/countries/KI.rb +14 -14
  118. data/lib/tzinfo/countries/KM.rb +12 -12
  119. data/lib/tzinfo/countries/KN.rb +12 -12
  120. data/lib/tzinfo/countries/KP.rb +12 -12
  121. data/lib/tzinfo/countries/KR.rb +12 -12
  122. data/lib/tzinfo/countries/KW.rb +12 -12
  123. data/lib/tzinfo/countries/KY.rb +12 -12
  124. data/lib/tzinfo/countries/KZ.rb +16 -16
  125. data/lib/tzinfo/countries/LA.rb +12 -12
  126. data/lib/tzinfo/countries/LB.rb +12 -12
  127. data/lib/tzinfo/countries/LC.rb +12 -12
  128. data/lib/tzinfo/countries/LI.rb +12 -12
  129. data/lib/tzinfo/countries/LK.rb +12 -12
  130. data/lib/tzinfo/countries/LR.rb +12 -12
  131. data/lib/tzinfo/countries/LS.rb +12 -12
  132. data/lib/tzinfo/countries/LT.rb +12 -12
  133. data/lib/tzinfo/countries/LU.rb +12 -12
  134. data/lib/tzinfo/countries/LV.rb +12 -12
  135. data/lib/tzinfo/countries/LY.rb +12 -12
  136. data/lib/tzinfo/countries/MA.rb +12 -12
  137. data/lib/tzinfo/countries/MC.rb +12 -12
  138. data/lib/tzinfo/countries/MD.rb +12 -12
  139. data/lib/tzinfo/countries/MG.rb +12 -12
  140. data/lib/tzinfo/countries/MH.rb +13 -13
  141. data/lib/tzinfo/countries/MK.rb +12 -12
  142. data/lib/tzinfo/countries/ML.rb +12 -12
  143. data/lib/tzinfo/countries/MM.rb +12 -12
  144. data/lib/tzinfo/countries/MN.rb +14 -14
  145. data/lib/tzinfo/countries/MO.rb +12 -12
  146. data/lib/tzinfo/countries/MP.rb +12 -12
  147. data/lib/tzinfo/countries/MQ.rb +12 -12
  148. data/lib/tzinfo/countries/MR.rb +12 -12
  149. data/lib/tzinfo/countries/MS.rb +12 -12
  150. data/lib/tzinfo/countries/MT.rb +12 -12
  151. data/lib/tzinfo/countries/MU.rb +12 -12
  152. data/lib/tzinfo/countries/MV.rb +12 -12
  153. data/lib/tzinfo/countries/MW.rb +12 -12
  154. data/lib/tzinfo/countries/MX.rb +19 -19
  155. data/lib/tzinfo/countries/MY.rb +13 -13
  156. data/lib/tzinfo/countries/MZ.rb +12 -12
  157. data/lib/tzinfo/countries/NA.rb +12 -12
  158. data/lib/tzinfo/countries/NC.rb +12 -12
  159. data/lib/tzinfo/countries/NE.rb +12 -12
  160. data/lib/tzinfo/countries/NF.rb +12 -12
  161. data/lib/tzinfo/countries/NG.rb +12 -12
  162. data/lib/tzinfo/countries/NI.rb +12 -12
  163. data/lib/tzinfo/countries/NL.rb +12 -12
  164. data/lib/tzinfo/countries/NO.rb +12 -12
  165. data/lib/tzinfo/countries/NP.rb +12 -12
  166. data/lib/tzinfo/countries/NR.rb +12 -12
  167. data/lib/tzinfo/countries/NU.rb +12 -12
  168. data/lib/tzinfo/countries/NZ.rb +13 -13
  169. data/lib/tzinfo/countries/OM.rb +12 -12
  170. data/lib/tzinfo/countries/PA.rb +12 -12
  171. data/lib/tzinfo/countries/PE.rb +12 -12
  172. data/lib/tzinfo/countries/PF.rb +14 -14
  173. data/lib/tzinfo/countries/PG.rb +12 -12
  174. data/lib/tzinfo/countries/PH.rb +12 -12
  175. data/lib/tzinfo/countries/PK.rb +12 -12
  176. data/lib/tzinfo/countries/PL.rb +12 -12
  177. data/lib/tzinfo/countries/PM.rb +12 -12
  178. data/lib/tzinfo/countries/PN.rb +12 -12
  179. data/lib/tzinfo/countries/PR.rb +12 -12
  180. data/lib/tzinfo/countries/PS.rb +12 -12
  181. data/lib/tzinfo/countries/PT.rb +14 -14
  182. data/lib/tzinfo/countries/PW.rb +12 -12
  183. data/lib/tzinfo/countries/PY.rb +12 -12
  184. data/lib/tzinfo/countries/QA.rb +12 -12
  185. data/lib/tzinfo/countries/RE.rb +12 -12
  186. data/lib/tzinfo/countries/RO.rb +12 -12
  187. data/lib/tzinfo/countries/RU.rb +25 -25
  188. data/lib/tzinfo/countries/RW.rb +12 -12
  189. data/lib/tzinfo/countries/SA.rb +12 -12
  190. data/lib/tzinfo/countries/SB.rb +12 -12
  191. data/lib/tzinfo/countries/SC.rb +12 -12
  192. data/lib/tzinfo/countries/SD.rb +12 -12
  193. data/lib/tzinfo/countries/SE.rb +12 -12
  194. data/lib/tzinfo/countries/SG.rb +12 -12
  195. data/lib/tzinfo/countries/SH.rb +12 -12
  196. data/lib/tzinfo/countries/SI.rb +12 -12
  197. data/lib/tzinfo/countries/SJ.rb +13 -13
  198. data/lib/tzinfo/countries/SK.rb +12 -12
  199. data/lib/tzinfo/countries/SL.rb +12 -12
  200. data/lib/tzinfo/countries/SM.rb +12 -12
  201. data/lib/tzinfo/countries/SN.rb +12 -12
  202. data/lib/tzinfo/countries/SO.rb +12 -12
  203. data/lib/tzinfo/countries/SR.rb +12 -12
  204. data/lib/tzinfo/countries/ST.rb +12 -12
  205. data/lib/tzinfo/countries/SV.rb +12 -12
  206. data/lib/tzinfo/countries/SY.rb +12 -12
  207. data/lib/tzinfo/countries/SZ.rb +12 -12
  208. data/lib/tzinfo/countries/TC.rb +12 -12
  209. data/lib/tzinfo/countries/TD.rb +12 -12
  210. data/lib/tzinfo/countries/TF.rb +12 -12
  211. data/lib/tzinfo/countries/TG.rb +12 -12
  212. data/lib/tzinfo/countries/TH.rb +12 -12
  213. data/lib/tzinfo/countries/TJ.rb +12 -12
  214. data/lib/tzinfo/countries/TK.rb +12 -12
  215. data/lib/tzinfo/countries/TL.rb +12 -12
  216. data/lib/tzinfo/countries/TM.rb +12 -12
  217. data/lib/tzinfo/countries/TN.rb +12 -12
  218. data/lib/tzinfo/countries/TO.rb +12 -12
  219. data/lib/tzinfo/countries/TR.rb +12 -12
  220. data/lib/tzinfo/countries/TT.rb +12 -12
  221. data/lib/tzinfo/countries/TV.rb +12 -12
  222. data/lib/tzinfo/countries/TW.rb +12 -12
  223. data/lib/tzinfo/countries/TZ.rb +12 -12
  224. data/lib/tzinfo/countries/UA.rb +15 -15
  225. data/lib/tzinfo/countries/UG.rb +12 -12
  226. data/lib/tzinfo/countries/UM.rb +14 -14
  227. data/lib/tzinfo/countries/US.rb +36 -35
  228. data/lib/tzinfo/countries/UY.rb +12 -12
  229. data/lib/tzinfo/countries/UZ.rb +13 -13
  230. data/lib/tzinfo/countries/VA.rb +12 -12
  231. data/lib/tzinfo/countries/VC.rb +12 -12
  232. data/lib/tzinfo/countries/VE.rb +12 -12
  233. data/lib/tzinfo/countries/VG.rb +12 -12
  234. data/lib/tzinfo/countries/VI.rb +12 -12
  235. data/lib/tzinfo/countries/VN.rb +12 -12
  236. data/lib/tzinfo/countries/VU.rb +12 -12
  237. data/lib/tzinfo/countries/WF.rb +12 -12
  238. data/lib/tzinfo/countries/WS.rb +12 -12
  239. data/lib/tzinfo/countries/YE.rb +12 -12
  240. data/lib/tzinfo/countries/YT.rb +12 -12
  241. data/lib/tzinfo/countries/ZA.rb +12 -12
  242. data/lib/tzinfo/countries/ZM.rb +12 -12
  243. data/lib/tzinfo/countries/ZW.rb +12 -12
  244. data/lib/tzinfo/definitions/Africa/Abidjan.rb +13 -13
  245. data/lib/tzinfo/definitions/Africa/Accra.rb +27 -27
  246. data/lib/tzinfo/definitions/Africa/Addis_Ababa.rb +14 -14
  247. data/lib/tzinfo/definitions/Africa/Algiers.rb +46 -46
  248. data/lib/tzinfo/definitions/Africa/Asmera.rb +15 -15
  249. data/lib/tzinfo/definitions/Africa/Bamako.rb +15 -15
  250. data/lib/tzinfo/definitions/Africa/Bangui.rb +13 -13
  251. data/lib/tzinfo/definitions/Africa/Banjul.rb +15 -15
  252. data/lib/tzinfo/definitions/Africa/Bissau.rb +14 -14
  253. data/lib/tzinfo/definitions/Africa/Blantyre.rb +13 -13
  254. data/lib/tzinfo/definitions/Africa/Brazzaville.rb +13 -13
  255. data/lib/tzinfo/definitions/Africa/Bujumbura.rb +13 -13
  256. data/lib/tzinfo/definitions/Africa/Cairo.rb +213 -203
  257. data/lib/tzinfo/definitions/Africa/Casablanca.rb +31 -31
  258. data/lib/tzinfo/definitions/Africa/Ceuta.rb +164 -157
  259. data/lib/tzinfo/definitions/Africa/Conakry.rb +15 -15
  260. data/lib/tzinfo/definitions/Africa/Dakar.rb +14 -14
  261. data/lib/tzinfo/definitions/Africa/Dar_es_Salaam.rb +15 -15
  262. data/lib/tzinfo/definitions/Africa/Djibouti.rb +13 -13
  263. data/lib/tzinfo/definitions/Africa/Douala.rb +13 -13
  264. data/lib/tzinfo/definitions/Africa/El_Aaiun.rb +14 -14
  265. data/lib/tzinfo/definitions/Africa/Freetown.rb +43 -43
  266. data/lib/tzinfo/definitions/Africa/Gaborone.rb +15 -15
  267. data/lib/tzinfo/definitions/Africa/Harare.rb +13 -13
  268. data/lib/tzinfo/definitions/Africa/Johannesburg.rb +18 -18
  269. data/lib/tzinfo/definitions/Africa/Kampala.rb +16 -16
  270. data/lib/tzinfo/definitions/Africa/Khartoum.rb +46 -46
  271. data/lib/tzinfo/definitions/Africa/Kigali.rb +13 -13
  272. data/lib/tzinfo/definitions/Africa/Kinshasa.rb +13 -13
  273. data/lib/tzinfo/definitions/Africa/Lagos.rb +13 -13
  274. data/lib/tzinfo/definitions/Africa/Libreville.rb +13 -13
  275. data/lib/tzinfo/definitions/Africa/Lome.rb +13 -13
  276. data/lib/tzinfo/definitions/Africa/Luanda.rb +14 -14
  277. data/lib/tzinfo/definitions/Africa/Lubumbashi.rb +13 -13
  278. data/lib/tzinfo/definitions/Africa/Lusaka.rb +13 -13
  279. data/lib/tzinfo/definitions/Africa/Malabo.rb +14 -14
  280. data/lib/tzinfo/definitions/Africa/Maputo.rb +13 -13
  281. data/lib/tzinfo/definitions/Africa/Maseru.rb +15 -15
  282. data/lib/tzinfo/definitions/Africa/Mbabane.rb +13 -13
  283. data/lib/tzinfo/definitions/Africa/Mogadishu.rb +15 -15
  284. data/lib/tzinfo/definitions/Africa/Monrovia.rb +15 -15
  285. data/lib/tzinfo/definitions/Africa/Nairobi.rb +16 -16
  286. data/lib/tzinfo/definitions/Africa/Ndjamena.rb +15 -15
  287. data/lib/tzinfo/definitions/Africa/Niamey.rb +15 -15
  288. data/lib/tzinfo/definitions/Africa/Nouakchott.rb +15 -15
  289. data/lib/tzinfo/definitions/Africa/Ouagadougou.rb +13 -13
  290. data/lib/tzinfo/definitions/Africa/Porto__m__Novo.rb +14 -14
  291. data/lib/tzinfo/definitions/Africa/Sao_Tome.rb +14 -14
  292. data/lib/tzinfo/definitions/Africa/Timbuktu.rb +11 -11
  293. data/lib/tzinfo/definitions/Africa/Tripoli.rb +41 -41
  294. data/lib/tzinfo/definitions/Africa/Tunis.rb +130 -40
  295. data/lib/tzinfo/definitions/Africa/Windhoek.rb +130 -121
  296. data/lib/tzinfo/definitions/America/Adak.rb +183 -175
  297. data/lib/tzinfo/definitions/America/Anchorage.rb +183 -175
  298. data/lib/tzinfo/definitions/America/Anguilla.rb +13 -13
  299. data/lib/tzinfo/definitions/America/Antigua.rb +14 -14
  300. data/lib/tzinfo/definitions/America/Araguaina.rb +61 -64
  301. data/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +71 -71
  302. data/lib/tzinfo/definitions/America/Argentina/Catamarca.rb +73 -73
  303. data/lib/tzinfo/definitions/America/Argentina/ComodRivadavia.rb +13 -13
  304. data/lib/tzinfo/definitions/America/Argentina/Cordoba.rb +71 -71
  305. data/lib/tzinfo/definitions/America/Argentina/Jujuy.rb +71 -72
  306. data/lib/tzinfo/definitions/America/Argentina/La_Rioja.rb +74 -74
  307. data/lib/tzinfo/definitions/America/Argentina/Mendoza.rb +73 -73
  308. data/lib/tzinfo/definitions/America/Argentina/Rio_Gallegos.rb +73 -73
  309. data/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +74 -74
  310. data/lib/tzinfo/definitions/America/Argentina/Tucuman.rb +73 -73
  311. data/lib/tzinfo/definitions/America/Argentina/Ushuaia.rb +73 -73
  312. data/lib/tzinfo/definitions/America/Aruba.rb +14 -14
  313. data/lib/tzinfo/definitions/America/Asuncion.rb +166 -157
  314. data/lib/tzinfo/definitions/America/Atka.rb +11 -11
  315. data/lib/tzinfo/definitions/America/Bahia.rb +71 -72
  316. data/lib/tzinfo/definitions/America/Barbados.rb +22 -22
  317. data/lib/tzinfo/definitions/America/Belem.rb +41 -42
  318. data/lib/tzinfo/definitions/America/Belize.rb +67 -67
  319. data/lib/tzinfo/definitions/America/Boa_Vista.rb +45 -47
  320. data/lib/tzinfo/definitions/America/Bogota.rb +16 -16
  321. data/lib/tzinfo/definitions/America/Boise.rb +189 -178
  322. data/lib/tzinfo/definitions/America/Buenos_Aires.rb +11 -11
  323. data/lib/tzinfo/definitions/America/Cambridge_Bay.rb +165 -154
  324. data/lib/tzinfo/definitions/America/Campo_Grande.rb +165 -156
  325. data/lib/tzinfo/definitions/America/Cancun.rb +125 -115
  326. data/lib/tzinfo/definitions/America/Caracas.rb +15 -15
  327. data/lib/tzinfo/definitions/America/Catamarca.rb +11 -11
  328. data/lib/tzinfo/definitions/America/Cayenne.rb +14 -14
  329. data/lib/tzinfo/definitions/America/Cayman.rb +14 -14
  330. data/lib/tzinfo/definitions/America/Chicago.rb +274 -267
  331. data/lib/tzinfo/definitions/America/Chihuahua.rb +128 -120
  332. data/lib/tzinfo/definitions/America/Coral_Harbour.rb +20 -20
  333. data/lib/tzinfo/definitions/America/Cordoba.rb +11 -11
  334. data/lib/tzinfo/definitions/America/Costa_Rica.rb +22 -22
  335. data/lib/tzinfo/definitions/America/Cuiaba.rb +163 -156
  336. data/lib/tzinfo/definitions/America/Curacao.rb +14 -14
  337. data/lib/tzinfo/definitions/America/Danmarkshavn.rb +46 -46
  338. data/lib/tzinfo/definitions/America/Dawson.rb +165 -154
  339. data/lib/tzinfo/definitions/America/Dawson_Creek.rb +70 -70
  340. data/lib/tzinfo/definitions/America/Denver.rb +196 -189
  341. data/lib/tzinfo/definitions/America/Detroit.rb +177 -169
  342. data/lib/tzinfo/definitions/America/Dominica.rb +13 -13
  343. data/lib/tzinfo/definitions/America/Edmonton.rb +192 -181
  344. data/lib/tzinfo/definitions/America/Eirunepe.rb +43 -46
  345. data/lib/tzinfo/definitions/America/El_Salvador.rb +17 -17
  346. data/lib/tzinfo/definitions/America/Ensenada.rb +11 -11
  347. data/lib/tzinfo/definitions/America/Fort_Wayne.rb +11 -11
  348. data/lib/tzinfo/definitions/America/Fortaleza.rb +51 -55
  349. data/lib/tzinfo/definitions/America/Glace_Bay.rb +178 -171
  350. data/lib/tzinfo/definitions/America/Godthab.rb +155 -145
  351. data/lib/tzinfo/definitions/America/Goose_Bay.rb +242 -236
  352. data/lib/tzinfo/definitions/America/Grand_Turk.rb +158 -148
  353. data/lib/tzinfo/definitions/America/Grenada.rb +13 -13
  354. data/lib/tzinfo/definitions/America/Guadeloupe.rb +13 -13
  355. data/lib/tzinfo/definitions/America/Guatemala.rb +19 -19
  356. data/lib/tzinfo/definitions/America/Guayaquil.rb +14 -14
  357. data/lib/tzinfo/definitions/America/Guyana.rb +16 -16
  358. data/lib/tzinfo/definitions/America/Halifax.rb +266 -259
  359. data/lib/tzinfo/definitions/America/Havana.rb +194 -184
  360. data/lib/tzinfo/definitions/America/Hermosillo.rb +27 -28
  361. data/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +139 -134
  362. data/lib/tzinfo/definitions/America/Indiana/Knox.rb +194 -184
  363. data/lib/tzinfo/definitions/America/Indiana/Marengo.rb +143 -136
  364. data/lib/tzinfo/definitions/America/Indiana/Petersburg.rb +156 -146
  365. data/lib/tzinfo/definitions/America/Indiana/Vevay.rb +121 -113
  366. data/lib/tzinfo/definitions/America/Indiana/Vincennes.rb +141 -133
  367. data/lib/tzinfo/definitions/America/Indianapolis.rb +11 -11
  368. data/lib/tzinfo/definitions/America/Inuvik.rb +165 -154
  369. data/lib/tzinfo/definitions/America/Iqaluit.rb +164 -153
  370. data/lib/tzinfo/definitions/America/Jamaica.rb +34 -34
  371. data/lib/tzinfo/definitions/America/Jujuy.rb +11 -11
  372. data/lib/tzinfo/definitions/America/Juneau.rb +182 -174
  373. data/lib/tzinfo/definitions/America/Kentucky/Louisville.rb +218 -211
  374. data/lib/tzinfo/definitions/America/Kentucky/Monticello.rb +188 -179
  375. data/lib/tzinfo/definitions/America/Knox_IN.rb +11 -11
  376. data/lib/tzinfo/definitions/America/La_Paz.rb +15 -15
  377. data/lib/tzinfo/definitions/America/Lima.rb +28 -28
  378. data/lib/tzinfo/definitions/America/Los_Angeles.rb +224 -215
  379. data/lib/tzinfo/definitions/America/Louisville.rb +11 -11
  380. data/lib/tzinfo/definitions/America/Maceio.rb +53 -59
  381. data/lib/tzinfo/definitions/America/Managua.rb +26 -26
  382. data/lib/tzinfo/definitions/America/Manaus.rb +43 -46
  383. data/lib/tzinfo/definitions/America/Martinique.rb +16 -16
  384. data/lib/tzinfo/definitions/America/Mazatlan.rb +131 -121
  385. data/lib/tzinfo/definitions/America/Mendoza.rb +11 -11
  386. data/lib/tzinfo/definitions/America/Menominee.rb +181 -171
  387. data/lib/tzinfo/definitions/America/Merida.rb +125 -115
  388. data/lib/tzinfo/definitions/America/Mexico_City.rb +136 -127
  389. data/lib/tzinfo/definitions/America/Miquelon.rb +142 -133
  390. data/lib/tzinfo/definitions/America/Moncton.rb +245 -239
  391. data/lib/tzinfo/definitions/America/Monterrey.rb +125 -117
  392. data/lib/tzinfo/definitions/America/Montevideo.rb +81 -80
  393. data/lib/tzinfo/definitions/America/Montreal.rb +271 -264
  394. data/lib/tzinfo/definitions/America/Montserrat.rb +13 -13
  395. data/lib/tzinfo/definitions/America/Nassau.rb +187 -177
  396. data/lib/tzinfo/definitions/America/New_York.rb +274 -267
  397. data/lib/tzinfo/definitions/America/Nipigon.rb +173 -162
  398. data/lib/tzinfo/definitions/America/Nome.rb +183 -175
  399. data/lib/tzinfo/definitions/America/Noronha.rb +51 -55
  400. data/lib/tzinfo/definitions/America/North_Dakota/Center.rb +190 -179
  401. data/lib/tzinfo/definitions/America/North_Dakota/New_Salem.rb +190 -0
  402. data/lib/tzinfo/definitions/America/Panama.rb +14 -14
  403. data/lib/tzinfo/definitions/America/Pangnirtung.rb +164 -153
  404. data/lib/tzinfo/definitions/America/Paramaribo.rb +17 -17
  405. data/lib/tzinfo/definitions/America/Phoenix.rb +23 -25
  406. data/lib/tzinfo/definitions/America/Port__m__au__m__Prince.rb +46 -46
  407. data/lib/tzinfo/definitions/America/Port_of_Spain.rb +13 -13
  408. data/lib/tzinfo/definitions/America/Porto_Acre.rb +11 -11
  409. data/lib/tzinfo/definitions/America/Porto_Velho.rb +41 -42
  410. data/lib/tzinfo/definitions/America/Puerto_Rico.rb +16 -15
  411. data/lib/tzinfo/definitions/America/Rainy_River.rb +173 -162
  412. data/lib/tzinfo/definitions/America/Rankin_Inlet.rb +164 -153
  413. data/lib/tzinfo/definitions/America/Recife.rb +51 -55
  414. data/lib/tzinfo/definitions/America/Regina.rb +65 -64
  415. data/lib/tzinfo/definitions/America/Rio_Branco.rb +41 -42
  416. data/lib/tzinfo/definitions/America/Rosario.rb +11 -11
  417. data/lib/tzinfo/definitions/America/Santiago.rb +195 -186
  418. data/lib/tzinfo/definitions/America/Santo_Domingo.rb +29 -29
  419. data/lib/tzinfo/definitions/America/Sao_Paulo.rb +165 -157
  420. data/lib/tzinfo/definitions/America/Scoresbysund.rb +155 -145
  421. data/lib/tzinfo/definitions/America/Shiprock.rb +11 -11
  422. data/lib/tzinfo/definitions/America/St_Johns.rb +277 -270
  423. data/lib/tzinfo/definitions/America/St_Kitts.rb +13 -13
  424. data/lib/tzinfo/definitions/America/St_Lucia.rb +14 -14
  425. data/lib/tzinfo/definitions/America/St_Thomas.rb +13 -13
  426. data/lib/tzinfo/definitions/America/St_Vincent.rb +14 -14
  427. data/lib/tzinfo/definitions/America/Swift_Current.rb +35 -34
  428. data/lib/tzinfo/definitions/America/Tegucigalpa.rb +17 -17
  429. data/lib/tzinfo/definitions/America/Thule.rb +133 -123
  430. data/lib/tzinfo/definitions/America/Thunder_Bay.rb +177 -170
  431. data/lib/tzinfo/definitions/America/Tijuana.rb +187 -182
  432. data/lib/tzinfo/definitions/America/Toronto.rb +271 -263
  433. data/lib/tzinfo/definitions/America/Tortola.rb +13 -13
  434. data/lib/tzinfo/definitions/America/Vancouver.rb +228 -217
  435. data/lib/tzinfo/definitions/America/Virgin.rb +11 -11
  436. data/lib/tzinfo/definitions/America/Whitehorse.rb +165 -154
  437. data/lib/tzinfo/definitions/America/Winnipeg.rb +224 -213
  438. data/lib/tzinfo/definitions/America/Yakutat.rb +182 -174
  439. data/lib/tzinfo/definitions/America/Yellowknife.rb +164 -153
  440. data/lib/tzinfo/definitions/Antarctica/Casey.rb +13 -13
  441. data/lib/tzinfo/definitions/Antarctica/Davis.rb +15 -15
  442. data/lib/tzinfo/definitions/Antarctica/DumontDUrville.rb +15 -15
  443. data/lib/tzinfo/definitions/Antarctica/Mawson.rb +13 -13
  444. data/lib/tzinfo/definitions/Antarctica/McMurdo.rb +165 -156
  445. data/lib/tzinfo/definitions/Antarctica/Palmer.rb +168 -158
  446. data/lib/tzinfo/definitions/Antarctica/Rothera.rb +13 -13
  447. data/lib/tzinfo/definitions/Antarctica/South_Pole.rb +11 -11
  448. data/lib/tzinfo/definitions/Antarctica/Syowa.rb +13 -13
  449. data/lib/tzinfo/definitions/Antarctica/Vostok.rb +13 -13
  450. data/lib/tzinfo/definitions/Arctic/Longyearbyen.rb +11 -11
  451. data/lib/tzinfo/definitions/Asia/Aden.rb +13 -13
  452. data/lib/tzinfo/definitions/Asia/Almaty.rb +60 -63
  453. data/lib/tzinfo/definitions/Asia/Amman.rb +157 -147
  454. data/lib/tzinfo/definitions/Asia/Anadyr.rb +155 -145
  455. data/lib/tzinfo/definitions/Asia/Aqtau.rb +62 -63
  456. data/lib/tzinfo/definitions/Asia/Aqtobe.rb +61 -63
  457. data/lib/tzinfo/definitions/Asia/Ashgabat.rb +38 -38
  458. data/lib/tzinfo/definitions/Asia/Ashkhabad.rb +11 -11
  459. data/lib/tzinfo/definitions/Asia/Baghdad.rb +152 -142
  460. data/lib/tzinfo/definitions/Asia/Bahrain.rb +14 -14
  461. data/lib/tzinfo/definitions/Asia/Baku.rb +149 -141
  462. data/lib/tzinfo/definitions/Asia/Bangkok.rb +14 -14
  463. data/lib/tzinfo/definitions/Asia/Beirut.rb +179 -169
  464. data/lib/tzinfo/definitions/Asia/Bishkek.rb +64 -63
  465. data/lib/tzinfo/definitions/Asia/Brunei.rb +14 -14
  466. data/lib/tzinfo/definitions/Asia/Calcutta.rb +17 -17
  467. data/lib/tzinfo/definitions/Asia/Choibalsan.rb +146 -136
  468. data/lib/tzinfo/definitions/Asia/Chongqing.rb +26 -26
  469. data/lib/tzinfo/definitions/Asia/Chungking.rb +11 -11
  470. data/lib/tzinfo/definitions/Asia/Colombo.rb +20 -19
  471. data/lib/tzinfo/definitions/Asia/Dacca.rb +11 -11
  472. data/lib/tzinfo/definitions/Asia/Damascus.rb +189 -179
  473. data/lib/tzinfo/definitions/Asia/Dhaka.rb +18 -18
  474. data/lib/tzinfo/definitions/Asia/Dili.rb +17 -17
  475. data/lib/tzinfo/definitions/Asia/Dubai.rb +13 -13
  476. data/lib/tzinfo/definitions/Asia/Dushanbe.rb +36 -36
  477. data/lib/tzinfo/definitions/Asia/Gaza.rb +182 -173
  478. data/lib/tzinfo/definitions/Asia/Harbin.rb +29 -29
  479. data/lib/tzinfo/definitions/Asia/Hong_Kong.rb +81 -81
  480. data/lib/tzinfo/definitions/Asia/Hovd.rb +146 -136
  481. data/lib/tzinfo/definitions/Asia/Irkutsk.rb +156 -146
  482. data/lib/tzinfo/definitions/Asia/Istanbul.rb +11 -11
  483. data/lib/tzinfo/definitions/Asia/Jakarta.rb +20 -20
  484. data/lib/tzinfo/definitions/Asia/Jayapura.rb +15 -15
  485. data/lib/tzinfo/definitions/Asia/Jerusalem.rb +155 -155
  486. data/lib/tzinfo/definitions/Asia/Kabul.rb +14 -14
  487. data/lib/tzinfo/definitions/Asia/Kamchatka.rb +155 -145
  488. data/lib/tzinfo/definitions/Asia/Karachi.rb +19 -19
  489. data/lib/tzinfo/definitions/Asia/Kashgar.rb +27 -27
  490. data/lib/tzinfo/definitions/Asia/Katmandu.rb +14 -14
  491. data/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +155 -145
  492. data/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +20 -20
  493. data/lib/tzinfo/definitions/Asia/Kuching.rb +31 -31
  494. data/lib/tzinfo/definitions/Asia/Kuwait.rb +13 -13
  495. data/lib/tzinfo/definitions/Asia/Macao.rb +11 -11
  496. data/lib/tzinfo/definitions/Asia/Macau.rb +54 -54
  497. data/lib/tzinfo/definitions/Asia/Magadan.rb +155 -145
  498. data/lib/tzinfo/definitions/Asia/Makassar.rb +16 -16
  499. data/lib/tzinfo/definitions/Asia/Manila.rb +22 -22
  500. data/lib/tzinfo/definitions/Asia/Muscat.rb +13 -13
  501. data/lib/tzinfo/definitions/Asia/Nicosia.rb +165 -156
  502. data/lib/tzinfo/definitions/Asia/Novosibirsk.rb +156 -146
  503. data/lib/tzinfo/definitions/Asia/Omsk.rb +155 -145
  504. data/lib/tzinfo/definitions/Asia/Oral.rb +62 -63
  505. data/lib/tzinfo/definitions/Asia/Phnom_Penh.rb +16 -16
  506. data/lib/tzinfo/definitions/Asia/Pontianak.rb +20 -20
  507. data/lib/tzinfo/definitions/Asia/Pyongyang.rb +18 -18
  508. data/lib/tzinfo/definitions/Asia/Qatar.rb +14 -14
  509. data/lib/tzinfo/definitions/Asia/Qyzylorda.rb +62 -64
  510. data/lib/tzinfo/definitions/Asia/Rangoon.rb +16 -16
  511. data/lib/tzinfo/definitions/Asia/Riyadh.rb +13 -13
  512. data/lib/tzinfo/definitions/Asia/Riyadh87.rb +348 -0
  513. data/lib/tzinfo/definitions/Asia/Riyadh88.rb +349 -0
  514. data/lib/tzinfo/definitions/Asia/Riyadh89.rb +349 -0
  515. data/lib/tzinfo/definitions/Asia/Saigon.rb +16 -16
  516. data/lib/tzinfo/definitions/Asia/Sakhalin.rb +156 -146
  517. data/lib/tzinfo/definitions/Asia/Samarkand.rb +37 -41
  518. data/lib/tzinfo/definitions/Asia/Seoul.rb +25 -25
  519. data/lib/tzinfo/definitions/Asia/Shanghai.rb +29 -30
  520. data/lib/tzinfo/definitions/Asia/Singapore.rb +21 -21
  521. data/lib/tzinfo/definitions/Asia/Taipei.rb +53 -53
  522. data/lib/tzinfo/definitions/Asia/Tashkent.rb +37 -41
  523. data/lib/tzinfo/definitions/Asia/Tbilisi.rb +65 -67
  524. data/lib/tzinfo/definitions/Asia/Tehran.rb +52 -116
  525. data/lib/tzinfo/definitions/Asia/Tel_Aviv.rb +11 -11
  526. data/lib/tzinfo/definitions/Asia/Thimbu.rb +11 -11
  527. data/lib/tzinfo/definitions/Asia/Thimphu.rb +14 -14
  528. data/lib/tzinfo/definitions/Asia/Tokyo.rb +23 -23
  529. data/lib/tzinfo/definitions/Asia/Ujung_Pandang.rb +11 -11
  530. data/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +146 -136
  531. data/lib/tzinfo/definitions/Asia/Ulan_Bator.rb +11 -11
  532. data/lib/tzinfo/definitions/Asia/Urumqi.rb +26 -26
  533. data/lib/tzinfo/definitions/Asia/Vientiane.rb +16 -16
  534. data/lib/tzinfo/definitions/Asia/Vladivostok.rb +155 -145
  535. data/lib/tzinfo/definitions/Asia/Yakutsk.rb +155 -145
  536. data/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +155 -145
  537. data/lib/tzinfo/definitions/Asia/Yerevan.rb +153 -144
  538. data/lib/tzinfo/definitions/Atlantic/Azores.rb +259 -249
  539. data/lib/tzinfo/definitions/Atlantic/Bermuda.rb +167 -157
  540. data/lib/tzinfo/definitions/Atlantic/Canary.rb +156 -147
  541. data/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +16 -16
  542. data/lib/tzinfo/definitions/Atlantic/Faeroe.rb +153 -144
  543. data/lib/tzinfo/definitions/Atlantic/Jan_Mayen.rb +11 -11
  544. data/lib/tzinfo/definitions/Atlantic/Madeira.rb +259 -249
  545. data/lib/tzinfo/definitions/Atlantic/Reykjavik.rb +77 -77
  546. data/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +13 -13
  547. data/lib/tzinfo/definitions/Atlantic/St_Helena.rb +14 -14
  548. data/lib/tzinfo/definitions/Atlantic/Stanley.rb +161 -152
  549. data/lib/tzinfo/definitions/Australia/ACT.rb +11 -11
  550. data/lib/tzinfo/definitions/Australia/Adelaide.rb +180 -172
  551. data/lib/tzinfo/definitions/Australia/Brisbane.rb +29 -30
  552. data/lib/tzinfo/definitions/Australia/Broken_Hill.rb +181 -174
  553. data/lib/tzinfo/definitions/Australia/Canberra.rb +11 -11
  554. data/lib/tzinfo/definitions/Australia/Currie.rb +179 -172
  555. data/lib/tzinfo/definitions/Australia/Darwin.rb +22 -22
  556. data/lib/tzinfo/definitions/Australia/Hobart.rb +187 -180
  557. data/lib/tzinfo/definitions/Australia/LHI.rb +11 -11
  558. data/lib/tzinfo/definitions/Australia/Lindeman.rb +33 -35
  559. data/lib/tzinfo/definitions/Australia/Lord_Howe.rb +152 -143
  560. data/lib/tzinfo/definitions/Australia/Melbourne.rb +179 -171
  561. data/lib/tzinfo/definitions/Australia/NSW.rb +11 -11
  562. data/lib/tzinfo/definitions/Australia/North.rb +11 -11
  563. data/lib/tzinfo/definitions/Australia/Perth.rb +25 -26
  564. data/lib/tzinfo/definitions/Australia/Queensland.rb +11 -11
  565. data/lib/tzinfo/definitions/Australia/South.rb +11 -11
  566. data/lib/tzinfo/definitions/Australia/Sydney.rb +179 -171
  567. data/lib/tzinfo/definitions/Australia/Tasmania.rb +11 -11
  568. data/lib/tzinfo/definitions/Australia/Victoria.rb +11 -11
  569. data/lib/tzinfo/definitions/Australia/West.rb +11 -11
  570. data/lib/tzinfo/definitions/Australia/Yancowinna.rb +11 -11
  571. data/lib/tzinfo/definitions/Brazil/Acre.rb +11 -11
  572. data/lib/tzinfo/definitions/Brazil/DeNoronha.rb +11 -11
  573. data/lib/tzinfo/definitions/Brazil/East.rb +11 -11
  574. data/lib/tzinfo/definitions/Brazil/West.rb +11 -11
  575. data/lib/tzinfo/definitions/CET.rb +170 -160
  576. data/lib/tzinfo/definitions/CST6CDT.rb +185 -174
  577. data/lib/tzinfo/definitions/Canada/Atlantic.rb +11 -11
  578. data/lib/tzinfo/definitions/Canada/Central.rb +11 -11
  579. data/lib/tzinfo/definitions/Canada/East__m__Saskatchewan.rb +11 -11
  580. data/lib/tzinfo/definitions/Canada/Eastern.rb +11 -11
  581. data/lib/tzinfo/definitions/Canada/Mountain.rb +11 -11
  582. data/lib/tzinfo/definitions/Canada/Newfoundland.rb +11 -11
  583. data/lib/tzinfo/definitions/Canada/Pacific.rb +11 -11
  584. data/lib/tzinfo/definitions/Canada/Saskatchewan.rb +11 -11
  585. data/lib/tzinfo/definitions/Canada/Yukon.rb +11 -11
  586. data/lib/tzinfo/definitions/Chile/Continental.rb +11 -11
  587. data/lib/tzinfo/definitions/Chile/EasterIsland.rb +11 -11
  588. data/lib/tzinfo/definitions/Cuba.rb +9 -9
  589. data/lib/tzinfo/definitions/EET.rb +158 -148
  590. data/lib/tzinfo/definitions/EST.rb +10 -10
  591. data/lib/tzinfo/definitions/EST5EDT.rb +185 -174
  592. data/lib/tzinfo/definitions/Egypt.rb +9 -9
  593. data/lib/tzinfo/definitions/Eire.rb +9 -9
  594. data/lib/tzinfo/definitions/Etc/GMT.rb +12 -12
  595. data/lib/tzinfo/definitions/Etc/GMT0.rb +11 -11
  596. data/lib/tzinfo/definitions/Etc/GMT__m__0.rb +11 -11
  597. data/lib/tzinfo/definitions/Etc/GMT__m__1.rb +12 -12
  598. data/lib/tzinfo/definitions/Etc/GMT__m__10.rb +12 -12
  599. data/lib/tzinfo/definitions/Etc/GMT__m__11.rb +12 -12
  600. data/lib/tzinfo/definitions/Etc/GMT__m__12.rb +12 -12
  601. data/lib/tzinfo/definitions/Etc/GMT__m__13.rb +12 -12
  602. data/lib/tzinfo/definitions/Etc/GMT__m__14.rb +12 -12
  603. data/lib/tzinfo/definitions/Etc/GMT__m__2.rb +12 -12
  604. data/lib/tzinfo/definitions/Etc/GMT__m__3.rb +12 -12
  605. data/lib/tzinfo/definitions/Etc/GMT__m__4.rb +12 -12
  606. data/lib/tzinfo/definitions/Etc/GMT__m__5.rb +12 -12
  607. data/lib/tzinfo/definitions/Etc/GMT__m__6.rb +12 -12
  608. data/lib/tzinfo/definitions/Etc/GMT__m__7.rb +12 -12
  609. data/lib/tzinfo/definitions/Etc/GMT__m__8.rb +12 -12
  610. data/lib/tzinfo/definitions/Etc/GMT__m__9.rb +12 -12
  611. data/lib/tzinfo/definitions/Etc/GMT__p__0.rb +11 -11
  612. data/lib/tzinfo/definitions/Etc/GMT__p__1.rb +12 -12
  613. data/lib/tzinfo/definitions/Etc/GMT__p__10.rb +12 -12
  614. data/lib/tzinfo/definitions/Etc/GMT__p__11.rb +12 -12
  615. data/lib/tzinfo/definitions/Etc/GMT__p__12.rb +12 -12
  616. data/lib/tzinfo/definitions/Etc/GMT__p__2.rb +12 -12
  617. data/lib/tzinfo/definitions/Etc/GMT__p__3.rb +12 -12
  618. data/lib/tzinfo/definitions/Etc/GMT__p__4.rb +12 -12
  619. data/lib/tzinfo/definitions/Etc/GMT__p__5.rb +12 -12
  620. data/lib/tzinfo/definitions/Etc/GMT__p__6.rb +12 -12
  621. data/lib/tzinfo/definitions/Etc/GMT__p__7.rb +12 -12
  622. data/lib/tzinfo/definitions/Etc/GMT__p__8.rb +12 -12
  623. data/lib/tzinfo/definitions/Etc/GMT__p__9.rb +12 -12
  624. data/lib/tzinfo/definitions/Etc/Greenwich.rb +11 -11
  625. data/lib/tzinfo/definitions/Etc/UCT.rb +12 -12
  626. data/lib/tzinfo/definitions/Etc/UTC.rb +12 -12
  627. data/lib/tzinfo/definitions/Etc/Universal.rb +11 -11
  628. data/lib/tzinfo/definitions/Etc/Zulu.rb +11 -11
  629. data/lib/tzinfo/definitions/Europe/Amsterdam.rb +218 -208
  630. data/lib/tzinfo/definitions/Europe/Andorra.rb +146 -136
  631. data/lib/tzinfo/definitions/Europe/Athens.rb +176 -167
  632. data/lib/tzinfo/definitions/Europe/Belfast.rb +11 -11
  633. data/lib/tzinfo/definitions/Europe/Belgrade.rb +157 -147
  634. data/lib/tzinfo/definitions/Europe/Berlin.rb +181 -172
  635. data/lib/tzinfo/definitions/Europe/Bratislava.rb +11 -11
  636. data/lib/tzinfo/definitions/Europe/Brussels.rb +223 -214
  637. data/lib/tzinfo/definitions/Europe/Bucharest.rb +174 -167
  638. data/lib/tzinfo/definitions/Europe/Budapest.rb +191 -181
  639. data/lib/tzinfo/definitions/Europe/Chisinau.rb +177 -170
  640. data/lib/tzinfo/definitions/Europe/Copenhagen.rb +172 -163
  641. data/lib/tzinfo/definitions/Europe/Dublin.rb +265 -257
  642. data/lib/tzinfo/definitions/Europe/Gibraltar.rb +236 -227
  643. data/lib/tzinfo/definitions/Europe/Helsinki.rb +156 -147
  644. data/lib/tzinfo/definitions/Europe/Istanbul.rb +209 -201
  645. data/lib/tzinfo/definitions/Europe/Kaliningrad.rb +169 -159
  646. data/lib/tzinfo/definitions/Europe/Kiev.rb +157 -149
  647. data/lib/tzinfo/definitions/Europe/Lisbon.rb +259 -250
  648. data/lib/tzinfo/definitions/Europe/Ljubljana.rb +11 -11
  649. data/lib/tzinfo/definitions/Europe/London.rb +279 -271
  650. data/lib/tzinfo/definitions/Europe/Luxembourg.rb +221 -211
  651. data/lib/tzinfo/definitions/Europe/Madrid.rb +202 -193
  652. data/lib/tzinfo/definitions/Europe/Malta.rb +207 -198
  653. data/lib/tzinfo/definitions/Europe/Mariehamn.rb +11 -11
  654. data/lib/tzinfo/definitions/Europe/Minsk.rb +159 -147
  655. data/lib/tzinfo/definitions/Europe/Monaco.rb +223 -214
  656. data/lib/tzinfo/definitions/Europe/Moscow.rb +168 -158
  657. data/lib/tzinfo/definitions/Europe/Nicosia.rb +11 -11
  658. data/lib/tzinfo/definitions/Europe/Oslo.rb +179 -169
  659. data/lib/tzinfo/definitions/Europe/Paris.rb +222 -212
  660. data/lib/tzinfo/definitions/Europe/Prague.rb +180 -170
  661. data/lib/tzinfo/definitions/Europe/Riga.rb +164 -156
  662. data/lib/tzinfo/definitions/Europe/Rome.rb +208 -200
  663. data/lib/tzinfo/definitions/Europe/Samara.rb +155 -145
  664. data/lib/tzinfo/definitions/Europe/San_Marino.rb +11 -11
  665. data/lib/tzinfo/definitions/Europe/Sarajevo.rb +11 -11
  666. data/lib/tzinfo/definitions/Europe/Simferopol.rb +159 -151
  667. data/lib/tzinfo/definitions/Europe/Skopje.rb +11 -11
  668. data/lib/tzinfo/definitions/Europe/Sofia.rb +164 -157
  669. data/lib/tzinfo/definitions/Europe/Stockholm.rb +158 -149
  670. data/lib/tzinfo/definitions/Europe/Tallinn.rb +161 -152
  671. data/lib/tzinfo/definitions/Europe/Tirane.rb +171 -162
  672. data/lib/tzinfo/definitions/Europe/Tiraspol.rb +11 -11
  673. data/lib/tzinfo/definitions/Europe/Uzhgorod.rb +158 -153
  674. data/lib/tzinfo/definitions/Europe/Vaduz.rb +153 -144
  675. data/lib/tzinfo/definitions/Europe/Vatican.rb +11 -11
  676. data/lib/tzinfo/definitions/Europe/Vienna.rb +177 -170
  677. data/lib/tzinfo/definitions/Europe/Vilnius.rb +158 -148
  678. data/lib/tzinfo/definitions/Europe/Warsaw.rb +203 -195
  679. data/lib/tzinfo/definitions/Europe/Zagreb.rb +11 -11
  680. data/lib/tzinfo/definitions/Europe/Zaporozhye.rb +160 -150
  681. data/lib/tzinfo/definitions/Europe/Zurich.rb +160 -151
  682. data/lib/tzinfo/definitions/GB.rb +9 -9
  683. data/lib/tzinfo/definitions/GB__m__Eire.rb +9 -9
  684. data/lib/tzinfo/definitions/GMT.rb +9 -9
  685. data/lib/tzinfo/definitions/GMT0.rb +9 -9
  686. data/lib/tzinfo/definitions/GMT__m__0.rb +9 -9
  687. data/lib/tzinfo/definitions/GMT__p__0.rb +9 -9
  688. data/lib/tzinfo/definitions/Greenwich.rb +9 -9
  689. data/lib/tzinfo/definitions/HST.rb +10 -10
  690. data/lib/tzinfo/definitions/Hongkong.rb +9 -9
  691. data/lib/tzinfo/definitions/Iceland.rb +9 -9
  692. data/lib/tzinfo/definitions/Indian/Antananarivo.rb +15 -15
  693. data/lib/tzinfo/definitions/Indian/Chagos.rb +14 -14
  694. data/lib/tzinfo/definitions/Indian/Christmas.rb +13 -13
  695. data/lib/tzinfo/definitions/Indian/Cocos.rb +13 -13
  696. data/lib/tzinfo/definitions/Indian/Comoro.rb +13 -13
  697. data/lib/tzinfo/definitions/Indian/Kerguelen.rb +13 -13
  698. data/lib/tzinfo/definitions/Indian/Mahe.rb +13 -13
  699. data/lib/tzinfo/definitions/Indian/Maldives.rb +14 -14
  700. data/lib/tzinfo/definitions/Indian/Mauritius.rb +13 -13
  701. data/lib/tzinfo/definitions/Indian/Mayotte.rb +13 -13
  702. data/lib/tzinfo/definitions/Indian/Reunion.rb +13 -13
  703. data/lib/tzinfo/definitions/Iran.rb +9 -9
  704. data/lib/tzinfo/definitions/Israel.rb +9 -9
  705. data/lib/tzinfo/definitions/Jamaica.rb +9 -9
  706. data/lib/tzinfo/definitions/Japan.rb +9 -9
  707. data/lib/tzinfo/definitions/Kwajalein.rb +9 -9
  708. data/lib/tzinfo/definitions/Libya.rb +9 -9
  709. data/lib/tzinfo/definitions/MET.rb +170 -160
  710. data/lib/tzinfo/definitions/MST.rb +10 -10
  711. data/lib/tzinfo/definitions/MST7MDT.rb +185 -174
  712. data/lib/tzinfo/definitions/Mexico/BajaNorte.rb +11 -11
  713. data/lib/tzinfo/definitions/Mexico/BajaSur.rb +11 -11
  714. data/lib/tzinfo/definitions/Mexico/General.rb +11 -11
  715. data/lib/tzinfo/definitions/Mideast/Riyadh87.rb +11 -0
  716. data/lib/tzinfo/definitions/Mideast/Riyadh88.rb +11 -0
  717. data/lib/tzinfo/definitions/Mideast/Riyadh89.rb +11 -0
  718. data/lib/tzinfo/definitions/NZ.rb +9 -9
  719. data/lib/tzinfo/definitions/NZ__m__CHAT.rb +9 -9
  720. data/lib/tzinfo/definitions/Navajo.rb +9 -9
  721. data/lib/tzinfo/definitions/PRC.rb +9 -9
  722. data/lib/tzinfo/definitions/PST8PDT.rb +185 -174
  723. data/lib/tzinfo/definitions/Pacific/Apia.rb +15 -15
  724. data/lib/tzinfo/definitions/Pacific/Auckland.rb +192 -184
  725. data/lib/tzinfo/definitions/Pacific/Chatham.rb +165 -156
  726. data/lib/tzinfo/definitions/Pacific/Easter.rb +182 -174
  727. data/lib/tzinfo/definitions/Pacific/Efate.rb +33 -33
  728. data/lib/tzinfo/definitions/Pacific/Enderbury.rb +15 -15
  729. data/lib/tzinfo/definitions/Pacific/Fakaofo.rb +13 -13
  730. data/lib/tzinfo/definitions/Pacific/Fiji.rb +17 -17
  731. data/lib/tzinfo/definitions/Pacific/Funafuti.rb +13 -13
  732. data/lib/tzinfo/definitions/Pacific/Galapagos.rb +14 -14
  733. data/lib/tzinfo/definitions/Pacific/Gambier.rb +13 -13
  734. data/lib/tzinfo/definitions/Pacific/Guadalcanal.rb +13 -13
  735. data/lib/tzinfo/definitions/Pacific/Guam.rb +15 -15
  736. data/lib/tzinfo/definitions/Pacific/Honolulu.rb +19 -17
  737. data/lib/tzinfo/definitions/Pacific/Johnston.rb +12 -12
  738. data/lib/tzinfo/definitions/Pacific/Kiritimati.rb +15 -15
  739. data/lib/tzinfo/definitions/Pacific/Kosrae.rb +15 -15
  740. data/lib/tzinfo/definitions/Pacific/Kwajalein.rb +15 -15
  741. data/lib/tzinfo/definitions/Pacific/Majuro.rb +14 -14
  742. data/lib/tzinfo/definitions/Pacific/Marquesas.rb +13 -13
  743. data/lib/tzinfo/definitions/Pacific/Midway.rb +17 -17
  744. data/lib/tzinfo/definitions/Pacific/Nauru.rb +16 -16
  745. data/lib/tzinfo/definitions/Pacific/Niue.rb +15 -15
  746. data/lib/tzinfo/definitions/Pacific/Norfolk.rb +14 -14
  747. data/lib/tzinfo/definitions/Pacific/Noumea.rb +19 -19
  748. data/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +17 -17
  749. data/lib/tzinfo/definitions/Pacific/Palau.rb +13 -13
  750. data/lib/tzinfo/definitions/Pacific/Pitcairn.rb +14 -14
  751. data/lib/tzinfo/definitions/Pacific/Ponape.rb +13 -13
  752. data/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +14 -14
  753. data/lib/tzinfo/definitions/Pacific/Rarotonga.rb +39 -39
  754. data/lib/tzinfo/definitions/Pacific/Saipan.rb +16 -16
  755. data/lib/tzinfo/definitions/Pacific/Samoa.rb +11 -11
  756. data/lib/tzinfo/definitions/Pacific/Tahiti.rb +13 -13
  757. data/lib/tzinfo/definitions/Pacific/Tarawa.rb +13 -13
  758. data/lib/tzinfo/definitions/Pacific/Tongatapu.rb +20 -21
  759. data/lib/tzinfo/definitions/Pacific/Truk.rb +13 -13
  760. data/lib/tzinfo/definitions/Pacific/Wake.rb +13 -13
  761. data/lib/tzinfo/definitions/Pacific/Wallis.rb +13 -13
  762. data/lib/tzinfo/definitions/Pacific/Yap.rb +11 -11
  763. data/lib/tzinfo/definitions/Poland.rb +9 -9
  764. data/lib/tzinfo/definitions/Portugal.rb +9 -9
  765. data/lib/tzinfo/definitions/ROC.rb +9 -9
  766. data/lib/tzinfo/definitions/ROK.rb +9 -9
  767. data/lib/tzinfo/definitions/Singapore.rb +9 -9
  768. data/lib/tzinfo/definitions/Turkey.rb +9 -9
  769. data/lib/tzinfo/definitions/UCT.rb +9 -9
  770. data/lib/tzinfo/definitions/US/Alaska.rb +11 -11
  771. data/lib/tzinfo/definitions/US/Aleutian.rb +11 -11
  772. data/lib/tzinfo/definitions/US/Arizona.rb +11 -11
  773. data/lib/tzinfo/definitions/US/Central.rb +11 -11
  774. data/lib/tzinfo/definitions/US/East__m__Indiana.rb +11 -11
  775. data/lib/tzinfo/definitions/US/Eastern.rb +11 -11
  776. data/lib/tzinfo/definitions/US/Hawaii.rb +11 -11
  777. data/lib/tzinfo/definitions/US/Indiana__m__Starke.rb +11 -11
  778. data/lib/tzinfo/definitions/US/Michigan.rb +11 -11
  779. data/lib/tzinfo/definitions/US/Mountain.rb +11 -11
  780. data/lib/tzinfo/definitions/US/Pacific.rb +11 -11
  781. data/lib/tzinfo/definitions/US/Pacific__m__New.rb +11 -11
  782. data/lib/tzinfo/definitions/US/Samoa.rb +11 -11
  783. data/lib/tzinfo/definitions/UTC.rb +9 -9
  784. data/lib/tzinfo/definitions/Universal.rb +9 -9
  785. data/lib/tzinfo/definitions/WET.rb +158 -148
  786. data/lib/tzinfo/definitions/W__m__SU.rb +9 -9
  787. data/lib/tzinfo/definitions/Zulu.rb +9 -9
  788. data/lib/tzinfo/offset_rationals.rb +95 -0
  789. data/lib/tzinfo/time_or_datetime.rb +269 -0
  790. data/lib/tzinfo/timezone.rb +25 -44
  791. data/lib/tzinfo/timezone_period.rb +54 -87
  792. data/lib/tzinfo/timezone_period_list.rb +7 -2
  793. data/lib/tzinfo/tzdataparser.rb +378 -325
  794. data/test/tc_offset_rationals.rb +25 -0
  795. data/test/tc_time_or_datetime.rb +386 -0
  796. data/test/tc_timezone.rb +43 -7
  797. data/test/tc_timezone_london.rb +61 -1
  798. data/test/tc_timezone_melbourne.rb +61 -1
  799. data/test/tc_timezone_new_york.rb +61 -1
  800. data/test/tc_timezone_period.rb +152 -65
  801. data/test/ts_all.rb +4 -0
  802. metadata +14 -2
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2005 Philip Ross
2
+ # Copyright (c) 2005-2006 Philip Ross
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -20,69 +20,16 @@
20
20
  # THE SOFTWARE.
21
21
  #++
22
22
 
23
+ require 'tzinfo/offset_rationals'
24
+ require 'tzinfo/time_or_datetime'
25
+
23
26
  module TZInfo
24
27
  # A period of time in a timezone where the same offset from UTC applies.
28
+ #
29
+ # All the methods that take times accept instances of Time, DateTime or
30
+ # integer timestamps.
25
31
  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
-
32
+
86
33
  # Base offset of the timezone from UTC (seconds).
87
34
  attr_reader :utc_offset
88
35
 
@@ -94,39 +41,55 @@ module TZInfo
94
41
  # The identifier of this period, e.g. "GMT" (Greenwich Mean Time) or "BST"
95
42
  # (British Summer Time) for "Europe/London". The returned identifier is a
96
43
  # 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
44
+ attr_reader :zone_identifier
101
45
 
102
- # End time of the period (local time). May be nil if unbounded.
103
- attr_reader :local_end
46
+ # Total offset from UTC (seconds). Equal to utc_offset + std_offset.
47
+ attr_reader :utc_total_offset
104
48
 
105
49
  # Initializes a new TimezonePeriod.
106
50
  def initialize(utc_start, utc_end, utc_offset, std_offset, zone_identifier)
107
- @utc_start = utc_start
108
- @utc_end = utc_end
51
+ @utc_start = utc_start.nil? ? nil : TimeOrDateTime.wrap(utc_start)
52
+ @utc_end = utc_end.nil? ? nil : TimeOrDateTime.wrap(utc_end)
109
53
  @utc_offset = utc_offset
110
54
  @std_offset = std_offset
111
55
  @zone_identifier = zone_identifier
112
56
  @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
57
+ @utc_total_offset_rational = nil
58
+
59
+ # Use add_with_convert to use DateTime based TimeOrDateTimes if we run
60
+ # off the range of Time.
61
+ @local_start = @utc_start.nil? ? nil : @utc_start.add_with_convert(@utc_total_offset)
62
+ @local_end = @utc_end.nil? ? nil : @utc_end.add_with_convert(@utc_total_offset)
123
63
  end
124
-
64
+
125
65
  # Total offset from UTC (days). Result is a Rational.
126
66
  def utc_total_offset_rational
67
+ if @utc_total_offset_rational.nil?
68
+ @utc_total_offset_rational = OffsetRationals.rational_for_offset(@utc_total_offset)
69
+ end
127
70
  @utc_total_offset_rational
128
71
  end
129
72
 
73
+ # Start time of the period (UTC). May be nil if unbounded.
74
+ def utc_start
75
+ @utc_start.nil? ? nil : @utc_start.to_datetime
76
+ end
77
+
78
+ # End time of the period (UTC). May be nil if unbounded.
79
+ def utc_end
80
+ @utc_end.nil? ? nil : @utc_end.to_datetime
81
+ end
82
+
83
+ # Start time of the period (local time). May be nil if unbounded.
84
+ def local_start
85
+ @local_start.nil? ? nil : @local_start.to_datetime
86
+ end
87
+
88
+ # End time of the period (local time). May be nil if unbounded.
89
+ def local_end
90
+ @local_end.nil? ? nil : @local_end.to_datetime
91
+ end
92
+
130
93
  # true if daylight savings is in effect for this period; otherwise false.
131
94
  def dst?
132
95
  std_offset != 0
@@ -138,38 +101,42 @@ module TZInfo
138
101
  end
139
102
 
140
103
  # true if the given utc DateTime is after the start of the period (inclusive); otherwise false.
141
- def utc_after_start?(utc)
104
+ def utc_after_start?(utc)
142
105
  @utc_start.nil? || @utc_start <= utc
143
106
  end
144
107
 
145
108
  # true if the given utc DateTime is before the end of the period (exclusive); otherwise false.
146
- def utc_before_end?(utc)
109
+ def utc_before_end?(utc)
147
110
  @utc_end.nil? || @utc_end > utc
148
111
  end
149
112
 
150
113
  # true if this period is valid for the given local DateTime; otherwise false.
151
- def valid_for_local?(local)
114
+ def valid_for_local?(local)
152
115
  local_after_start?(local) && local_before_end?(local)
153
116
  end
154
117
 
155
118
  # true if the given local DateTime is after the start of the period (inclusive); otherwise false.
156
- def local_after_start?(local)
119
+ def local_after_start?(local)
157
120
  @local_start.nil? || @local_start <= local
158
121
  end
159
122
 
160
123
  # true if the given local DateTime is before the end of the period (exclusive); otherwise false.
161
- def local_before_end?(local)
124
+ def local_before_end?(local)
162
125
  @local_end.nil? || @local_end > local
163
126
  end
164
127
 
165
128
  # Converts a UTC DateTime to local time based on the offset of this period.
166
129
  def to_local(utc)
167
- utc + utc_total_offset_rational
130
+ TimeOrDateTime.wrap(utc) {|utc|
131
+ utc + utc_total_offset
132
+ }
168
133
  end
169
134
 
170
135
  # Converts a local DateTime to UTC based on the offset of this period.
171
136
  def to_utc(local)
172
- local - utc_total_offset_rational
137
+ TimeOrDateTime.wrap(local) {|local|
138
+ local - utc_total_offset
139
+ }
173
140
  end
174
141
  end
175
142
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2005 Philip Ross
2
+ # Copyright (c) 2005-2006 Philip Ross
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  # of this software and associated documentation files (the "Software"), to deal
@@ -20,6 +20,7 @@
20
20
  # THE SOFTWARE.
21
21
  #++
22
22
 
23
+ require 'tzinfo/time_or_datetime'
23
24
  require 'tzinfo/timezone_period'
24
25
 
25
26
  module TZInfo
@@ -85,7 +86,9 @@ module TZInfo
85
86
 
86
87
  # Returns the period for the given utc time.
87
88
  # If no period is found for the given time, PeriodNotFound is thrown.
88
- def period_for_utc(utc)
89
+ def period_for_utc(utc)
90
+ utc = TimeOrDateTime.wrap(utc)
91
+
89
92
  if @list.nil?
90
93
  result = nil
91
94
  else
@@ -128,6 +131,8 @@ module TZInfo
128
131
  # If no period is found for the given time, PeriodNotFound is thrown.
129
132
  # Results returned are ordered by increasing UTC start date.
130
133
  def periods_for_local(local)
134
+ local = TimeOrDateTime.wrap(local)
135
+
131
136
  # found_first is used to avoid searching back to far
132
137
  # the search will be limited at the next half year block after discovering
133
138
  # the first match
@@ -32,7 +32,13 @@ module TZInfo
32
32
  # tzinfo version for a new version of the tzdata data.
33
33
  #
34
34
  # This process is extremely slow (optimization is required).
35
- class TZDataParser
35
+ class TZDataParser
36
+ # Minimum year that will be considered.
37
+ MIN_YEAR = 1800
38
+
39
+ # Maximum year that will be considered.
40
+ MAX_YEAR = 2050
41
+
36
42
  # Whether to generate zone definitions (set to false to stop zones being
37
43
  # generated).
38
44
  attr_accessor :generate_zones
@@ -75,8 +81,7 @@ module TZInfo
75
81
  @generate_countries = true
76
82
  @only_zones = []
77
83
  @only_countries = []
78
- @exclude_zones = ['Asia/Riyadh87', 'Asia/Riyadh88', 'Asia/Riyadh89',
79
- 'Mideast/Riyadh87', 'Mideast/Riyadh88', 'Mideast/Riyadh89']
84
+ @exclude_zones = []
80
85
  @exclude_countries = []
81
86
  end
82
87
 
@@ -153,6 +158,25 @@ module TZInfo
153
158
  end
154
159
  end
155
160
 
161
+ # Parses an offset string [-]h:m:s (minutes and seconds are optional). Returns
162
+ # the offset in seconds.
163
+ def self.parse_offset(offset)
164
+ raise "Invalid time: #{offset}" if offset !~ /^(-)?([0-9]+)(:([0-9]+)(:([0-9]+))?)?$/
165
+
166
+ negative = !$1.nil?
167
+ hour = $2.to_i
168
+ minute = $4.nil? ? 0 : $4.to_i
169
+ second = $6.nil? ? 0 : $6.to_i
170
+
171
+ seconds = hour
172
+ seconds = seconds * 60
173
+ seconds = seconds + minute
174
+ seconds = seconds * 60
175
+ seconds = seconds + second
176
+ seconds = -seconds if negative
177
+ seconds
178
+ end
179
+
156
180
  private
157
181
  # Loads all the Rule definitions from the tz data and stores them in
158
182
  # @rule_sets.
@@ -182,7 +206,7 @@ module TZInfo
182
206
  if ref == '-'
183
207
  @no_rules
184
208
  elsif ref =~ /^[0-9]+:[0-9]+$/
185
- TZDataFixedOffsetRules.new(TZDataOffset.new(ref))
209
+ TZDataFixedOffsetRules.new(TZDataParser.parse_offset(ref))
186
210
  else
187
211
  rule_set = @rule_sets[ref]
188
212
  raise "Ruleset not found: #{ref}" if rule_set.nil?
@@ -203,7 +227,7 @@ module TZInfo
203
227
  if in_zone
204
228
  if line =~ /^\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)(\s+([0-9]+(\s+.*)?))?$/
205
229
 
206
- in_zone.add_period(TZDataPeriod.new($1, get_rules($2), $3, $5))
230
+ in_zone.add_observance(TZDataObservance.new($1, get_rules($2), $3, $5))
207
231
 
208
232
  in_zone = nil if $4.nil?
209
233
  end
@@ -215,7 +239,7 @@ module TZInfo
215
239
  @zones[name] = TZDataZone.new(name)
216
240
  end
217
241
 
218
- @zones[name].add_period(TZDataPeriod.new($2, get_rules($3), $4, $6))
242
+ @zones[name].add_observance(TZDataObservance.new($2, get_rules($3), $4, $6))
219
243
 
220
244
  in_zone = @zones[name] if !$5.nil?
221
245
  end
@@ -320,37 +344,9 @@ module TZInfo
320
344
  @name = name
321
345
  end
322
346
 
323
- protected
324
- # Writes a period of time with the same utc and std offsets to the file.
325
- def write_period(file, utc_start, utc_end, period, std_offset, letter)
326
- # The tzdata neglects to define the identifier for certain periods
327
- # These have %s as the Zone format, but don't start with at the same
328
- # time as a rule is defined to fill in %s.
329
- zone_id = period.format.expand(std_offset, letter)
330
- if zone_id.empty?
331
- zone_id = 'Unknown'
332
- end
333
-
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
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)}"
340
- end
341
-
342
- private
343
- def datetime_constructor(datetime)
344
- if datetime.nil?
345
- 'nil'
346
- else
347
- "DateTime.new0(Rational.new!(#{datetime.ajd.numerator},#{datetime.ajd.denominator}),0,Date::ITALY)"
348
- end
349
- end
350
-
351
- def quote_str(str)
352
- "'#{str.gsub(/'/, '\\\'')}'"
353
- end
347
+ def count
348
+ 0
349
+ end
354
350
  end
355
351
 
356
352
  # Empty rule set with a fixed daylight savings (std) offset.
@@ -360,18 +356,7 @@ module TZInfo
360
356
  def initialize(offset)
361
357
  super(offset.to_s)
362
358
  @offset = offset
363
- end
364
-
365
- # Writes a single period to the file with the fixed offset. Returns the
366
- # end of the period in UTC and the offset.
367
- def write_class_periods(file, utc_start, period, last_utc_offset, std_offset)
368
- result = period.valid_until.nil? ? nil :
369
- period.valid_until.to_utc(period.utc_offset, @offset)
370
-
371
- write_period(file, utc_start, result, period, @offset, nil)
372
-
373
- [result, @offset]
374
- end
359
+ end
375
360
  end
376
361
 
377
362
  # An empty set of rules.
@@ -379,19 +364,6 @@ module TZInfo
379
364
  def initialize
380
365
  super('-')
381
366
  end
382
-
383
- # Writes a single period to the file with a zero daylight savings offset.
384
- def write_class_periods(file, utc_start, period, last_utc_offset, std_offset)
385
- # no rules to apply, just take the end of the period and convert to
386
- # utc according to the zone offset
387
-
388
- result = period.valid_until.nil? ? nil :
389
- period.valid_until.to_utc(period.utc_offset, TZDataOffset.zero)
390
-
391
- write_period(file, utc_start, result, period, TZDataOffset.zero, nil)
392
-
393
- [result, TZDataOffset.zero]
394
- end
395
367
  end
396
368
 
397
369
  # A rule set (as defined by Rule name in the tz data).
@@ -406,112 +378,16 @@ module TZInfo
406
378
  # Adds a new rule to the set.
407
379
  def add_rule(rule)
408
380
  @rules << rule
409
- end
381
+ end
410
382
 
411
- # Finds all the periods between utc_start and period.valid_until and writes
412
- # them to file. Returns the end of the period and the final std_offset.
413
- #
414
- # This is where almost all the time is currently spent running the import.
415
- def write_class_periods(file, utc_start, period, last_utc_offset, std_offset)
416
- # search the rule space between utc_start and period.valid_until
417
- # (both can be nil = unbounded)
418
- # For simplicity treat unbounded ends as fixed dates. This is not too bad
419
- # as there wasn't daylight savings before 1900 and the rules will change
420
- # in the future.
421
-
422
- # divide the time up into periods with the same std_offset
423
- # need to keep finding the earliest rule after utc_start and before period.valid_until
424
- #puts name
425
-
426
- utc_current = utc_start.nil? ? DateTime.new(1850, 1, 1, 0, 0, 0) : utc_start
427
-
428
- unbounded_end = period.valid_until.nil?
429
- if unbounded_end
430
- utc_end = DateTime.now + 14600
431
- else
432
- utc_end = period.valid_until.to_utc(period.utc_offset, std_offset)
433
- end
434
-
435
- #puts "utc_end: #{utc_end}"
436
-
437
- first = true
438
- letter = nil
439
-
440
- if last_utc_offset != period.utc_offset
441
- # change of offset
442
- # need to check if there is a wallclock time transition right at the start
443
- # of the period using the _last_ utc offset (see Asia/Qyzylorda Apr 1 1982)
444
-
445
- #puts "checking last_utc_offset #{last_utc_offset.inspect}"
446
-
447
- earliest = earliest_in_bounds(utc_current, utc_end, last_utc_offset, std_offset)
448
-
449
- if !earliest.nil? && earliest[1] == utc_current
450
- # found the transition
451
- # no period to write here, just update the std_offset
452
- rule = earliest[0]
453
- std_offset = rule.save
454
- letter = rule.letter
455
- first = false
456
- end
457
- end
458
-
459
- # Main loop. Repeatedly find earliest rule to apply.
460
- while utc_current < utc_end
461
- #puts "utc_current: #{utc_current}"
462
-
463
- earliest = earliest_in_bounds(utc_current, utc_end, period.utc_offset, std_offset)
464
-
465
- if earliest.nil?
466
- #puts 'found no earliest rule'
467
- write_period(file, utc_current, unbounded_end ? nil : utc_end, period, std_offset, letter)
468
-
469
- [utc_end, std_offset]
470
- break
471
- else
472
- write_period(file, utc_current, earliest[1], period, std_offset, letter) if !first || earliest[1] > utc_current
473
-
474
- raise 'Not moved forwards' if !first and earliest[1] <= utc_current
475
- first = false if first
476
-
477
- rule = earliest[0]
478
- utc_current = earliest[1]
479
- std_offset = rule.save
480
- letter = rule.letter
481
-
482
- if !unbounded_end
483
- utc_end = period.valid_until.to_utc(period.utc_offset, std_offset)
484
- end
485
- end
486
- end
487
-
488
- [utc_end, std_offset]
383
+ def count
384
+ @rules.length
489
385
  end
490
386
 
491
- # Finds the earliest rule that applies at of after utc_start and before
492
- # utc_end that has a different std_offset to the current std_offset.
493
- def earliest_in_bounds(utc_start, utc_end, utc_offset, std_offset)
494
- earliest_utc = nil
495
- earliest_rule = nil
496
- @rules.each {|rule|
497
- # only consider rules that change the offset
498
- if rule.save.to_seconds != std_offset.to_seconds
499
- test = rule.earliest_in_bounds(utc_start, utc_end, utc_offset, std_offset)
500
-
501
- if !test.nil? && (earliest_utc.nil? || test < earliest_utc)
502
- earliest_utc = test
503
- earliest_rule = rule
504
- end
505
- end
506
- }
507
-
508
- if earliest_rule.nil?
509
- nil
510
- else
511
- [earliest_rule, earliest_utc]
512
- end
387
+ def each
388
+ @rules.each {|rule| yield rule}
513
389
  end
514
- end
390
+ end
515
391
 
516
392
  # A rule in a RuleSet (a single Rule line in the tz data).
517
393
  class TZDataRule #:nodoc:
@@ -528,102 +404,31 @@ module TZInfo
528
404
  @from = parse_from(from)
529
405
  @to = parse_to(to)
530
406
 
531
- # get rid of to only
407
+ # replace a to of :only with the from year
532
408
  raise 'to cannot be only if from is minimum' if @to == :only && @from == :min
533
- @to = @from if @to == :only
409
+ @to = @from if @to == :only
534
410
 
535
411
  @type = parse_type(type)
536
412
  @in_month = TZDataParser.parse_month(in_month)
537
413
  @on_day = TZDataDayOfMonth.new(on_day)
538
414
  @at_time = TZDataTime.new(at_time)
539
- @save = TZDataOffset.new(save)
415
+ @save = TZDataParser.parse_offset(save)
540
416
  @letter = parse_letter(letter)
541
417
  end
542
418
 
543
- # Gets the earliest UTC time this rule can be applied that is greater than
544
- # or equal to utc_start and before utc_end.
545
- def earliest_in_bounds(utc_start, utc_end, utc_offset, std_offset)
546
- earliest = earliest_start_date(utc_start, utc_offset, std_offset)
547
- if !earliest.nil? && earliest < utc_end
548
- earliest
419
+ def activate(year)
420
+ # The following test ignores yearistype at present (currently unused in
421
+ # the data. parse_type currently excepts on encountering a year type.
422
+ if (@from == :min || @from <= year) && (@to == :max || @to >= year)
423
+ TZDataActivatedRule.new(self, year)
549
424
  else
550
425
  nil
551
426
  end
552
427
  end
553
428
 
554
- # Gets the earliest UTC time this rule can be applied that is greater than
555
- # or equal to utc_start.
556
- def earliest_start_date(utc_now, utc_offset, std_offset)
557
- #puts "testing rule #{@from}-#{@to}"
558
-
559
- # convert the utc definition to whatever reference this rule is in terms of
560
-
561
- if @at_time.ref == :standard
562
- rule_now = utc_now + Rational(utc_offset.to_seconds, 86400)
563
- #puts "converted utc to standard: #{rule_now}"
564
- elsif @at_time.ref == :wall_clock
565
- rule_now = utc_now + Rational(utc_offset.to_seconds + std_offset.to_seconds, 86400)
566
- #puts "converted utc to wall clock: #{rule_now}"
567
- else
568
- rule_now = utc_now
569
- end
570
-
571
- if @to == :max || @to >= rule_now.year
572
-
573
- next_year = false
574
-
575
- if @in_month > rule_now.mon
576
- #puts 'month greater'
577
- elsif @in_month < rule_now.mon
578
- #puts 'month less'
579
- next_year = true
580
- else
581
- # work out the complete time as this may move the day back/forward
582
- abs_day = @on_day.to_absolute(rule_now.year, @in_month)
583
- #puts "months equal #{abs_day}"
584
-
585
- if abs_day > rule_now.mday
586
- elsif abs_day < rule_now.mday
587
- next_year = true
588
- else
589
- if @at_time.hour > rule_now.hour
590
- elsif @at_time.hour < rule_now.hour
591
- else
592
- if @at_time.minute > rule_now.min
593
- elsif @at_time.minute < rule_now.min
594
- next_year = true
595
- else
596
- if @at_time.second >= rule_now.sec
597
- else
598
- next_year = true
599
- end
600
- end
601
- end
602
- end
603
- end
604
-
605
- if @from == :min
606
- year = rule_now.year
607
- else
608
- if @from > rule_now.year
609
- year = @from
610
- else
611
- year = rule_now.year
612
- end
613
- end
614
-
615
- if next_year && year == rule_now.year
616
- year = year + 1
617
- end
618
-
619
- if @to == :max || @to >= year
620
- @at_time.to_utc(utc_offset, std_offset, year, @in_month, @on_day.to_absolute(year, @in_month))
621
- else
622
- nil
623
- end
624
- else
625
- nil
626
- end
429
+ def at_utc_time(year, utc_offset, std_offset)
430
+ @at_time.to_utc(utc_offset, std_offset,
431
+ year, @in_month, @on_day.to_absolute(year, @in_month))
627
432
  end
628
433
 
629
434
  private
@@ -686,6 +491,7 @@ module TZInfo
686
491
  FileUtils.mkdir_p(dir)
687
492
 
688
493
  File.open(output_dir + File::SEPARATOR + 'definitions' + File::SEPARATOR + @name_for_class.gsub(/\//, File::SEPARATOR) + '.rb', 'w') {|file|
494
+ file.binmode
689
495
  write_requires(file)
690
496
  file.puts('module TZInfo')
691
497
  file.puts('module Definitions #:nodoc:')
@@ -696,12 +502,7 @@ module TZInfo
696
502
  file.puts("class #{class_name} < #{superclass} #:nodoc:")
697
503
 
698
504
  yield file
699
-
700
- #file.puts('@@instance = new')
701
- #file.puts('def self.instance')
702
- #file.puts(' @@instance')
703
- #file.puts('end')
704
-
505
+
705
506
  file.puts('end') # end class
706
507
 
707
508
  modules.each do
@@ -748,17 +549,17 @@ module TZInfo
748
549
  end
749
550
  end
750
551
 
751
- # A tz data Zone. Each line from the tz data is loaded as a TZDataPeriod.
552
+ # A tz data Zone. Each line from the tz data is loaded as a TZDataObservance.
752
553
  class TZDataZone < TZDataDefinition #:nodoc:
753
- attr_reader :periods
554
+ attr_reader :observances
754
555
 
755
556
  def initialize(name)
756
557
  super
757
- @periods = []
558
+ @observances = []
758
559
  end
759
560
 
760
- def add_period(period)
761
- @periods << period
561
+ def add_observance(observance)
562
+ @observances << observance
762
563
  end
763
564
 
764
565
  # Superclass is a Timezone. Called by create_file.
@@ -776,39 +577,307 @@ module TZInfo
776
577
  file.puts('setup')
777
578
  file.puts("set_identifier('#{@name.gsub(/'/, '\\\'')}')")
778
579
 
779
- utc_start = nil
780
- std_offset = TZDataOffset.zero
781
- last_utc_offset = nil
782
-
783
- @periods.each {|period|
784
- last_utc_offset = period.utc_offset if last_utc_offset.nil?
785
- result = period.write_class_periods(file, utc_start, last_utc_offset, std_offset)
786
- utc_start = result[0]
787
- std_offset = result[1]
788
- last_utc_offset = period.utc_offset
789
- }
580
+ transitions = find_transitions
581
+ transitions.output_class(file)
790
582
  }
791
583
  end
584
+
585
+ private
586
+ def find_transitions
587
+ transitions = TZDataTransitions.new
588
+
589
+ # algorithm from zic.c outzone
590
+
591
+ start_time = nil
592
+ until_time = nil
593
+
594
+
595
+ @observances.each_with_index {|observance, i|
596
+ std_offset = 0
597
+ use_start = i > 0
598
+ use_until = i < @observances.length - 1
599
+ utc_offset = observance.utc_offset
600
+ start_zone_id = nil
601
+ start_utc_offset = observance.utc_offset
602
+ start_std_offset = 0
603
+
604
+ if observance.rule_set.count == 0
605
+ std_offset = observance.std_offset
606
+ start_zone_id = observance.format.expand(std_offset, nil)
607
+
608
+ if use_start
609
+ transitions << TZDataTransition.new(start_time, utc_offset, std_offset, start_zone_id)
610
+ use_start = false
611
+ else
612
+ # zic algorithm only outputs this if std_offset is non-zero
613
+ # to get the initial LMT range, we output this regardless
614
+ transitions << TZDataTransition.new(nil, utc_offset, std_offset, start_zone_id)
615
+ end
616
+ else
617
+ (TZDataParser::MIN_YEAR..TZDataParser::MAX_YEAR).each {|year|
618
+ if use_until && year > observance.valid_until.year
619
+ break
620
+ end
621
+
622
+ activated_rules = []
623
+
624
+ observance.rule_set.each {|rule|
625
+ activated_rule = rule.activate(year)
626
+ activated_rules << activated_rule unless activated_rule.nil?
627
+ }
628
+
629
+ while true
630
+ # turn until_time into UTC using the current utc_offset and std_offset
631
+ until_time = observance.valid_until.to_utc(utc_offset, std_offset) if use_until
632
+
633
+ earliest = nil
634
+
635
+ activated_rules.each {|activated_rule|
636
+ # recalculate the time using the current std_offset
637
+ activated_rule.calculate_time(utc_offset, std_offset)
638
+ earliest = activated_rule if earliest.nil? || activated_rule.at < earliest.at
639
+ }
640
+
641
+ break if earliest.nil?
642
+ activated_rules.delete(earliest)
643
+ break if use_until && earliest.at >= until_time
644
+ std_offset = earliest.rule.save
645
+ use_start = false if use_start && earliest.at == start_time
646
+
647
+ if use_start
648
+ if earliest.at < start_time
649
+ start_utc_offset = observance.utc_offset
650
+ start_std_offset = std_offset
651
+ start_zone_id = observance.format.expand(earliest.rule.save, earliest.rule.letter)
652
+ next
653
+ end
654
+
655
+ if start_zone_id.nil? && start_utc_offset + start_std_offset == observance.utc_offset + std_offset
656
+ start_zone_id = observance.format.expand(earliest.rule.save, earliest.rule.letter)
657
+ end
658
+ end
659
+
660
+ zone_id = observance.format.expand(earliest.rule.save, earliest.rule.letter)
661
+ transitions << TZDataTransition.new(earliest.at, observance.utc_offset, earliest.rule.save, zone_id)
662
+ end
663
+ }
664
+ end
665
+
666
+ if use_start
667
+ start_zone_id = observance.format.expand(nil, nil) if start_zone_id.nil? && observance.format.fixed?
668
+ raise 'Could not determine time zone abbreviation to use just after until time' if start_zone_id.nil?
669
+ transitions << TZDataTransition.new(start_time, start_utc_offset, start_std_offset, start_zone_id)
670
+ end
671
+
672
+ start_time = observance.valid_until.to_utc(utc_offset, std_offset) if use_until
673
+ }
674
+
675
+ transitions
676
+ end
792
677
  end
793
678
 
794
- # A period within a zone.
795
- class TZDataPeriod #:nodoc:
679
+ # A observance within a zone (a line within the zone definition).
680
+ class TZDataObservance #:nodoc:
796
681
  attr_reader :utc_offset
797
682
  attr_reader :rule_set
798
683
  attr_reader :format
799
684
  attr_reader :valid_until
800
685
 
801
686
  def initialize(utc_offset, rule_set, format, valid_until)
802
- @utc_offset = TZDataOffset.new(utc_offset)
687
+ @utc_offset = TZDataParser.parse_offset(utc_offset)
803
688
  @rule_set = rule_set
804
689
  @format = TZDataFormat.new(format)
805
690
  @valid_until = valid_until.nil? ? nil : TZDataUntil.new(valid_until)
691
+ end
692
+
693
+ def std_offset
694
+ if @rule_set.kind_of?(TZDataFixedOffsetRules)
695
+ @rule_set.offset
696
+ else
697
+ 0
698
+ end
699
+ end
700
+ end
701
+
702
+ # Collection of TZDataTransition instances used when building a zone class.
703
+ class TZDataTransitions #:nodoc:
704
+
705
+ def initialize
706
+ @transitions = []
707
+ end
708
+
709
+ def << (transition)
710
+ @transitions << transition
711
+ end
712
+
713
+ def output_class(file)
714
+ optimize
715
+
716
+ # Try and end on a transition to std if one happens in the last year.
717
+ if @transitions.length > 1 &&
718
+ @transitions.last.std_offset != 0 &&
719
+ @transitions[@transitions.length - 2].std_offset == 0 &&
720
+ @transitions[@transitions.length - 2].at_utc.year == TZDataParser::MAX_YEAR
721
+
722
+ transitions = @transitions[0..@transitions.length - 2]
723
+ else
724
+ transitions = @transitions
725
+ end
726
+
727
+ previous = nil
728
+ transitions.each {|transition|
729
+ if previous.nil?
730
+ # first transition
731
+ # if it has a time, need to work out what the unbounded start before
732
+ # it should have been
733
+
734
+ if transition.std_offset == 0
735
+ # treat the start time as nil
736
+ previous = transition.clone_with_at(nil)
737
+ else
738
+ first_std = @transitions.find {|t| t.std_offset == 0}
739
+
740
+ if first_std.nil?
741
+ previous = transition.clone_with_at(nil)
742
+ else
743
+ first_std.clone_with_at(nil).write_period(file, transition.at_utc)
744
+ previous = transition
745
+ end
746
+ end
747
+ else
748
+ raise 'Only the first transition can have a nil start time' if transition.at_utc.nil?
749
+ previous.write_period(file, transition.at_utc)
750
+ previous = transition
751
+ end
752
+ }
753
+
754
+ previous.write_period(file, nil) unless previous.nil?
755
+ end
756
+
757
+ private
758
+ def optimize
759
+ @transitions.sort!
760
+
761
+ # Optimization logic from zic.c writezone.
762
+
763
+ from_i = 0
764
+ to_i = 0
765
+
766
+ while from_i < @transitions.length
767
+ if to_i > 1 &&
768
+ !@transitions[from_i].at_utc.nil? &&
769
+ !@transitions[to_i - 1].at_utc.nil? &&
770
+ @transitions[from_i].at_utc + Rational(@transitions[to_i - 1].total_offset, 86400) <=
771
+ @transitions[to_i - 1].at_utc + Rational(@transitions[to_i - 2].total_offset, 86400)
772
+
773
+ @transitions[to_i - 1] = @transitions[from_i].clone_with_at(@transitions[to_i - 1].at_utc)
774
+ from_i += 1
775
+ next
776
+ end
777
+
778
+ # Shuffle transitions up, eliminating any redundant transitions
779
+ # along the way.
780
+ if to_i == 0 ||
781
+ @transitions[to_i - 1].total_offset != @transitions[from_i].total_offset ||
782
+ @transitions[to_i - 1].zone_id != @transitions[from_i].zone_id
783
+
784
+ @transitions[to_i] = @transitions[from_i]
785
+ to_i += 1
786
+ end
787
+
788
+ from_i += 1
789
+ end
790
+
791
+ if to_i > 0
792
+ @transitions = @transitions[0..to_i - 1]
793
+ else
794
+ @transitions = []
795
+ end
796
+ end
797
+ end
798
+
799
+ # A transition that will be used to write the periods in a zone class.
800
+ class TZDataTransition #:nodoc:
801
+ include Comparable
802
+
803
+ attr_reader :at_utc
804
+ attr_reader :utc_offset
805
+ attr_reader :std_offset
806
+ attr_reader :zone_id
807
+
808
+ def initialize(at_utc, utc_offset, std_offset, zone_id)
809
+ @at_utc = at_utc
810
+ @utc_offset = utc_offset
811
+ @std_offset = std_offset
812
+ @zone_id = zone_id
813
+ end
814
+
815
+ def to_s
816
+ "At #{at_utc} UTC switch to UTC offset #{@utc_offset} with std offset #{@std_offset}, zone id #{@zone_id}"
817
+ end
818
+
819
+ def <=>(transition)
820
+ if @at_utc == transition.at_utc
821
+ 0
822
+ elsif @at_utc.nil?
823
+ -1
824
+ elsif transition.nil?
825
+ 1
826
+ else
827
+ @at_utc - transition.at_utc
828
+ end
829
+ end
830
+
831
+ def total_offset
832
+ @utc_offset + @std_offset
833
+ end
834
+
835
+ def clone_with_at(at_utc)
836
+ TZDataTransition.new(at_utc, @utc_offset, @std_offset, @zone_id)
837
+ end
838
+
839
+ def write_period(file, utc_end)
840
+ if @at_utc.nil?
841
+ file.puts "add_unbounded_start_period {TimezonePeriod.new(nil,#{datetime_constructor(utc_end)},#{@utc_offset},#{@std_offset},:#{quote_str(@zone_id)})}"
842
+ else
843
+ file.puts "add_period(#{@at_utc.year},#{@at_utc.mon}) {TimezonePeriod.new(#{datetime_constructor(@at_utc)},#{datetime_constructor(utc_end)},#{@utc_offset},#{@std_offset},:#{quote_str(@zone_id)})}"
844
+ end
845
+ end
846
+
847
+ private
848
+ def datetime_constructor(datetime)
849
+ if datetime.nil?
850
+ 'nil'
851
+ elsif (1970..2037).include?(datetime.year)
852
+ "#{Time.utc(datetime.year, datetime.mon, datetime.mday, datetime.hour, datetime.min, datetime.sec).to_i}"
853
+ else
854
+ "DateTime.new0(Rational.new!(#{datetime.ajd.numerator},#{datetime.ajd.denominator}),0,Date::ITALY)"
855
+ end
856
+ end
857
+
858
+ def quote_str(str)
859
+ if str =~ %r{[\-+']}
860
+ "'#{str.gsub(/'/, '\\\'')}'"
861
+ else
862
+ str
863
+ end
864
+ end
865
+ end
866
+
867
+ # An instance of a rule for a year.
868
+ class TZDataActivatedRule
869
+ attr_reader :rule
870
+ attr_reader :year
871
+ attr_reader :at
872
+
873
+ def initialize(rule, year)
874
+ @rule = rule
875
+ @year = year
876
+ @at = nil
806
877
  end
807
878
 
808
- # Writes the definition of this period to the file. Calls the rule_set to
809
- # do this.
810
- def write_class_periods(file, utc_start, last_utc_offset, std_offset)
811
- @rule_set.write_class_periods(file, utc_start, self, last_utc_offset, std_offset)
879
+ def calculate_time(utc_offset, std_offset)
880
+ @at = @rule.at_utc_time(@year, utc_offset, std_offset)
812
881
  end
813
882
  end
814
883
 
@@ -840,54 +909,12 @@ module TZInfo
840
909
  def to_utc(utc_offset, std_offset, year, month, day)
841
910
  result = DateTime.new(year, month, day, @hour, @minute, @second)
842
911
  offset = 0
843
- offset = offset + utc_offset.to_seconds if @ref == :standard || @ref == :wall_clock
844
- offset = offset + std_offset.to_seconds if @ref == :wall_clock
912
+ offset = offset + utc_offset if @ref == :standard || @ref == :wall_clock
913
+ offset = offset + std_offset if @ref == :wall_clock
845
914
  result - Rational(offset, 86400)
846
915
  end
847
916
  end
848
-
849
- # A tz data offset.
850
- class TZDataOffset #:nodoc:
851
- attr_reader :hour
852
- attr_reader :minute
853
- attr_reader :second
854
-
855
- def initialize(spec)
856
- raise "Invalid time: #{spec}" if spec !~ /^(-)?([0-9]+)(:([0-9]+)(:([0-9]+))?)?$/
857
-
858
- @negative = !$1.nil?
859
- @hour = $2.to_i
860
- @minute = $4.nil? ? 0 : $4.to_i
861
- @second = $6.nil? ? 0 : $6.to_i
862
- end
863
-
864
- @@zero = TZDataOffset.new('0')
865
-
866
- # A TZDataOffset representing 0.
867
- def self.zero
868
- @@zero
869
- end
870
-
871
- def negative?
872
- @negative
873
- end
874
-
875
- def to_s
876
- "#{@negative ? '-' : ''}#{@hour}:#{@minute}:#{@second}"
877
- end
878
917
 
879
- # Converts the offset to seconds.
880
- def to_seconds
881
- result = @hour
882
- result = result * 60
883
- result = result + @minute
884
- result = result * 60
885
- result = result + @second
886
- result = -result if @negative
887
- result
888
- end
889
- end
890
-
891
918
  # A tz data day of the month reference. Can either be an absolute day,
892
919
  # a last week day or a week day >= or <= than a specific day of month.
893
920
  class TZDataDayOfMonth #:nodoc:
@@ -928,6 +955,11 @@ module TZInfo
928
955
  offset = offset + 7 if offset < 0
929
956
  offset = -offset if @operator == :less_equal
930
957
  result = pivot + offset
958
+ if result.month != pivot.month
959
+ puts self.inspect
960
+ puts year
961
+ puts month
962
+ end
931
963
  raise 'No suitable date found' if result.month != pivot.month
932
964
  result.day
933
965
  else #absolute
@@ -970,6 +1002,11 @@ module TZInfo
970
1002
 
971
1003
  # A tz data Zone until reference.
972
1004
  class TZDataUntil #:nodoc:
1005
+ attr_reader :year
1006
+ attr_reader :month
1007
+ attr_reader :day
1008
+ attr_reader :time
1009
+
973
1010
  def initialize(spec)
974
1011
  parts = spec.split(/\s+/)
975
1012
  raise "Invalid until: #{spec}" if parts.length < 1
@@ -986,32 +1023,47 @@ module TZInfo
986
1023
  end
987
1024
  end
988
1025
 
989
- # A tz data Zone format string. Either alternate standard/daylight-savings
990
- # or substitution (%s) format.
1026
+ # A tz data Zone format string. Either alternate standard/daylight-savings,
1027
+ # substitution (%s) format or a fixed string.
991
1028
  class TZDataFormat #:nodoc:
992
1029
  def initialize(spec)
993
1030
  if spec =~ /([A-z]+)\/([A-z]+)/
994
1031
  @type = :alternate
995
1032
  @standard_abbrev = $1
996
1033
  @daylight_abbrev = $2
997
- else
1034
+ elsif spec =~ /%s/
998
1035
  @type = :subst
999
1036
  @abbrev = spec
1037
+ else
1038
+ @type = :fixed
1039
+ @abbrev = spec
1000
1040
  end
1001
1041
  end
1002
1042
 
1003
1043
  # Expands given the current daylight savings offset and Rule string.
1004
1044
  def expand(std_offset, rule_string)
1005
1045
  if @type == :alternate
1006
- if std_offset.to_seconds == 0
1046
+ if std_offset == 0
1007
1047
  @standard_abbrev
1008
1048
  else
1009
1049
  @daylight_abbrev
1010
1050
  end
1011
- else
1051
+ elsif @type == :subst
1012
1052
  sprintf(@abbrev, rule_string)
1053
+ else
1054
+ @abbrev
1013
1055
  end
1014
1056
  end
1057
+
1058
+ # True if a string from the rule is required to expand this format.
1059
+ def requires_rule_string?
1060
+ @type == :subst
1061
+ end
1062
+
1063
+ # Is a fixed format string.
1064
+ def fixed?
1065
+ @type == :fixed
1066
+ end
1015
1067
  end
1016
1068
 
1017
1069
  # An ISO 3166 country.
@@ -1034,7 +1086,8 @@ module TZInfo
1034
1086
  dir = output_dir + File::SEPARATOR + 'countries'
1035
1087
  FileUtils.mkdir_p(dir)
1036
1088
 
1037
- File.open(dir + File::SEPARATOR + @code + '.rb', 'w') {|file|
1089
+ File.open(dir + File::SEPARATOR + @code + '.rb', 'w') {|file|
1090
+ file.binmode
1038
1091
  file.puts('require \'tzinfo/country\'')
1039
1092
  file.puts('module TZInfo #:nodoc:')
1040
1093
  file.puts('module Countries #:nodoc:')