module Mongoid::Extensions::Date

Adds type-casting behavior to Date class.

Public Instance Methods

__mongoize_time__() click to toggle source

Convert the date into a time.

@example Convert the date to a time.

Date.new(2018, 11, 1).__mongoize_time__
# => Thu, 01 Nov 2018 00:00:00 EDT -04:00

@return [ Time | ActiveSupport::TimeWithZone ] Local time in the

configured default time zone corresponding to local midnight of
this date.
# File lib/mongoid/extensions/date.rb, line 19
def __mongoize_time__
  ::Time.zone.local(year, month, day)
end
mongoize() click to toggle source

Turn the object from the ruby type we deal with to a Mongo friendly type.

@example Mongoize the object.

date.mongoize

@return [ Time ] The object mongoized.

# File lib/mongoid/extensions/date.rb, line 30
def mongoize
  ::Date.mongoize(self)
end