activesupport 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (163) hide show
  1. data/CHANGELOG +13 -1
  2. data/lib/active_support.rb +6 -0
  3. data/lib/active_support/cache.rb +3 -1
  4. data/lib/active_support/cache/compressed_mem_cache_store.rb +4 -4
  5. data/lib/active_support/core_ext/date/behavior.rb +26 -0
  6. data/lib/active_support/core_ext/date/calculations.rb +1 -1
  7. data/lib/active_support/core_ext/hash/except.rb +4 -3
  8. data/lib/active_support/core_ext/hash/slice.rb +3 -1
  9. data/lib/active_support/core_ext/module.rb +5 -0
  10. data/lib/active_support/core_ext/module/model_naming.rb +22 -0
  11. data/lib/active_support/core_ext/object/extending.rb +9 -8
  12. data/lib/active_support/core_ext/range/blockless_step.rb +2 -2
  13. data/lib/active_support/core_ext/rexml.rb +35 -0
  14. data/lib/active_support/core_ext/string/unicode.rb +11 -13
  15. data/lib/active_support/core_ext/time.rb +22 -1
  16. data/lib/active_support/dependencies.rb +393 -392
  17. data/lib/active_support/deprecation.rb +27 -9
  18. data/lib/active_support/inflections.rb +51 -49
  19. data/lib/active_support/inflector.rb +267 -262
  20. data/lib/active_support/json/encoders/date_time.rb +1 -1
  21. data/lib/active_support/ordered_options.rb +14 -12
  22. data/lib/active_support/string_inquirer.rb +11 -0
  23. data/lib/active_support/time_with_zone.rb +34 -13
  24. data/lib/active_support/values/time_zone.rb +348 -346
  25. data/lib/active_support/vendor.rb +2 -2
  26. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo.rb +0 -0
  27. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/data_timezone.rb +0 -0
  28. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/data_timezone_info.rb +2 -0
  29. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Africa/Algiers.rb +0 -0
  30. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Africa/Cairo.rb +0 -0
  31. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Africa/Casablanca.rb +2 -0
  32. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Africa/Harare.rb +0 -0
  33. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Africa/Johannesburg.rb +0 -0
  34. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Africa/Monrovia.rb +0 -0
  35. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Africa/Nairobi.rb +0 -0
  36. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -0
  37. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -0
  38. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Bogota.rb +0 -0
  39. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Caracas.rb +0 -0
  40. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Chicago.rb +0 -0
  41. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Chihuahua.rb +0 -0
  42. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Denver.rb +0 -0
  43. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Godthab.rb +0 -0
  44. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Guatemala.rb +0 -0
  45. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Halifax.rb +0 -0
  46. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -0
  47. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Juneau.rb +0 -0
  48. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/La_Paz.rb +0 -0
  49. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Lima.rb +0 -0
  50. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Los_Angeles.rb +0 -0
  51. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Mazatlan.rb +0 -0
  52. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Mexico_City.rb +0 -0
  53. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Monterrey.rb +0 -0
  54. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/New_York.rb +0 -0
  55. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Phoenix.rb +0 -0
  56. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Regina.rb +0 -0
  57. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Santiago.rb +0 -0
  58. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/St_Johns.rb +0 -0
  59. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/America/Tijuana.rb +0 -0
  60. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Almaty.rb +0 -0
  61. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Baghdad.rb +0 -0
  62. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Baku.rb +0 -0
  63. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Bangkok.rb +0 -0
  64. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Chongqing.rb +0 -0
  65. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Dhaka.rb +0 -0
  66. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Hong_Kong.rb +0 -0
  67. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Irkutsk.rb +0 -0
  68. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Jakarta.rb +0 -0
  69. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Jerusalem.rb +0 -0
  70. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Kabul.rb +0 -0
  71. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Kamchatka.rb +0 -0
  72. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Karachi.rb +2 -0
  73. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Katmandu.rb +0 -0
  74. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Kolkata.rb +0 -0
  75. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -0
  76. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -0
  77. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Kuwait.rb +0 -0
  78. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Magadan.rb +0 -0
  79. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Muscat.rb +0 -0
  80. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Novosibirsk.rb +0 -0
  81. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Rangoon.rb +0 -0
  82. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Riyadh.rb +0 -0
  83. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Seoul.rb +0 -0
  84. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Shanghai.rb +0 -0
  85. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Singapore.rb +0 -0
  86. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Taipei.rb +0 -0
  87. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Tashkent.rb +0 -0
  88. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Tbilisi.rb +0 -0
  89. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Tehran.rb +0 -0
  90. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Tokyo.rb +0 -0
  91. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -0
  92. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Urumqi.rb +0 -0
  93. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Vladivostok.rb +0 -0
  94. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Yakutsk.rb +0 -0
  95. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -0
  96. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Asia/Yerevan.rb +0 -0
  97. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Atlantic/Azores.rb +0 -0
  98. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -0
  99. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -0
  100. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Australia/Adelaide.rb +0 -0
  101. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Australia/Brisbane.rb +0 -0
  102. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Australia/Darwin.rb +0 -0
  103. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Australia/Hobart.rb +0 -0
  104. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Australia/Melbourne.rb +0 -0
  105. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Australia/Perth.rb +0 -0
  106. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Australia/Sydney.rb +0 -0
  107. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Etc/UTC.rb +0 -0
  108. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Amsterdam.rb +0 -0
  109. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Athens.rb +0 -0
  110. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Belgrade.rb +0 -0
  111. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Berlin.rb +0 -0
  112. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Bratislava.rb +0 -0
  113. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Brussels.rb +0 -0
  114. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Bucharest.rb +0 -0
  115. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Budapest.rb +0 -0
  116. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Copenhagen.rb +0 -0
  117. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Dublin.rb +0 -0
  118. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Helsinki.rb +0 -0
  119. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Istanbul.rb +0 -0
  120. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Kiev.rb +0 -0
  121. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Lisbon.rb +0 -0
  122. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Ljubljana.rb +0 -0
  123. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/London.rb +0 -0
  124. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Madrid.rb +0 -0
  125. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Minsk.rb +0 -0
  126. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Moscow.rb +0 -0
  127. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Paris.rb +0 -0
  128. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Prague.rb +0 -0
  129. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Riga.rb +0 -0
  130. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Rome.rb +0 -0
  131. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Sarajevo.rb +0 -0
  132. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Skopje.rb +0 -0
  133. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Sofia.rb +0 -0
  134. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Stockholm.rb +0 -0
  135. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Tallinn.rb +0 -0
  136. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Vienna.rb +0 -0
  137. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Vilnius.rb +0 -0
  138. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Warsaw.rb +0 -0
  139. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Europe/Zagreb.rb +0 -0
  140. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Auckland.rb +0 -0
  141. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Fiji.rb +0 -0
  142. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Guam.rb +0 -0
  143. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Honolulu.rb +0 -0
  144. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Majuro.rb +0 -0
  145. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Midway.rb +0 -0
  146. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Noumea.rb +0 -0
  147. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -0
  148. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -0
  149. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/definitions/Pacific/Tongatapu.rb +0 -0
  150. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/info_timezone.rb +0 -0
  151. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/linked_timezone.rb +0 -0
  152. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/linked_timezone_info.rb +0 -0
  153. data/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/offset_rationals.rb +95 -0
  154. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/time_or_datetime.rb +0 -0
  155. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/timezone.rb +6 -6
  156. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/timezone_definition.rb +0 -0
  157. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/timezone_info.rb +0 -0
  158. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/timezone_offset_info.rb +4 -4
  159. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/timezone_period.rb +0 -0
  160. data/lib/active_support/vendor/{tzinfo-0.3.8 → tzinfo-0.3.9}/tzinfo/timezone_transition_info.rb +2 -2
  161. data/lib/active_support/version.rb +1 -1
  162. metadata +154 -151
  163. data/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/offset_rationals.rb +0 -95
