5 # Ruby 1.8-cvs and 1.9 define private Time#to_date
6 %w(to_date to_datetime
).each
do |method
|
7 public method
if private_instance_methods
.include?(method
)
10 # Pre-1.9 versions of Ruby have a bug with marshaling Time instances, where utc instances are
11 # unmarshaled in the local zone, instead of utc. We're layering behavior on the _dump and _load
12 # methods so that utc instances can be flagged on dump, and coerced back to utc on load.
13 if RUBY_VERSION < '1.9'
15 alias_method
:_original_load, :_load
16 def _load(marshaled_time
)
17 time
= _original_load(marshaled_time
)
18 utc
= time
.instance_variable_get('@marshal_with_utc_coercion')
23 alias_method
:_original_dump, :_dump
25 obj
= self.frozen
? ? self.dup
: self
26 obj
.instance_variable_set('@marshal_with_utc_coercion', utc
?)
27 obj
._original_dump(*args
)
32 require 'active_support/core_ext/time/behavior'
33 require 'active_support/core_ext/time/calculations'
34 require 'active_support/core_ext/time/conversions'
35 require 'active_support/core_ext/time/zones'
38 include ActiveSupport
::CoreExtensions::Time::Behavior
39 include ActiveSupport
::CoreExtensions::Time::Calculations
40 include ActiveSupport
::CoreExtensions::Time::Conversions
41 include ActiveSupport
::CoreExtensions::Time::Zones