Module: Mongoid::Extensions::Date

Defined in:
lib/mongoid/extensions/date.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

EPOCH =

Constant for epoch - used when passing invalid times.

::Date.new(1970, 1, 1)

Instance Method Summary collapse

Instance Method Details

#__mongoize_time__Time

Convert the date into a time.

Examples:

Convert the date to a time.

date.__mongoize_time__

Returns:

  • (Time)

    The converted time.

Since:

  • 3.0.0



17
18
19
# File 'lib/mongoid/extensions/date.rb', line 17

def __mongoize_time__
  ::Time.configured.local(year, month, day)
end

#mongoizeTime

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

Examples:

Mongoize the object.

date.mongoize

Returns:

  • (Time)

    The object mongoized.

Since:

  • 3.0.0



30
31
32
# File 'lib/mongoid/extensions/date.rb', line 30

def mongoize
  ::Date.mongoize(self)
end