@@ -8,7 +8,7 @@ class DateTime
8
8
  if ActiveSupport.use_standard_json_time_format
9
9
  xmlschema.inspect
10
10
  else
11
- %("#{strftime("%Y/%m/%d %H:%M:%S %z")}")
11
+ strftime('"%Y/%m/%d %H:%M:%S %z"')
12
12
  end
13
13
  end
14
14
  end
@@ -1,17 +1,19 @@
1
- class OrderedOptions < ActiveSupport::OrderedHash #:nodoc:
2
- def []=(key, value)
3
- super(key.to_sym, value)
4
- end
1
+ module ActiveSupport #:nodoc:
2
+ class OrderedOptions < OrderedHash #:nodoc:
3
+ def []=(key, value)
4
+ super(key.to_sym, value)
5
+ end
5
6
 
6
- def [](key)
7
- super(key.to_sym)
8
- end
7
+ def [](key)
8
+ super(key.to_sym)
9
+ end
9
10
 
10
- def method_missing(name, *args)
11
- if name.to_s =~ /(.*)=$/
12
- self[$1.to_sym] = args.first
13
- else
14
- self[name]
11
+ def method_missing(name, *args)
12
+ if name.to_s =~ /(.*)=$/
13
+ self[$1.to_sym] = args.first
14
+ else
15
+ self[name]
16
+ end
15
17
  end
16
18
  end
17
19
  end
@@ -0,0 +1,11 @@
1
+ module ActiveSupport
2
+ class StringInquirer < String
3
+ def method_missing(method_name, *arguments)
4
+ if method_name.to_s.ends_with?("?")
5
+ self == method_name.to_s[0..-2]
6
+ else
7
+ super
8
+ end
9
+ end
10
+ end
11
+ end
@@ -159,19 +159,24 @@ module ActiveSupport
159
159
  utc == other
160
160
  end
161
161
 
162
- # If wrapped +time+ is a DateTime, use DateTime#since instead of <tt>+</tt>.
163
- # Otherwise, just pass on to +method_missing+.
164
162
  def +(other)
165
- result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other)
166
- result.in_time_zone(time_zone)
163
+ # If we're adding a Duration of variable length (i.e., years, months, days), move forward from #time,
164
+ # otherwise move forward from #utc, for accuracy when moving across DST boundaries
165
+ if duration_of_variable_length?(other)
166
+ method_missing(:+, other)
167
+ else
168
+ result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other)
169
+ result.in_time_zone(time_zone)
170
+ end
167
171
  end
168
-
169
- # If a time-like object is passed in, compare it with +utc+.
170
- # Else if wrapped +time+ is a DateTime, use DateTime#ago instead of DateTime#-.
171
- # Otherwise, just pass on to +method_missing+.
172
+
172
173
  def -(other)
174
+ # If we're subtracting a Duration of variable length (i.e., years, months, days), move backwards from #time,
175
+ # otherwise move backwards #utc, for accuracy when moving across DST boundaries
173
176
  if other.acts_like?(:time)
174
177
  utc - other
178
+ elsif duration_of_variable_length?(other)
179
+ method_missing(:-, other)
175
180
  else
176
181
  result = utc.acts_like?(:date) ? utc.ago(other) : utc - other rescue utc.ago(other)
177
182
  result.in_time_zone(time_zone)
@@ -179,15 +184,27 @@ module ActiveSupport
179
184
  end
180
185
 
181
186
  def since(other)
182
- utc.since(other).in_time_zone(time_zone)
187
+ # If we're adding a Duration of variable length (i.e., years, months, days), move forward from #time,
188
+ # otherwise move forward from #utc, for accuracy when moving across DST boundaries
189
+ if duration_of_variable_length?(other)
190
+ method_missing(:since, other)
191
+ else
192
+ utc.since(other).in_time_zone(time_zone)
193
+ end
183
194
  end
184
195
 
185
196
  def ago(other)
186
- utc.ago(other).in_time_zone(time_zone)
197
+ since(-other)
187
198
  end
188
-
199
+
189
200
  def advance(options)
190
- utc.advance(options).in_time_zone(time_zone)
201
+ # If we're advancing a value of variable length (i.e., years, weeks, months, days), advance from #time,
202
+ # otherwise advance from #utc, for accuracy when moving across DST boundaries
203
+ if options.detect {|k,v| [:years, :weeks, :months, :days].include? k}
204
+ method_missing(:advance, options)
205
+ else
206
+ utc.advance(options).in_time_zone(time_zone)
207
+ end
191
208
  end
192
209
 
193
210
  %w(year mon month day mday hour min sec).each do |method_name|
@@ -246,7 +263,7 @@ module ActiveSupport
246
263
  end
247
264
 
248
265
  def marshal_load(variables)
249
- initialize(variables[0], ::Time.send!(:get_zone, variables[1]), variables[2])
266
+ initialize(variables[0].utc, ::Time.send!(:get_zone, variables[1]), variables[2].utc)
250
267
  end
251
268
 
252
269
  # Ensure proxy class responds to all methods that underlying time instance responds to.
