Coercible::Coercer::TimeCoercions

Common time coercion methods

Public Instance Methods

to_date(value) click to toggle source

Coerce given value to Date

@example

coercer[Time].to_date(time)  # => Date object

@param [Time,DateTime] value

@return [Date]

@api public

# File lib/coercible/coercer/time_coercions.rb, line 59
def to_date(value)
  coerce_with_method(value, :to_date)
end
to_datetime(value) click to toggle source

Coerce given value to DateTime

@example

coercer[Time].to_datetime(time)  # => DateTime object

@param [Date,Time] value

@return [DateTime]

@api public

# File lib/coercible/coercer/time_coercions.rb, line 45
def to_datetime(value)
  coerce_with_method(value, :to_datetime)
end
to_string(value) click to toggle source

Coerce given value to String

@example

coercer[Time].to_string(time)  # => "Wed Jul 20 10:30:41 -0700 2011"

@param [Date,Time,DateTime] value

@return [String]

@api public

# File lib/coercible/coercer/time_coercions.rb, line 17
def to_string(value)
  value.to_s
end
to_time(value) click to toggle source

Coerce given value to Time

@example

coercer[DateTime].to_time(datetime)  # => Time object

@param [Date,DateTime] value

@return [Time]

@api public

# File lib/coercible/coercer/time_coercions.rb, line 31
def to_time(value)
  coerce_with_method(value, :to_time)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.