module Mongoid::Extensions::TimeWithZone

def __mongoize_time__

Returns:
  • (ActiveSupport::TimeWithZone) - self.
def __mongoize_time__
  self
end

def _bson_to_i

See https://jira.mongodb.org/browse/MONGOID-5491.
should be removed from here when the minimum BSON version is 5+.
This code is copied from Time class extension in bson-ruby gem. It
def _bson_to_i
  return super if defined?(super)
  # Workaround for JRuby's #to_i rounding negative timestamps up
  # rather than down (https://github.com/jruby/jruby/issues/6104)
  if BSON::Environment.jruby?
    (self - usec.to_r/1000000).to_i
  else
    to_i
  end
end

def mongoize

Returns:
  • (Time) - The object mongoized.

Other tags:
    Example: Mongoize the object. -
def mongoize
  ::ActiveSupport::TimeWithZone.mongoize(self)
end