@@ -279,5 +296,9 @@ module ActiveSupport
279
296
  def transfer_time_values_to_utc_constructor(time)
280
297
  ::Time.utc_time(time.year, time.month, time.day, time.hour, time.min, time.sec, time.respond_to?(:usec) ? time.usec : 0)
281
298
  end
299
+
300
+ def duration_of_variable_length?(obj)
301
+ ActiveSupport::Duration === obj && obj.parts.flatten.detect {|p| [:years, :months, :days].include? p }
302
+ end
282
303
  end
283
304
  end
@@ -4,7 +4,7 @@
4
4
  # * Retrieve and display zones with a friendlier name (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").
5
5
  # * Lazily load TZInfo::Timezone instances only when they're needed.
6
6
  # * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+, +parse+, +at+ and +now+ methods.
7
- #
7
+ #
8
8
  # If you set <tt>config.time_zone</tt> in the Rails Initializer, you can access this TimeZone object via <tt>Time.zone</tt>:
9
9
  #
10
10
  # # environment.rb:
@@ -16,379 +16,381 @@
16
16
  # Time.zone.name # => "Eastern Time (US & Canada)"
17
17
  # Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00
18
18
  #
19
- # The version of TZInfo bundled with Active Support only includes the definitions necessary to support the zones
19
+ # The version of TZInfo bundled with Active Support only includes the definitions necessary to support the zones
20
20
  # defined by the TimeZone class. If you need to use zones that aren't defined by TimeZone, you'll need to install the TZInfo gem
21
21
  # (if a recent version of the gem is installed locally, this will be used instead of the bundled version.)
