Sha256: 9ca82783736e79247c41b1f768089cc92d31b0decdf2304adeec4810c7bd5aa0

Contents?: true

Size: 549 Bytes

Versions: 102

Compression:

Stored size: 549 Bytes

Contents

class MLS::Property::DateTime < MLS::Property
  
  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

102 entries across 102 versions & 1 rubygems

Version Path
mls-0.2.21 lib/mls/properties/datetime.rb
mls-0.2.20 lib/mls/properties/datetime.rb
mls-0.2.19 lib/mls/properties/datetime.rb
mls-0.2.18 lib/mls/properties/datetime.rb
mls-0.2.17 lib/mls/properties/datetime.rb
mls-0.2.16 lib/mls/properties/datetime.rb
mls-0.2.15 lib/mls/properties/datetime.rb
mls-0.2.14 lib/mls/properties/datetime.rb
mls-0.2.13 lib/mls/properties/datetime.rb
mls-0.2.12 lib/mls/properties/datetime.rb
mls-0.2.11 lib/mls/properties/datetime.rb
mls-0.2.9.1 lib/mls/properties/datetime.rb
mls-0.2.10 lib/mls/properties/datetime.rb
mls-0.2.9 lib/mls/properties/datetime.rb
mls-0.2.8.2 lib/mls/properties/datetime.rb
mls-0.2.8.1 lib/mls/properties/datetime.rb
mls-0.2.8 lib/mls/properties/datetime.rb
mls-0.2.7 lib/mls/properties/datetime.rb
mls-0.2.6 lib/mls/properties/datetime.rb
mls-0.2.5 lib/mls/properties/datetime.rb