Sha256: 4efc7f06351c46887bdda304101a550ab375b96ef88a2946ea952b9201e129d2
Contents?: true
Size: 548 Bytes
Versions: 10
Compression:
Stored size: 548 Bytes
Contents
# encoding: UTF-8 module MongoMapper module Extensions module Date def to_mongo(value) if value.nil? || (value.instance_of?(String) && '' === value) nil else date = value.instance_of?(::Date) || value.instance_of?(::Time) ? value : ::Date.parse(value.to_s) ::Time.utc(date.year, date.month, date.day) end rescue nil end def from_mongo(value) value.to_date if value end end end end class Date extend MongoMapper::Extensions::Date end
Version data entries
10 entries across 10 versions & 1 rubygems