22
- class TimeZone
23
- unless const_defined?(:MAPPING)
24
- # Keys are Rails TimeZone names, values are TZInfo identifiers
25
- MAPPING = {
26
- "International Date Line West" => "Pacific/Midway",
27
- "Midway Island" => "Pacific/Midway",
28
- "Samoa" => "Pacific/Pago_Pago",
29
- "Hawaii" => "Pacific/Honolulu",
30
- "Alaska" => "America/Juneau",
31
- "Pacific Time (US & Canada)" => "America/Los_Angeles",
32
- "Tijuana" => "America/Tijuana",
33
- "Mountain Time (US & Canada)" => "America/Denver",
34
- "Arizona" => "America/Phoenix",
35
- "Chihuahua" => "America/Chihuahua",
36
- "Mazatlan" => "America/Mazatlan",
37
- "Central Time (US & Canada)" => "America/Chicago",
38
- "Saskatchewan" => "America/Regina",
39
- "Guadalajara" => "America/Mexico_City",
40
- "Mexico City" => "America/Mexico_City",
41
- "Monterrey" => "America/Monterrey",
42
- "Central America" => "America/Guatemala",
43
- "Eastern Time (US & Canada)" => "America/New_York",
44
- "Indiana (East)" => "America/Indiana/Indianapolis",
45
- "Bogota" => "America/Bogota",
46
- "Lima" => "America/Lima",
47
- "Quito" => "America/Lima",
48
- "Atlantic Time (Canada)" => "America/Halifax",
49
- "Caracas" => "America/Caracas",
50
- "La Paz" => "America/La_Paz",
51
- "Santiago" => "America/Santiago",
52
- "Newfoundland" => "America/St_Johns",
53
- "Brasilia" => "America/Argentina/Buenos_Aires",
54
- "Buenos Aires" => "America/Argentina/Buenos_Aires",
55
- "Georgetown" => "America/Argentina/San_Juan",
56
- "Greenland" => "America/Godthab",
57
- "Mid-Atlantic" => "Atlantic/South_Georgia",
58
- "Azores" => "Atlantic/Azores",
59
- "Cape Verde Is." => "Atlantic/Cape_Verde",
60
- "Dublin" => "Europe/Dublin",
61
- "Edinburgh" => "Europe/Dublin",
62
- "Lisbon" => "Europe/Lisbon",
63
- "London" => "Europe/London",
64
- "Casablanca" => "Africa/Casablanca",
65
- "Monrovia" => "Africa/Monrovia",
66
- "UTC" => "Etc/UTC",
67
- "Belgrade" => "Europe/Belgrade",
68
- "Bratislava" => "Europe/Bratislava",
69
- "Budapest" => "Europe/Budapest",
70
- "Ljubljana" => "Europe/Ljubljana",
71
- "Prague" => "Europe/Prague",
72
- "Sarajevo" => "Europe/Sarajevo",
73
- "Skopje" => "Europe/Skopje",
74
- "Warsaw" => "Europe/Warsaw",
75
- "Zagreb" => "Europe/Zagreb",
76
- "Brussels" => "Europe/Brussels",
77
- "Copenhagen" => "Europe/Copenhagen",
78
- "Madrid" => "Europe/Madrid",
79
- "Paris" => "Europe/Paris",
80
- "Amsterdam" => "Europe/Amsterdam",
81
- "Berlin" => "Europe/Berlin",
82
- "Bern" => "Europe/Berlin",
83
- "Rome" => "Europe/Rome",
84
- "Stockholm" => "Europe/Stockholm",
85
- "Vienna" => "Europe/Vienna",
86
- "West Central Africa" => "Africa/Algiers",
87
- "Bucharest" => "Europe/Bucharest",
88
- "Cairo" => "Africa/Cairo",
89
- "Helsinki" => "Europe/Helsinki",
90
- "Kyev" => "Europe/Kiev",
91
- "Riga" => "Europe/Riga",
92
- "Sofia" => "Europe/Sofia",
93
- "Tallinn" => "Europe/Tallinn",
94
- "Vilnius" => "Europe/Vilnius",
95
- "Athens" => "Europe/Athens",
96
- "Istanbul" => "Europe/Istanbul",
97
- "Minsk" => "Europe/Minsk",
98
- "Jerusalem" => "Asia/Jerusalem",
99
- "Harare" => "Africa/Harare",
100
- "Pretoria" => "Africa/Johannesburg",
101
- "Moscow" => "Europe/Moscow",
102
- "St. Petersburg" => "Europe/Moscow",
103
- "Volgograd" => "Europe/Moscow",
104
- "Kuwait" => "Asia/Kuwait",
105
- "Riyadh" => "Asia/Riyadh",
106
- "Nairobi" => "Africa/Nairobi",
107
- "Baghdad" => "Asia/Baghdad",
108
- "Tehran" => "Asia/Tehran",
109
- "Abu Dhabi" => "Asia/Muscat",
110
- "Muscat" => "Asia/Muscat",
111
- "Baku" => "Asia/Baku",
112
- "Tbilisi" => "Asia/Tbilisi",
113
- "Yerevan" => "Asia/Yerevan",
114
- "Kabul" => "Asia/Kabul",
115
- "Ekaterinburg" => "Asia/Yekaterinburg",
116
- "Islamabad" => "Asia/Karachi",
117
- "Karachi" => "Asia/Karachi",
118
- "Tashkent" => "Asia/Tashkent",
119
- "Chennai" => "Asia/Kolkata",
120
- "Kolkata" => "Asia/Kolkata",
121
- "Mumbai" => "Asia/Kolkata",
122
- "New Delhi" => "Asia/Kolkata",
123
- "Kathmandu" => "Asia/Katmandu",
124
- "Astana" => "Asia/Dhaka",
125
- "Dhaka" => "Asia/Dhaka",
126
- "Sri Jayawardenepura" => "Asia/Dhaka",
127
- "Almaty" => "Asia/Almaty",
128
- "Novosibirsk" => "Asia/Novosibirsk",
129
- "Rangoon" => "Asia/Rangoon",
130
- "Bangkok" => "Asia/Bangkok",
131
- "Hanoi" => "Asia/Bangkok",
132
- "Jakarta" => "Asia/Jakarta",
133
- "Krasnoyarsk" => "Asia/Krasnoyarsk",
134
- "Beijing" => "Asia/Shanghai",
135
- "Chongqing" => "Asia/Chongqing",
136
- "Hong Kong" => "Asia/Hong_Kong",
137
- "Urumqi" => "Asia/Urumqi",
138
- "Kuala Lumpur" => "Asia/Kuala_Lumpur",
139
- "Singapore" => "Asia/Singapore",
140
- "Taipei" => "Asia/Taipei",
141
- "Perth" => "Australia/Perth",
142
- "Irkutsk" => "Asia/Irkutsk",
143
- "Ulaan Bataar" => "Asia/Ulaanbaatar",
144
- "Seoul" => "Asia/Seoul",
145
- "Osaka" => "Asia/Tokyo",
146
- "Sapporo" => "Asia/Tokyo",
147
- "Tokyo" => "Asia/Tokyo",
148
- "Yakutsk" => "Asia/Yakutsk",
149
- "Darwin" => "Australia/Darwin",
150
- "Adelaide" => "Australia/Adelaide",
151
- "Canberra" => "Australia/Melbourne",
152
- "Melbourne" => "Australia/Melbourne",
153
- "Sydney" => "Australia/Sydney",
154
- "Brisbane" => "Australia/Brisbane",
155
- "Hobart" => "Australia/Hobart",
156
- "Vladivostok" => "Asia/Vladivostok",
157
- "Guam" => "Pacific/Guam",
158
- "Port Moresby" => "Pacific/Port_Moresby",
159
- "Magadan" => "Asia/Magadan",
160
- "Solomon Is." => "Asia/Magadan",
161
- "New Caledonia" => "Pacific/Noumea",
162
- "Fiji" => "Pacific/Fiji",
163
- "Kamchatka" => "Asia/Kamchatka",
164
- "Marshall Is." => "Pacific/Majuro",
165
- "Auckland" => "Pacific/Auckland",
166
- "Wellington" => "Pacific/Auckland",
167
- "Nuku'alofa" => "Pacific/Tongatapu"
168
- }.each { |name, zone| name.freeze; zone.freeze }
169
- MAPPING.freeze
170
- end
171
-
172
- include Comparable
173
- attr_reader :name
22
+ module ActiveSupport
23
+ class TimeZone
24
+ unless const_defined?(:MAPPING)
25
+ # Keys are Rails TimeZone names, values are TZInfo identifiers
26
+ MAPPING = {
27
+ "International Date Line West" => "Pacific/Midway",
28
+ "Midway Island" => "Pacific/Midway",
29
+ "Samoa" => "Pacific/Pago_Pago",
30
+ "Hawaii" => "Pacific/Honolulu",
31
+ "Alaska" => "America/Juneau",
32
+ "Pacific Time (US & Canada)" => "America/Los_Angeles",
33
+ "Tijuana" => "America/Tijuana",
34
+ "Mountain Time (US & Canada)" => "America/Denver",
35
+ "Arizona" => "America/Phoenix",
36
+ "Chihuahua" => "America/Chihuahua",
37
+ "Mazatlan" => "America/Mazatlan",
38
+ "Central Time (US & Canada)" => "America/Chicago",
39
+ "Saskatchewan" => "America/Regina",
40
+ "Guadalajara" => "America/Mexico_City",
41
+ "Mexico City" => "America/Mexico_City",
42
+ "Monterrey" => "America/Monterrey",
43
+ "Central America" => "America/Guatemala",
44
+ "Eastern Time (US & Canada)" => "America/New_York",
45
+ "Indiana (East)" => "America/Indiana/Indianapolis",
46
+ "Bogota" => "America/Bogota",
47
+ "Lima" => "America/Lima",
48
+ "Quito" => "America/Lima",
49
+ "Atlantic Time (Canada)" => "America/Halifax",
50
+ "Caracas" => "America/Caracas",
51
+ "La Paz" => "America/La_Paz",
52
+ "Santiago" => "America/Santiago",
53
+ "Newfoundland" => "America/St_Johns",
54
+ "Brasilia" => "America/Argentina/Buenos_Aires",
55
+ "Buenos Aires" => "America/Argentina/Buenos_Aires",
56
+ "Georgetown" => "America/Argentina/San_Juan",
57
+ "Greenland" => "America/Godthab",
58
+ "Mid-Atlantic" => "Atlantic/South_Georgia",
59
+ "Azores" => "Atlantic/Azores",
60
+ "Cape Verde Is." => "Atlantic/Cape_Verde",
61
+ "Dublin" => "Europe/Dublin",
62
+ "Edinburgh" => "Europe/Dublin",
63
+ "Lisbon" => "Europe/Lisbon",
64
+ "London" => "Europe/London",
65
+ "Casablanca" => "Africa/Casablanca",
66
+ "Monrovia" => "Africa/Monrovia",
67
+ "UTC" => "Etc/UTC",
68
+ "Belgrade" => "Europe/Belgrade",
69
+ "Bratislava" => "Europe/Bratislava",
70
+ "Budapest" => "Europe/Budapest",
71
+ "Ljubljana" => "Europe/Ljubljana",
72
+ "Prague" => "Europe/Prague",
73
+ "Sarajevo" => "Europe/Sarajevo",
74
+ "Skopje" => "Europe/Skopje",
75
+ "Warsaw" => "Europe/Warsaw",
76
+ "Zagreb" => "Europe/Zagreb",
77
+ "Brussels" => "Europe/Brussels",
78
+ "Copenhagen" => "Europe/Copenhagen",
79
+ "Madrid" => "Europe/Madrid",
80
+ "Paris" => "Europe/Paris",
81
+ "Amsterdam" => "Europe/Amsterdam",
82
+ "Berlin" => "Europe/Berlin",
83
+ "Bern" => "Europe/Berlin",
84
+ "Rome" => "Europe/Rome",
85
+ "Stockholm" => "Europe/Stockholm",
86
+ "Vienna" => "Europe/Vienna",
87
+ "West Central Africa" => "Africa/Algiers",
88
+ "Bucharest" => "Europe/Bucharest",
89
+ "Cairo" => "Africa/Cairo",
90
+ "Helsinki" => "Europe/Helsinki",
91
+ "Kyev" => "Europe/Kiev",
92
+ "Riga" => "Europe/Riga",
93
+ "Sofia" => "Europe/Sofia",
94
+ "Tallinn" => "Europe/Tallinn",
95
+ "Vilnius" => "Europe/Vilnius",
96
+ "Athens" => "Europe/Athens",
97
+ "Istanbul" => "Europe/Istanbul",
98
+ "Minsk" => "Europe/Minsk",
99
+ "Jerusalem" => "Asia/Jerusalem",
100
+ "Harare" => "Africa/Harare",
101
+ "Pretoria" => "Africa/Johannesburg",
102
+ "Moscow" => "Europe/Moscow",
103
+ "St. Petersburg" => "Europe/Moscow",
104
+ "Volgograd" => "Europe/Moscow",
105
+ "Kuwait" => "Asia/Kuwait",
106
+ "Riyadh" => "Asia/Riyadh",
107
+ "Nairobi" => "Africa/Nairobi",
108
+ "Baghdad" => "Asia/Baghdad",
109
+ "Tehran" => "Asia/Tehran",
110
+ "Abu Dhabi" => "Asia/Muscat",
111
+ "Muscat" => "Asia/Muscat",
112
+ "Baku" => "Asia/Baku",
113
+ "Tbilisi" => "Asia/Tbilisi",
114
+ "Yerevan" => "Asia/Yerevan",
115
+ "Kabul" => "Asia/Kabul",
116
+ "Ekaterinburg" => "Asia/Yekaterinburg",
117
+ "Islamabad" => "Asia/Karachi",
118
+ "Karachi" => "Asia/Karachi",
119
+ "Tashkent" => "Asia/Tashkent",
120
+ "Chennai" => "Asia/Kolkata",
121
+ "Kolkata" => "Asia/Kolkata",
122
+ "Mumbai" => "Asia/Kolkata",
123
+ "New Delhi" => "Asia/Kolkata",
124
+ "Kathmandu" => "Asia/Katmandu",
125
+ "Astana" => "Asia/Dhaka",
126
+ "Dhaka" => "Asia/Dhaka",
127
+ "Sri Jayawardenepura" => "Asia/Dhaka",
128
+ "Almaty" => "Asia/Almaty",
129
+ "Novosibirsk" => "Asia/Novosibirsk",
130
+ "Rangoon" => "Asia/Rangoon",
131
+ "Bangkok" => "Asia/Bangkok",
132
+ "Hanoi" => "Asia/Bangkok",
133
+ "Jakarta" => "Asia/Jakarta",
134
+ "Krasnoyarsk" => "Asia/Krasnoyarsk",
135
+ "Beijing" => "Asia/Shanghai",
136
+ "Chongqing" => "Asia/Chongqing",
137
+ "Hong Kong" => "Asia/Hong_Kong",
138
+ "Urumqi" => "Asia/Urumqi",
139
+ "Kuala Lumpur" => "Asia/Kuala_Lumpur",
140
+ "Singapore" => "Asia/Singapore",
141
+ "Taipei" => "Asia/Taipei",
142
+ "Perth" => "Australia/Perth",
143
+ "Irkutsk" => "Asia/Irkutsk",
144
+ "Ulaan Bataar" => "Asia/Ulaanbaatar",
145
+ "Seoul" => "Asia/Seoul",
146
+ "Osaka" => "Asia/Tokyo",
147
+ "Sapporo" => "Asia/Tokyo",
148
+ "Tokyo" => "Asia/Tokyo",
149
+ "Yakutsk" => "Asia/Yakutsk",
150
+ "Darwin" => "Australia/Darwin",
151
+ "Adelaide" => "Australia/Adelaide",
152
+ "Canberra" => "Australia/Melbourne",
153
+ "Melbourne" => "Australia/Melbourne",
154
+ "Sydney" => "Australia/Sydney",
155
+ "Brisbane" => "Australia/Brisbane",
156
+ "Hobart" => "Australia/Hobart",
157
+ "Vladivostok" => "Asia/Vladivostok",
158
+ "Guam" => "Pacific/Guam",
159
+ "Port Moresby" => "Pacific/Port_Moresby",
160
+ "Magadan" => "Asia/Magadan",
161
+ "Solomon Is." => "Asia/Magadan",
162
+ "New Caledonia" => "Pacific/Noumea",
163
+ "Fiji" => "Pacific/Fiji",
164
+ "Kamchatka" => "Asia/Kamchatka",
165
+ "Marshall Is." => "Pacific/Majuro",
166
+ "Auckland" => "Pacific/Auckland",
167
+ "Wellington" => "Pacific/Auckland",
168
+ "Nuku'alofa" => "Pacific/Tongatapu"
169
+ }.each { |name, zone| name.freeze; zone.freeze }
170
+ MAPPING.freeze
171
+ end
174
172
 
