activesupport 3.0.0.beta4 → 3.0.pre
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.
- data/CHANGELOG +1 -100
- data/lib/active_support.rb +4 -38
- data/lib/active_support/autoload.rb +28 -0
- data/lib/active_support/backtrace_cleaner.rb +9 -31
- data/lib/active_support/benchmarkable.rb +0 -1
- data/lib/active_support/buffered_logger.rb +1 -0
- data/lib/active_support/cache.rb +81 -436
- data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -6
- data/lib/active_support/cache/file_store.rb +41 -139
- data/lib/active_support/cache/mem_cache_store.rb +75 -120
- data/lib/active_support/cache/memory_store.rb +27 -127
- data/lib/active_support/cache/strategy/local_cache.rb +58 -111
- data/lib/active_support/cache/synchronized_memory_store.rb +38 -2
- data/lib/active_support/callbacks.rb +48 -87
- data/lib/active_support/configurable.rb +18 -19
- data/lib/active_support/core_ext/array.rb +0 -1
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +54 -29
- data/lib/active_support/core_ext/array/extract_options.rb +1 -16
- data/lib/active_support/core_ext/array/random_access.rb +5 -19
- data/lib/active_support/core_ext/array/wrap.rb +9 -13
- data/lib/active_support/core_ext/benchmark.rb +12 -0
- data/lib/active_support/core_ext/boolean.rb +1 -0
- data/lib/active_support/core_ext/boolean/conversions.rb +11 -0
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -2
- data/lib/active_support/core_ext/class.rb +1 -1
- data/lib/active_support/core_ext/class/attribute_accessors.rb +27 -33
- data/lib/active_support/core_ext/class/delegating_attributes.rb +41 -35
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +13 -22
- data/lib/active_support/core_ext/class/removal.rb +53 -0
- data/lib/active_support/core_ext/date.rb +7 -0
- data/lib/active_support/core_ext/date/calculations.rb +8 -30
- data/lib/active_support/core_ext/date/conversions.rb +2 -2
- data/lib/active_support/core_ext/date_time.rb +5 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +1 -2
- data/lib/active_support/core_ext/date_time/conversions.rb +5 -23
- data/lib/active_support/core_ext/enumerable.rb +9 -5
- data/lib/active_support/core_ext/exception.rb +47 -0
- data/lib/active_support/core_ext/file.rb +0 -1
- data/lib/active_support/core_ext/file/atomic.rb +2 -3
- data/lib/active_support/core_ext/float/rounding.rb +2 -3
- data/lib/active_support/core_ext/hash/conversions.rb +145 -65
- data/lib/active_support/core_ext/hash/deep_merge.rb +7 -6
- data/lib/active_support/core_ext/hash/except.rb +0 -8
- data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -5
- data/lib/active_support/core_ext/hash/keys.rb +11 -10
- data/lib/active_support/core_ext/hash/slice.rb +0 -6
- data/lib/active_support/core_ext/integer.rb +1 -1
- data/lib/active_support/core_ext/integer/even_odd.rb +16 -0
- data/lib/active_support/core_ext/kernel.rb +1 -1
- data/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +2 -3
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -2
- data/lib/active_support/core_ext/load_error.rb +30 -17
- data/lib/active_support/core_ext/logger.rb +1 -1
- data/lib/active_support/core_ext/module.rb +3 -5
- data/lib/active_support/core_ext/module/aliasing.rb +1 -1
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
- data/lib/active_support/core_ext/module/attribute_accessors.rb +21 -25
- data/lib/active_support/core_ext/module/delegation.rb +10 -21
- data/lib/active_support/core_ext/module/inclusion.rb +30 -0
- data/lib/active_support/core_ext/module/introspection.rb +8 -8
- data/lib/active_support/core_ext/module/loading.rb +23 -0
- data/lib/active_support/core_ext/module/synchronization.rb +1 -2
- data/lib/active_support/core_ext/name_error.rb +1 -3
- data/lib/active_support/core_ext/nil.rb +1 -0
- data/lib/active_support/core_ext/nil/conversions.rb +5 -0
- data/lib/active_support/core_ext/object.rb +2 -6
- data/lib/active_support/core_ext/object/blank.rb +2 -20
- data/lib/active_support/core_ext/object/conversions.rb +16 -2
- data/lib/active_support/core_ext/object/duplicable.rb +1 -23
- data/lib/active_support/core_ext/object/extending.rb +77 -8
- data/lib/active_support/core_ext/object/instance_variables.rb +7 -0
- data/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/active_support/core_ext/object/misc.rb +1 -0
- data/lib/active_support/core_ext/object/tap.rb +16 -0
- data/lib/active_support/core_ext/object/with_options.rb +0 -2
- data/lib/active_support/core_ext/proc.rb +4 -4
- data/lib/active_support/core_ext/regexp.rb +22 -0
- data/lib/active_support/core_ext/rexml.rb +1 -4
- data/lib/active_support/core_ext/string.rb +2 -3
- data/lib/active_support/core_ext/string/access.rb +2 -4
- data/lib/active_support/core_ext/string/bytesize.rb +5 -0
- data/lib/active_support/core_ext/string/conversions.rb +1 -36
- data/lib/active_support/core_ext/string/filters.rb +0 -29
- data/lib/active_support/core_ext/string/inflections.rb +12 -1
- data/lib/active_support/core_ext/string/interpolation.rb +92 -2
- data/lib/active_support/core_ext/string/iterators.rb +13 -0
- data/lib/active_support/core_ext/string/multibyte.rb +19 -16
- data/lib/active_support/core_ext/string/output_safety.rb +35 -101
- data/lib/active_support/core_ext/string/starts_ends_with.rb +14 -0
- data/lib/active_support/core_ext/string/xchar.rb +1 -1
- data/lib/active_support/core_ext/symbol.rb +1 -0
- data/lib/active_support/core_ext/symbol/to_proc.rb +14 -0
- data/lib/active_support/core_ext/time.rb +10 -0
- data/lib/active_support/core_ext/time/calculations.rb +7 -9
- data/lib/active_support/core_ext/time/conversions.rb +0 -1
- data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +22 -0
- data/lib/active_support/core_ext/uri.rb +4 -10
- data/lib/active_support/dependencies.rb +192 -179
- data/lib/active_support/deprecated_callbacks.rb +283 -0
- data/lib/active_support/deprecation/behaviors.rb +1 -1
- data/lib/active_support/deprecation/method_wrappers.rb +9 -10
- data/lib/active_support/deprecation/reporting.rb +1 -2
- data/lib/active_support/duration.rb +2 -6
- data/lib/active_support/hash_with_indifferent_access.rb +1 -9
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector.rb +407 -4
- data/lib/active_support/json/backends/jsongem.rb +9 -12
- data/lib/active_support/json/decoding.rb +1 -16
- data/lib/active_support/json/encoding.rb +12 -42
- data/lib/active_support/locale/en.yml +1 -4
- data/lib/active_support/memoizable.rb +1 -1
- data/lib/active_support/message_encryptor.rb +0 -1
- data/lib/active_support/message_verifier.rb +5 -6
- data/lib/active_support/multibyte.rb +22 -7
- data/lib/active_support/multibyte/chars.rb +392 -164
- data/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/active_support/multibyte/utils.rb +7 -6
- data/lib/active_support/notifications.rb +113 -23
- data/lib/active_support/ordered_hash.rb +11 -35
- data/lib/active_support/ordered_options.rb +0 -6
- data/lib/active_support/rescuable.rb +4 -7
- data/lib/active_support/ruby/shim.rb +6 -4
- data/lib/active_support/test_case.rb +7 -2
- data/lib/active_support/testing/assertions.rb +0 -15
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/isolation.rb +19 -63
- data/lib/active_support/testing/performance.rb +337 -342
- data/lib/active_support/testing/setup_and_teardown.rb +29 -51
- data/lib/active_support/time.rb +3 -23
- data/lib/active_support/time_with_zone.rb +10 -5
- data/lib/active_support/values/time_zone.rb +84 -40
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/vendor.rb +16 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +113 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +13 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +20 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +250 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +115 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
- data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +20 -0
- data/lib/active_support/vendor/i18n-0.1.3/README.textile +20 -0
- data/lib/active_support/vendor/i18n-0.1.3/Rakefile +5 -0
- data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +27 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +204 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +215 -0
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +53 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +5 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +99 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +124 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +1 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +3 -0
- data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +567 -0
- data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +1133 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +47 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +228 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +55 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +219 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +42 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +283 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +136 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +204 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +161 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +274 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +194 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +139 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +144 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +131 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +282 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +74 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +205 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +288 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +196 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +67 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +73 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +161 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +32 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +24 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +34 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +59 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +47 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +121 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +30 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +33 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +270 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +187 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +35 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +29 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +193 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +37 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +16 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +185 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +188 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +181 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +197 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +276 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +163 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +218 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +168 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +268 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +288 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +211 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +170 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +181 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +232 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +187 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +176 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +215 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +173 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +165 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +172 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +183 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +170 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +212 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +13 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +202 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +23 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +22 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +25 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +52 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +51 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +44 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +98 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +56 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +292 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +508 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +56 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +40 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +94 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +198 -0
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +129 -0
- data/lib/active_support/version.rb +2 -3
- data/lib/active_support/whiny_nil.rb +7 -9
- data/lib/active_support/xml_mini.rb +1 -126
- data/lib/active_support/xml_mini/jdom.rb +0 -2
- data/lib/active_support/xml_mini/libxml.rb +86 -24
- data/lib/active_support/xml_mini/nokogiri.rb +24 -27
- data/lib/active_support/xml_mini/rexml.rb +1 -7
- metadata +191 -49
- data/lib/active_support/builder.rb +0 -6
- data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
- data/lib/active_support/core_ext/class/attribute.rb +0 -67
- data/lib/active_support/core_ext/class/subclasses.rb +0 -55
- data/lib/active_support/core_ext/file/path.rb +0 -5
- data/lib/active_support/core_ext/integer/multiple.rb +0 -6
- data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
- data/lib/active_support/core_ext/module/anonymous.rb +0 -24
- data/lib/active_support/core_ext/module/method_names.rb +0 -14
- data/lib/active_support/core_ext/module/reachable.rb +0 -10
- data/lib/active_support/core_ext/module/remove_method.rb +0 -6
- data/lib/active_support/core_ext/object/to_param.rb +0 -49
- data/lib/active_support/core_ext/object/to_query.rb +0 -27
- data/lib/active_support/core_ext/string/encoding.rb +0 -11
- data/lib/active_support/core_ext/string/exclude.rb +0 -6
- data/lib/active_support/core_ext/time/marshal.rb +0 -56
- data/lib/active_support/dependencies/autoload.rb +0 -50
- data/lib/active_support/i18n.rb +0 -8
- data/lib/active_support/inflector/inflections.rb +0 -211
- data/lib/active_support/inflector/methods.rb +0 -141
- data/lib/active_support/inflector/transliterate.rb +0 -97
- data/lib/active_support/json/backends/yajl.rb +0 -40
- data/lib/active_support/lazy_load_hooks.rb +0 -27
- data/lib/active_support/multibyte/unicode.rb +0 -393
- data/lib/active_support/notifications/fanout.rb +0 -93
- data/lib/active_support/notifications/instrumenter.rb +0 -56
- data/lib/active_support/railtie.rb +0 -100
- data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
- data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
@@ -0,0 +1,56 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2006 Philip Ross
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'tzinfo/data_timezone_info'
|
24
|
+
require 'tzinfo/linked_timezone_info'
|
25
|
+
|
26
|
+
module TZInfo
|
27
|
+
|
28
|
+
# TimezoneDefinition is included into Timezone definition modules.
|
29
|
+
# TimezoneDefinition provides the methods for defining timezones.
|
30
|
+
module TimezoneDefinition #:nodoc:
|
31
|
+
# Add class methods to the includee.
|
32
|
+
def self.append_features(base)
|
33
|
+
super
|
34
|
+
base.extend(ClassMethods)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Class methods for inclusion.
|
38
|
+
module ClassMethods #:nodoc:
|
39
|
+
# Returns and yields a DataTimezoneInfo object to define a timezone.
|
40
|
+
def timezone(identifier)
|
41
|
+
yield @timezone = DataTimezoneInfo.new(identifier)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Defines a linked timezone.
|
45
|
+
def linked_timezone(identifier, link_to_identifier)
|
46
|
+
@timezone = LinkedTimezoneInfo.new(identifier, link_to_identifier)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the last TimezoneInfo to be defined with timezone or
|
50
|
+
# linked_timezone.
|
51
|
+
def get
|
52
|
+
@timezone
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2006 Philip Ross
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
module TZInfo
|
24
|
+
# Represents a timezone defined in a data module.
|
25
|
+
class TimezoneInfo #:nodoc:
|
26
|
+
|
27
|
+
# The timezone identifier.
|
28
|
+
attr_reader :identifier
|
29
|
+
|
30
|
+
# Constructs a new TimezoneInfo with an identifier.
|
31
|
+
def initialize(identifier)
|
32
|
+
@identifier = identifier
|
33
|
+
end
|
34
|
+
|
35
|
+
# Returns internal object state as a programmer-readable string.
|
36
|
+
def inspect
|
37
|
+
"#<#{self.class}: #@identifier>"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2006 Philip Ross
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
module TZInfo
|
24
|
+
# Represents an offset defined in a Timezone data file.
|
25
|
+
class TimezoneOffsetInfo #:nodoc:
|
26
|
+
# The base offset of the timezone from UTC in seconds.
|
27
|
+
attr_reader :utc_offset
|
28
|
+
|
29
|
+
# The offset from standard time for the zone in seconds (i.e. non-zero if
|
30
|
+
# daylight savings is being observed).
|
31
|
+
attr_reader :std_offset
|
32
|
+
|
33
|
+
# The total offset of this observance from UTC in seconds
|
34
|
+
# (utc_offset + std_offset).
|
35
|
+
attr_reader :utc_total_offset
|
36
|
+
|
37
|
+
# The abbreviation that identifies this observance, e.g. "GMT"
|
38
|
+
# (Greenwich Mean Time) or "BST" (British Summer Time) for "Europe/London". The returned identifier is a
|
39
|
+
# symbol.
|
40
|
+
attr_reader :abbreviation
|
41
|
+
|
42
|
+
# Constructs a new TimezoneOffsetInfo. utc_offset and std_offset are
|
43
|
+
# specified in seconds.
|
44
|
+
def initialize(utc_offset, std_offset, abbreviation)
|
45
|
+
@utc_offset = utc_offset
|
46
|
+
@std_offset = std_offset
|
47
|
+
@abbreviation = abbreviation
|
48
|
+
|
49
|
+
@utc_total_offset = @utc_offset + @std_offset
|
50
|
+
end
|
51
|
+
|
52
|
+
# True if std_offset is non-zero.
|
53
|
+
def dst?
|
54
|
+
@std_offset != 0
|
55
|
+
end
|
56
|
+
|
57
|
+
# Converts a UTC DateTime to local time based on the offset of this period.
|
58
|
+
def to_local(utc)
|
59
|
+
TimeOrDateTime.wrap(utc) {|wrapped|
|
60
|
+
wrapped + @utc_total_offset
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# Converts a local DateTime to UTC based on the offset of this period.
|
65
|
+
def to_utc(local)
|
66
|
+
TimeOrDateTime.wrap(local) {|wrapped|
|
67
|
+
wrapped - @utc_total_offset
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns true if and only if toi has the same utc_offset, std_offset
|
72
|
+
# and abbreviation as this TimezoneOffsetInfo.
|
73
|
+
def ==(toi)
|
74
|
+
toi.respond_to?(:utc_offset) && toi.respond_to?(:std_offset) && toi.respond_to?(:abbreviation) &&
|
75
|
+
utc_offset == toi.utc_offset && std_offset == toi.std_offset && abbreviation == toi.abbreviation
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns true if and only if toi has the same utc_offset, std_offset
|
79
|
+
# and abbreviation as this TimezoneOffsetInfo.
|
80
|
+
def eql?(toi)
|
81
|
+
self == toi
|
82
|
+
end
|
83
|
+
|
84
|
+
# Returns a hash of this TimezoneOffsetInfo.
|
85
|
+
def hash
|
86
|
+
utc_offset.hash ^ std_offset.hash ^ abbreviation.hash
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns internal object state as a programmer-readable string.
|
90
|
+
def inspect
|
91
|
+
"#<#{self.class}: #@utc_offset,#@std_offset,#@abbreviation>"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2005-2006 Philip Ross
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'tzinfo/offset_rationals'
|
24
|
+
require 'tzinfo/time_or_datetime'
|
25
|
+
|
26
|
+
module TZInfo
|
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.
|
31
|
+
class TimezonePeriod
|
32
|
+
# The TimezoneTransitionInfo that defines the start of this TimezonePeriod
|
33
|
+
# (may be nil if unbounded).
|
34
|
+
attr_reader :start_transition
|
35
|
+
|
36
|
+
# The TimezoneTransitionInfo that defines the end of this TimezonePeriod
|
37
|
+
# (may be nil if unbounded).
|
38
|
+
attr_reader :end_transition
|
39
|
+
|
40
|
+
# The TimezoneOffsetInfo for this period.
|
41
|
+
attr_reader :offset
|
42
|
+
|
43
|
+
# Initializes a new TimezonePeriod.
|
44
|
+
def initialize(start_transition, end_transition, offset = nil)
|
45
|
+
@start_transition = start_transition
|
46
|
+
@end_transition = end_transition
|
47
|
+
|
48
|
+
if offset
|
49
|
+
raise ArgumentError, 'Offset specified with transitions' if @start_transition || @end_transition
|
50
|
+
@offset = offset
|
51
|
+
else
|
52
|
+
if @start_transition
|
53
|
+
@offset = @start_transition.offset
|
54
|
+
elsif @end_transition
|
55
|
+
@offset = @end_transition.previous_offset
|
56
|
+
else
|
57
|
+
raise ArgumentError, 'No offset specified and no transitions to determine it from'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
@utc_total_offset_rational = nil
|
62
|
+
end
|
63
|
+
|
64
|
+
# Base offset of the timezone from UTC (seconds).
|
65
|
+
def utc_offset
|
66
|
+
@offset.utc_offset
|
67
|
+
end
|
68
|
+
|
69
|
+
# Offset from the local time where daylight savings is in effect (seconds).
|
70
|
+
# E.g.: utc_offset could be -5 hours. Normally, std_offset would be 0.
|
71
|
+
# During daylight savings, std_offset would typically become +1 hours.
|
72
|
+
def std_offset
|
73
|
+
@offset.std_offset
|
74
|
+
end
|
75
|
+
|
76
|
+
# The identifier of this period, e.g. "GMT" (Greenwich Mean Time) or "BST"
|
77
|
+
# (British Summer Time) for "Europe/London". The returned identifier is a
|
78
|
+
# symbol.
|
79
|
+
def abbreviation
|
80
|
+
@offset.abbreviation
|
81
|
+
end
|
82
|
+
alias :zone_identifier :abbreviation
|
83
|
+
|
84
|
+
# Total offset from UTC (seconds). Equal to utc_offset + std_offset.
|
85
|
+
def utc_total_offset
|
86
|
+
@offset.utc_total_offset
|
87
|
+
end
|
88
|
+
|
89
|
+
# Total offset from UTC (days). Result is a Rational.
|
90
|
+
def utc_total_offset_rational
|
91
|
+
unless @utc_total_offset_rational
|
92
|
+
@utc_total_offset_rational = OffsetRationals.rational_for_offset(utc_total_offset)
|
93
|
+
end
|
94
|
+
@utc_total_offset_rational
|
95
|
+
end
|
96
|
+
|
97
|
+
# The start time of the period in UTC as a DateTime. May be nil if unbounded.
|
98
|
+
def utc_start
|
99
|
+
@start_transition ? @start_transition.at.to_datetime : nil
|
100
|
+
end
|
101
|
+
|
102
|
+
# The end time of the period in UTC as a DateTime. May be nil if unbounded.
|
103
|
+
def utc_end
|
104
|
+
@end_transition ? @end_transition.at.to_datetime : nil
|
105
|
+
end
|
106
|
+
|
107
|
+
# The start time of the period in local time as a DateTime. May be nil if
|
108
|
+
# unbounded.
|
109
|
+
def local_start
|
110
|
+
@start_transition ? @start_transition.local_start.to_datetime : nil
|
111
|
+
end
|
112
|
+
|
113
|
+
# The end time of the period in local time as a DateTime. May be nil if
|
114
|
+
# unbounded.
|
115
|
+
def local_end
|
116
|
+
@end_transition ? @end_transition.local_end.to_datetime : nil
|
117
|
+
end
|
118
|
+
|
119
|
+
# true if daylight savings is in effect for this period; otherwise false.
|
120
|
+
def dst?
|
121
|
+
@offset.dst?
|
122
|
+
end
|
123
|
+
|
124
|
+
# true if this period is valid for the given UTC DateTime; otherwise false.
|
125
|
+
def valid_for_utc?(utc)
|
126
|
+
utc_after_start?(utc) && utc_before_end?(utc)
|
127
|
+
end
|
128
|
+
|
129
|
+
# true if the given UTC DateTime is after the start of the period
|
130
|
+
# (inclusive); otherwise false.
|
131
|
+
def utc_after_start?(utc)
|
132
|
+
!@start_transition || @start_transition.at <= utc
|
133
|
+
end
|
134
|
+
|
135
|
+
# true if the given UTC DateTime is before the end of the period
|
136
|
+
# (exclusive); otherwise false.
|
137
|
+
def utc_before_end?(utc)
|
138
|
+
!@end_transition || @end_transition.at > utc
|
139
|
+
end
|
140
|
+
|
141
|
+
# true if this period is valid for the given local DateTime; otherwise false.
|
142
|
+
def valid_for_local?(local)
|
143
|
+
local_after_start?(local) && local_before_end?(local)
|
144
|
+
end
|
145
|
+
|
146
|
+
# true if the given local DateTime is after the start of the period
|
147
|
+
# (inclusive); otherwise false.
|
148
|
+
def local_after_start?(local)
|
149
|
+
!@start_transition || @start_transition.local_start <= local
|
150
|
+
end
|
151
|
+
|
152
|
+
# true if the given local DateTime is before the end of the period
|
153
|
+
# (exclusive); otherwise false.
|
154
|
+
def local_before_end?(local)
|
155
|
+
!@end_transition || @end_transition.local_end > local
|
156
|
+
end
|
157
|
+
|
158
|
+
# Converts a UTC DateTime to local time based on the offset of this period.
|
159
|
+
def to_local(utc)
|
160
|
+
@offset.to_local(utc)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Converts a local DateTime to UTC based on the offset of this period.
|
164
|
+
def to_utc(local)
|
165
|
+
@offset.to_utc(local)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns true if this TimezonePeriod is equal to p. This compares the
|
169
|
+
# start_transition, end_transition and offset using ==.
|
170
|
+
def ==(p)
|
171
|
+
p.respond_to?(:start_transition) && p.respond_to?(:end_transition) &&
|
172
|
+
p.respond_to?(:offset) && start_transition == p.start_transition &&
|
173
|
+
end_transition == p.end_transition && offset == p.offset
|
174
|
+
end
|
175
|
+
|
176
|
+
# Returns true if this TimezonePeriods is equal to p. This compares the
|
177
|
+
# start_transition, end_transition and offset using eql?
|
178
|
+
def eql?(p)
|
179
|
+
p.respond_to?(:start_transition) && p.respond_to?(:end_transition) &&
|
180
|
+
p.respond_to?(:offset) && start_transition.eql?(p.start_transition) &&
|
181
|
+
end_transition.eql?(p.end_transition) && offset.eql?(p.offset)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns a hash of this TimezonePeriod.
|
185
|
+
def hash
|
186
|
+
result = @start_transition.hash ^ @end_transition.hash
|
187
|
+
result ^= @offset.hash unless @start_transition || @end_transition
|
188
|
+
result
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns internal object state as a programmer-readable string.
|
192
|
+
def inspect
|
193
|
+
result = "#<#{self.class}: #{@start_transition.inspect},#{@end_transition.inspect}"
|
194
|
+
result << ",#{@offset.inspect}>" unless @start_transition || @end_transition
|
195
|
+
result + '>'
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2006 Philip Ross
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'date'
|
24
|
+
require 'tzinfo/time_or_datetime'
|
25
|
+
|
26
|
+
module TZInfo
|
27
|
+
# Represents an offset defined in a Timezone data file.
|
28
|
+
class TimezoneTransitionInfo #:nodoc:
|
29
|
+
# The offset this transition changes to (a TimezoneOffsetInfo instance).
|
30
|
+
attr_reader :offset
|
31
|
+
|
32
|
+
# The offset this transition changes from (a TimezoneOffsetInfo instance).
|
33
|
+
attr_reader :previous_offset
|
34
|
+
|
35
|
+
# The numerator of the DateTime if the transition time is defined as a
|
36
|
+
# DateTime, otherwise the transition time as a timestamp.
|
37
|
+
attr_reader :numerator_or_time
|
38
|
+
protected :numerator_or_time
|
39
|
+
|
40
|
+
# Either the denominotor of the DateTime if the transition time is defined
|
41
|
+
# as a DateTime, otherwise nil.
|
42
|
+
attr_reader :denominator
|
43
|
+
protected :denominator
|
44
|
+
|
45
|
+
# Creates a new TimezoneTransitionInfo with the given offset,
|
46
|
+
# previous_offset (both TimezoneOffsetInfo instances) and UTC time.
|
47
|
+
# if denominator is nil, numerator_or_time is treated as a number of
|
48
|
+
# seconds since the epoch. If denominator is specified numerator_or_time
|
49
|
+
# and denominator are used to create a DateTime as follows:
|
50
|
+
#
|
51
|
+
# DateTime.new!(Rational.send(:new!, numerator_or_time, denominator), 0, Date::ITALY)
|
52
|
+
#
|
53
|
+
# For performance reasons, the numerator and denominator must be specified
|
54
|
+
# in their lowest form.
|
55
|
+
def initialize(offset, previous_offset, numerator_or_time, denominator = nil)
|
56
|
+
@offset = offset
|
57
|
+
@previous_offset = previous_offset
|
58
|
+
@numerator_or_time = numerator_or_time
|
59
|
+
@denominator = denominator
|
60
|
+
|
61
|
+
@at = nil
|
62
|
+
@local_end = nil
|
63
|
+
@local_start = nil
|
64
|
+
end
|
65
|
+
|
66
|
+
# A TimeOrDateTime instance representing the UTC time when this transition
|
67
|
+
# occurs.
|
68
|
+
def at
|
69
|
+
unless @at
|
70
|
+
unless @denominator
|
71
|
+
@at = TimeOrDateTime.new(@numerator_or_time)
|
72
|
+
else
|
73
|
+
r = RubyCoreSupport.rational_new!(@numerator_or_time, @denominator)
|
74
|
+
dt = RubyCoreSupport.datetime_new!(r, 0, Date::ITALY)
|
75
|
+
@at = TimeOrDateTime.new(dt)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
@at
|
80
|
+
end
|
81
|
+
|
82
|
+
# A TimeOrDateTime instance representing the local time when this transition
|
83
|
+
# causes the previous observance to end (calculated from at using
|
84
|
+
# previous_offset).
|
85
|
+
def local_end
|
86
|
+
@local_end = at.add_with_convert(@previous_offset.utc_total_offset) unless @local_end
|
87
|
+
@local_end
|
88
|
+
end
|
89
|
+
|
90
|
+
# A TimeOrDateTime instance representing the local time when this transition
|
91
|
+
# causes the next observance to start (calculated from at using offset).
|
92
|
+
def local_start
|
93
|
+
@local_start = at.add_with_convert(@offset.utc_total_offset) unless @local_start
|
94
|
+
@local_start
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns true if this TimezoneTransitionInfo is equal to the given
|
98
|
+
# TimezoneTransitionInfo. Two TimezoneTransitionInfo instances are
|
99
|
+
# considered to be equal by == if offset, previous_offset and at are all
|
100
|
+
# equal.
|
101
|
+
def ==(tti)
|
102
|
+
tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) && tti.respond_to?(:at) &&
|
103
|
+
offset == tti.offset && previous_offset == tti.previous_offset && at == tti.at
|
104
|
+
end
|
105
|
+
|
106
|
+
# Returns true if this TimezoneTransitionInfo is equal to the given
|
107
|
+
# TimezoneTransitionInfo. Two TimezoneTransitionInfo instances are
|
108
|
+
# considered to be equal by eql? if offset, previous_offset,
|
109
|
+
# numerator_or_time and denominator are all equal. This is stronger than ==,
|
110
|
+
# which just requires the at times to be equal regardless of how they were
|
111
|
+
# originally specified.
|
112
|
+
def eql?(tti)
|
113
|
+
tti.respond_to?(:offset) && tti.respond_to?(:previous_offset) &&
|
114
|
+
tti.respond_to?(:numerator_or_time) && tti.respond_to?(:denominator) &&
|
115
|
+
offset == tti.offset && previous_offset == tti.previous_offset &&
|
116
|
+
numerator_or_time == tti.numerator_or_time && denominator == tti.denominator
|
117
|
+
end
|
118
|
+
|
119
|
+
# Returns a hash of this TimezoneTransitionInfo instance.
|
120
|
+
def hash
|
121
|
+
@offset.hash ^ @previous_offset.hash ^ @numerator_or_time.hash ^ @denominator.hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# Returns internal object state as a programmer-readable string.
|
125
|
+
def inspect
|
126
|
+
"#<#{self.class}: #{at.inspect},#{@offset.inspect}>"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|