Module: Mongoid::Extensions::TimeConversions

Included in:
Date, DateTime, Time
Defined in:
lib/mongoid/extensions/time_conversions.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#get(value) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/mongoid/extensions/time_conversions.rb', line 10

def get(value)
  return nil if value.blank?
  if Mongoid::Config.instance.use_utc?
    value
  else
    value.getlocal
  end
end

#set(value) ⇒ Object



4
5
6
7
8
# File 'lib/mongoid/extensions/time_conversions.rb', line 4

def set(value)
  return nil if value.blank?
  time = convert_to_time(value)
  strip_milliseconds(time).utc
end