175
- # Create a new TimeZone object with the given name and offset. The
176
- # offset is the number of seconds that this time zone is offset from UTC
177
- # (GMT). Seconds were chosen as the offset unit because that is the unit that
178
- # Ruby uses to represent time zone offsets (see Time#utc_offset).
179
- def initialize(name, utc_offset, tzinfo = nil)
180
- @name = name
181
- @utc_offset = utc_offset
182
- @tzinfo = tzinfo
183
- end
173
+ include Comparable
174
+ attr_reader :name
184
175
 
185
- def utc_offset
186
- @utc_offset ||= tzinfo.current_period.utc_offset
187
- end
188
-
189
- # Returns the offset of this time zone as a formatted string, of the
190
- # format "+HH:MM".
191
- def formatted_offset(colon=true, alternate_utc_string = nil)
192
- utc_offset == 0 && alternate_utc_string || utc_offset.to_utc_offset_s(colon)
193
- end
176
+ # Create a new TimeZone object with the given name and offset. The
177
+ # offset is the number of seconds that this time zone is offset from UTC
178
+ # (GMT). Seconds were chosen as the offset unit because that is the unit that
179
+ # Ruby uses to represent time zone offsets (see Time#utc_offset).
180
+ def initialize(name, utc_offset, tzinfo = nil)
181
+ @name = name
182
+ @utc_offset = utc_offset
183
+ @tzinfo = tzinfo
184
+ end
194
185
 
