Class: DateTime

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo_odm/core_ext/conversions.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) type_cast(value)



164
165
166
167
# File 'lib/mongo_odm/core_ext/conversions.rb', line 164

def self.type_cast(value)
  return nil if value.nil?
  value.to_datetime
end

Instance Method Details

- (Object) to_mongo



169
170
171
172
# File 'lib/mongo_odm/core_ext/conversions.rb', line 169

def to_mongo
  datetime = self.utc
  Time.utc(datetime.year, datetime.month, datetime.day, datetime.hour, datetime.min, datetime.sec)
end