Sha256: 879daa6a7fe6d991afc4bb24425c13dba5cf3d9d402b8db4813eaf71943d8437

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'date'
require 'time'

class Time
  # Ruby 1.8-cvs and 1.9 define private Time#to_date
  %w(to_date to_datetime).each do |method|
    public method if private_instance_methods.include?(method)
  end

  # Pre-1.9 versions of Ruby have a bug with marshaling Time instances, where utc instances are
  # unmarshaled in the local zone, instead of utc. We're layering behavior on the _dump and _load
  # methods so that utc instances can be flagged on dump, and coerced back to utc on load.
  if RUBY_VERSION < '1.9'
    class << self
      alias_method :_original_load, :_load
      def _load(marshaled_time)
        time = _original_load(marshaled_time)
        time.instance_eval do
          if defined?(@marshal_with_utc_coercion)
            val = remove_instance_variable("@marshal_with_utc_coercion")
          end
          val ? utc : self
        end
      end
    end

    alias_method :_original_dump, :_dump
    def _dump(*args)
      obj = dup
      obj.instance_variable_set('@marshal_with_utc_coercion', utc?)
      obj._original_dump(*args)
    end
  end
end

require 'passive_support/core_ext/time/behavior'
require 'passive_support/core_ext/time/calculations'
require 'passive_support/core_ext/time/conversions'
require 'passive_support/core_ext/time/zones'

class Time#:nodoc:
  include PassiveSupport::CoreExtensions::Time::Behavior
  include PassiveSupport::CoreExtensions::Time::Calculations
  include PassiveSupport::CoreExtensions::Time::Conversions
  include PassiveSupport::CoreExtensions::Time::Zones
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emipair-delayed_job-2.0.3.1 lib/passive_support/core_ext/time.rb