195
- # Compare this time zone to the parameter. The two are comapred first on
196
- # their offsets, and then by name.
197
- def <=>(zone)
198
- result = (utc_offset <=> zone.utc_offset)
199
- result = (name <=> zone.name) if result == 0
200
- result
201
- end
186
+ def utc_offset
187
+ @utc_offset ||= tzinfo.current_period.utc_offset
188
+ end
202
189
 
203
- # Returns a textual representation of this time zone.
204
- def to_s
205
- "(GMT#{formatted_offset}) #{name}"
206
- end
190
+ # Returns the offset of this time zone as a formatted string, of the
191
+ # format "+HH:MM".
192
+ def formatted_offset(colon=true, alternate_utc_string = nil)
193
+ utc_offset == 0 && alternate_utc_string || utc_offset.to_utc_offset_s(colon)
194
+ end
207
195
 
208
- # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from given values. Example:
209
- #
210
- # Time.zone = "Hawaii" # => "Hawaii"
211
- # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00
212
- def local(*args)
213
- time = Time.utc_time(*args)
214
- ActiveSupport::TimeWithZone.new(nil, self, time)
215
- end
196
+ # Compare this time zone to the parameter. The two are comapred first on
197
+ # their offsets, and then by name.
198
+ def <=>(zone)
199
+ result = (utc_offset <=> zone.utc_offset)
200
+ result = (name <=> zone.name) if result == 0
201
+ result
202
+ end
216
203
 
217
- # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from number of seconds since the Unix epoch. Example:
218
- #
219
- # Time.zone = "Hawaii" # => "Hawaii"
220
- # Time.utc(2000).to_f # => 946684800.0
221
- # Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00
222
- def at(secs)
223
- utc = Time.at(secs).utc rescue DateTime.civil(1970).since(secs)
224
- utc.in_time_zone(self)
225
- end
204
+ # Returns a textual representation of this time zone.
205
+ def to_s
206
+ "(GMT#{formatted_offset}) #{name}"
207
+ end
226
208
 
227
- # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from parsed string. Example:
228
- #
229
- # Time.zone = "Hawaii" # => "Hawaii"
230
- # Time.zone.parse('1999-12-31 14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00
231
- #
232
- # If upper components are missing from the string, they are supplied from TimeZone#now:
233
- #
234
- # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00
235
- # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00
236
- def parse(str, now=now)
237
- date_parts = Date._parse(str)
238
- return if date_parts.blank?
239
- time = Time.parse(str, now) rescue DateTime.parse(str)
240
- if date_parts[:offset].nil?
209
+ # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from given values. Example:
210
+ #
211
+ # Time.zone = "Hawaii" # => "Hawaii"
212
+ # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00
213
+ def local(*args)
214
+ time = Time.utc_time(*args)
241
215
  ActiveSupport::TimeWithZone.new(nil, self, time)
242
- else
243
- time.in_time_zone(self)
244
216
  end
245
- end
246
217
 
247
- # Returns an ActiveSupport::TimeWithZone instance representing the current time
248
- # in the time zone represented by +self+. Example:
249
- #
250
- # Time.zone = 'Hawaii' # => "Hawaii"
251
- # Time.zone.now # => Wed, 23 Jan 2008 20:24:27 HST -10:00
252
- def now
253
- Time.now.utc.in_time_zone(self)
254
- end
218
+ # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from number of seconds since the Unix epoch. Example:
219
+ #
220
+ # Time.zone = "Hawaii" # => "Hawaii"
221
+ # Time.utc(2000).to_f # => 946684800.0
222
+ # Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00
223
+ def at(secs)
224
+ utc = Time.at(secs).utc rescue DateTime.civil(1970).since(secs)
225
+ utc.in_time_zone(self)
226
+ end
255
227
 
256
- # Return the current date in this time zone.
257
- def today
258
- tzinfo.now.to_date
259
- end
228
+ # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from parsed string. Example:
229
+ #
230
+ # Time.zone = "Hawaii" # => "Hawaii"
231
+ # Time.zone.parse('1999-12-31 14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00
232
+ #
233
+ # If upper components are missing from the string, they are supplied from TimeZone#now:
234
+ #
235
+ # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00
236
+ # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00
237
+ def parse(str, now=now)
238
+ date_parts = Date._parse(str)
239
+ return if date_parts.blank?
240
+ time = Time.parse(str, now) rescue DateTime.parse(str)
241
+ if date_parts[:offset].nil?
242
+ ActiveSupport::TimeWithZone.new(nil, self, time)
243
+ else
244
+ time.in_time_zone(self)
245
+ end
246
+ end
260
247
 
261
- # Adjust the given time to the simultaneous time in the time zone represented by +self+. Returns a
262
- # Time.utc() instance -- if you want an ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead.
263
- def utc_to_local(time)
264
- tzinfo.utc_to_local(time)
265
- end
248
+ # Returns an ActiveSupport::TimeWithZone instance representing the current time
249
+ # in the time zone represented by +self+. Example:
250
+ #
251
+ # Time.zone = 'Hawaii' # => "Hawaii"
252
+ # Time.zone.now # => Wed, 23 Jan 2008 20:24:27 HST -10:00
253
+ def now
254
+ Time.now.utc.in_time_zone(self)
255
+ end
266
256
 
267
- # Adjust the given time to the simultaneous time in UTC. Returns a Time.utc() instance.
268
- def local_to_utc(time, dst=true)
269
- tzinfo.local_to_utc(time, dst)
270
- end
257
+ # Return the current date in this time zone.
258
+ def today
259
+ tzinfo.now.to_date
260
+ end
271
261
 
272
- # Available so that TimeZone instances respond like TZInfo::Timezone instances
273
- def period_for_utc(time)
274
- tzinfo.period_for_utc(time)
275
- end
262
+ # Adjust the given time to the simultaneous time in the time zone represented by +self+. Returns a
263
+ # Time.utc() instance -- if you want an ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead.
264
+ def utc_to_local(time)
265
+ tzinfo.utc_to_local(time)
266
+ end
276
267
 
