module MongoMapper::Extensions::Date
Public Instance Methods
from_mongo(value)
click to toggle source
# File lib/mongo_mapper/extensions/date.rb, line 16 def from_mongo(value) value.to_date if value end
to_mongo(value)
click to toggle source
# File lib/mongo_mapper/extensions/date.rb, line 5 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