Sha256: f2684bbb469d505450075b0663418b2e20bbd2bd763c5c937fad7e7e69bb556d

Contents?: true

Size: 551 Bytes

Versions: 7

Compression:

Stored size: 551 Bytes

Contents

class MLS::Attribute::DateTime < MLS::Attribute
  
  def load(value) # from_json
    if value.is_a?(::String)
      ::DateTime.iso8601(value)
    elsif value.nil? || value.is_a?(::DateTime)
      value
    elsif value.is_a?(::Time) || value.is_a?(::Date)
      value.to_datetime
    else
      raise 'unsupported date type'
    end
  end
  
  def dump(value)
    if value.is_a?(::DateTime) || value.is_a?(::Time) || value.is_a?(::Date)
      value.iso8601
    elsif value.nil?
      nil
    else
      raise 'unsupported date type'
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mls-0.14.0 lib/mls/attributes/datetime.rb
mls-0.13.0 lib/mls/attributes/datetime.rb
mls-0.12.5 lib/mls/attributes/datetime.rb
mls-0.12.4 lib/mls/attributes/datetime.rb
mls-0.12.2 lib/mls/attributes/datetime.rb
mls-0.12.3 lib/mls/attributes/datetime.rb
mls-0.12.1 lib/mls/attributes/datetime.rb