277
- # Available so that TimeZone instances respond like TZInfo::Timezone instances
278
- def period_for_local(time, dst=true)
279
- tzinfo.period_for_local(time, dst)
280
- end
268
+ # Adjust the given time to the simultaneous time in UTC. Returns a Time.utc() instance.
269
+ def local_to_utc(time, dst=true)
270
+ tzinfo.local_to_utc(time, dst)
271
+ end
281
272
 
282
- # TODO: Preload instead of lazy load for thread safety
283
- def tzinfo
284
- @tzinfo ||= TZInfo::Timezone.get(MAPPING[name])
285
- end
273
+ # Available so that TimeZone instances respond like TZInfo::Timezone instances
274
+ def period_for_utc(time)
275
+ tzinfo.period_for_utc(time)
276
+ end
286
277
 
287
- unless const_defined?(:ZONES)
288
- ZONES = []
289
- ZONES_MAP = {}
290
- [[-39_600, "International Date Line West", "Midway Island", "Samoa" ],
291
- [-36_000, "Hawaii" ],
292
- [-32_400, "Alaska" ],
293
- [-28_800, "Pacific Time (US & Canada)", "Tijuana" ],
294
- [-25_200, "Mountain Time (US & Canada)", "Chihuahua", "Mazatlan",
295
- "Arizona" ],
296
- [-21_600, "Central Time (US & Canada)", "Saskatchewan", "Guadalajara",
297
- "Mexico City", "Monterrey", "Central America" ],
298
- [-18_000, "Eastern Time (US & Canada)", "Indiana (East)", "Bogota",
299
- "Lima", "Quito" ],
300
- [-14_400, "Atlantic Time (Canada)", "Caracas", "La Paz", "Santiago" ],
301
- [-12_600, "Newfoundland" ],
302
- [-10_800, "Brasilia", "Buenos Aires", "Georgetown", "Greenland" ],
303
- [ -7_200, "Mid-Atlantic" ],
304
- [ -3_600, "Azores", "Cape Verde Is." ],
305
- [ 0, "Dublin", "Edinburgh", "Lisbon", "London", "Casablanca",
306
- "Monrovia", "UTC" ],
307
- [ 3_600, "Belgrade", "Bratislava", "Budapest", "Ljubljana", "Prague",
308
- "Sarajevo", "Skopje", "Warsaw", "Zagreb", "Brussels",
309
- "Copenhagen", "Madrid", "Paris", "Amsterdam", "Berlin",
310
- "Bern", "Rome", "Stockholm", "Vienna",
311
- "West Central Africa" ],
312
- [ 7_200, "Bucharest", "Cairo", "Helsinki", "Kyev", "Riga", "Sofia",
313
- "Tallinn", "Vilnius", "Athens", "Istanbul", "Minsk",
314
- "Jerusalem", "Harare", "Pretoria" ],
315
- [ 10_800, "Moscow", "St. Petersburg", "Volgograd", "Kuwait", "Riyadh",
316
- "Nairobi", "Baghdad" ],
317
- [ 12_600, "Tehran" ],
318
- [ 14_400, "Abu Dhabi", "Muscat", "Baku", "Tbilisi", "Yerevan" ],
319
- [ 16_200, "Kabul" ],
320
- [ 18_000, "Ekaterinburg", "Islamabad", "Karachi", "Tashkent" ],
321
- [ 19_800, "Chennai", "Kolkata", "Mumbai", "New Delhi" ],
322
- [ 20_700, "Kathmandu" ],
323
- [ 21_600, "Astana", "Dhaka", "Sri Jayawardenepura", "Almaty",
324
- "Novosibirsk" ],
325
- [ 23_400, "Rangoon" ],
326
- [ 25_200, "Bangkok", "Hanoi", "Jakarta", "Krasnoyarsk" ],
327
- [ 28_800, "Beijing", "Chongqing", "Hong Kong", "Urumqi",
328
- "Kuala Lumpur", "Singapore", "Taipei", "Perth", "Irkutsk",
329
- "Ulaan Bataar" ],
330
- [ 32_400, "Seoul", "Osaka", "Sapporo", "Tokyo", "Yakutsk" ],
331
- [ 34_200, "Darwin", "Adelaide" ],
332
- [ 36_000, "Canberra", "Melbourne", "Sydney", "Brisbane", "Hobart",
333
- "Vladivostok", "Guam", "Port Moresby" ],
334
- [ 39_600, "Magadan", "Solomon Is.", "New Caledonia" ],
335
- [ 43_200, "Fiji", "Kamchatka", "Marshall Is.", "Auckland",
336
- "Wellington" ],
337
- [ 46_800, "Nuku'alofa" ]].
338
- each do |offset, *places|
339
- places.each do |place|
340
- place.freeze
341
- zone = new(place, offset)
342
- ZONES << zone
343
- ZONES_MAP[place] = zone
344
- end
278
+ # Available so that TimeZone instances respond like TZInfo::Timezone instances
279
+ def period_for_local(time, dst=true)
280
+ tzinfo.period_for_local(time, dst)
345
281
  end
346
- ZONES.sort!
347
- ZONES.freeze
348
- ZONES_MAP.freeze
349
282
 
350
- US_ZONES = ZONES.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
351
- US_ZONES.freeze
352
- end
283
+ # TODO: Preload instead of lazy load for thread safety
284
+ def tzinfo
285
+ @tzinfo ||= TZInfo::Timezone.get(MAPPING[name])
286
+ end
353
287
 
