Convert the object from its mongo friendly ruby type to this type.
@example Demongoize the object.
Date.demongoize(object)
@param [ Time ] object The time from Mongo.
@return [ Date ] The object as a date.
@since 3.0.0
# File lib/mongoid/extensions/date.rb, line 45 def demongoize(object) ::Date.new(object.year, object.month, object.day) if object end
Turn the object from the ruby type we deal with to a Mongo friendly type.
@example Mongoize the object.
Date.mongoize("2012-1-1")
@param [ Object ] object The object to mongoize.
@return [ Time ] The object mongoized.
@since 3.0.0
# File lib/mongoid/extensions/date.rb, line 60 def mongoize(object) unless object.blank? begin time = object.__mongoize_time__ ::Time.utc(time.year, time.month, time.day) rescue ArgumentError EPOCH end end end