354
- class << self
355
- alias_method :create, :new
288
+ unless const_defined?(:ZONES)
289
+ ZONES = []
290
+ ZONES_MAP = {}
291
+ [[-39_600, "International Date Line West", "Midway Island", "Samoa" ],
292
+ [-36_000, "Hawaii" ],
293
+ [-32_400, "Alaska" ],
294
+ [-28_800, "Pacific Time (US & Canada)", "Tijuana" ],
295
+ [-25_200, "Mountain Time (US & Canada)", "Chihuahua", "Mazatlan",
296
+ "Arizona" ],
297
+ [-21_600, "Central Time (US & Canada)", "Saskatchewan", "Guadalajara",
298
+ "Mexico City", "Monterrey", "Central America" ],
299
+ [-18_000, "Eastern Time (US & Canada)", "Indiana (East)", "Bogota",
300
+ "Lima", "Quito" ],
301
+ [-14_400, "Atlantic Time (Canada)", "Caracas", "La Paz", "Santiago" ],
302
+ [-12_600, "Newfoundland" ],
303
+ [-10_800, "Brasilia", "Buenos Aires", "Georgetown", "Greenland" ],
304
+ [ -7_200, "Mid-Atlantic" ],
305
+ [ -3_600, "Azores", "Cape Verde Is." ],
306
+ [ 0, "Dublin", "Edinburgh", "Lisbon", "London", "Casablanca",
307
+ "Monrovia", "UTC" ],
308
+ [ 3_600, "Belgrade", "Bratislava", "Budapest", "Ljubljana", "Prague",
309
+ "Sarajevo", "Skopje", "Warsaw", "Zagreb", "Brussels",
310
+ "Copenhagen", "Madrid", "Paris", "Amsterdam", "Berlin",
311
+ "Bern", "Rome", "Stockholm", "Vienna",
312
+ "West Central Africa" ],
313
+ [ 7_200, "Bucharest", "Cairo", "Helsinki", "Kyev", "Riga", "Sofia",
314
+ "Tallinn", "Vilnius", "Athens", "Istanbul", "Minsk",
315
+ "Jerusalem", "Harare", "Pretoria" ],
316
+ [ 10_800, "Moscow", "St. Petersburg", "Volgograd", "Kuwait", "Riyadh",
317
+ "Nairobi", "Baghdad" ],
318
+ [ 12_600, "Tehran" ],
319
+ [ 14_400, "Abu Dhabi", "Muscat", "Baku", "Tbilisi", "Yerevan" ],
320
+ [ 16_200, "Kabul" ],
321
+ [ 18_000, "Ekaterinburg", "Islamabad", "Karachi", "Tashkent" ],
322
+ [ 19_800, "Chennai", "Kolkata", "Mumbai", "New Delhi" ],
323
+ [ 20_700, "Kathmandu" ],
324
+ [ 21_600, "Astana", "Dhaka", "Sri Jayawardenepura", "Almaty",
325
+ "Novosibirsk" ],
326
+ [ 23_400, "Rangoon" ],
327
+ [ 25_200, "Bangkok", "Hanoi", "Jakarta", "Krasnoyarsk" ],
328
+ [ 28_800, "Beijing", "Chongqing", "Hong Kong", "Urumqi",
329
+ "Kuala Lumpur", "Singapore", "Taipei", "Perth", "Irkutsk",
330
+ "Ulaan Bataar" ],
331
+ [ 32_400, "Seoul", "Osaka", "Sapporo", "Tokyo", "Yakutsk" ],
332
+ [ 34_200, "Darwin", "Adelaide" ],
333
+ [ 36_000, "Canberra", "Melbourne", "Sydney", "Brisbane", "Hobart",
334
+ "Vladivostok", "Guam", "Port Moresby" ],
335
+ [ 39_600, "Magadan", "Solomon Is.", "New Caledonia" ],
336
+ [ 43_200, "Fiji", "Kamchatka", "Marshall Is.", "Auckland",
337
+ "Wellington" ],
338
+ [ 46_800, "Nuku'alofa" ]].
339
+ each do |offset, *places|
340
+ places.each do |place|
341
+ place.freeze
342
+ zone = new(place, offset)
343
+ ZONES << zone
344
+ ZONES_MAP[place] = zone
345
+ end
346
+ end
347
+ ZONES.sort!
348
+ ZONES.freeze
349
+ ZONES_MAP.freeze
356
350
 
357
- # Return a TimeZone instance with the given name, or +nil+ if no
358
- # such TimeZone instance exists. (This exists to support the use of
359
- # this class with the +composed_of+ macro.)
360
- def new(name)
361
- self[name]
351
+ US_ZONES = ZONES.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
352
+ US_ZONES.freeze
362
353
  end
363
354
 
364
- # Return an array of all TimeZone objects. There are multiple
365
- # TimeZone objects per time zone, in many cases, to make it easier
366
- # for users to find their own time zone.
367
- def all
368
- ZONES
369
- end
355
+ class << self
356
+ alias_method :create, :new
370
357
 
371
- # Locate a specific time zone object. If the argument is a string, it
372
- # is interpreted to mean the name of the timezone to locate. If it is a
373
- # numeric value it is either the hour offset, or the second offset, of the
374
- # timezone to find. (The first one with that offset will be returned.)
375
- # Returns +nil+ if no such time zone is known to the system.
376
- def [](arg)
377
- case arg
378
- when String
379
- ZONES_MAP[arg]
380
- when Numeric, ActiveSupport::Duration
381
- arg *= 3600 if arg.abs <= 13
382
- all.find { |z| z.utc_offset == arg.to_i }
383
- else
384
- raise ArgumentError, "invalid argument to TimeZone[]: #{arg.inspect}"
358
+ # Return a TimeZone instance with the given name, or +nil+ if no
359
+ # such TimeZone instance exists. (This exists to support the use of
360
+ # this class with the +composed_of+ macro.)
361
+ def new(name)
362
+ self[name]
385
363
  end
386
- end
387
364
 
388
- # A convenience method for returning a collection of TimeZone objects
389
- # for time zones in the USA.
390
- def us_zones
391
- US_ZONES
365
+ # Return an array of all TimeZone objects. There are multiple
366
+ # TimeZone objects per time zone, in many cases, to make it easier
367
+ # for users to find their own time zone.
368
+ def all
369
+ ZONES
370
+ end
371
+
372
+ # Locate a specific time zone object. If the argument is a string, it
373
+ # is interpreted to mean the name of the timezone to locate. If it is a
374
+ # numeric value it is either the hour offset, or the second offset, of the
375
+ # timezone to find. (The first one with that offset will be returned.)
376
+ # Returns +nil+ if no such time zone is known to the system.
377
+ def [](arg)
378
+ case arg
379
+ when String
380
+ ZONES_MAP[arg]
381
+ when Numeric, ActiveSupport::Duration
382
+ arg *= 3600 if arg.abs <= 13
383
+ all.find { |z| z.utc_offset == arg.to_i }
384
+ else
385
+ raise ArgumentError, "invalid argument to TimeZone[]: #{arg.inspect}"
386
+ end
387
+ end
388
+
389
+ # A convenience method for returning a collection of TimeZone objects
390
+ # for time zones in the USA.
391
+ def us_zones
392
+ US_ZONES
393
+ end
392
394
  end
393
395
  end
394
396
  end