Class: Date
Class Method Summary collapse
Class Method Details
.from_mongo(value) ⇒ Object
59 60 61 |
# File 'lib/novelys_mongo_mapper/support.rb', line 59 def self.from_mongo(value) value.to_date if value.present? end |
.to_mongo(value) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/novelys_mongo_mapper/support.rb', line 48 def self.to_mongo(value) if value.nil? || value == '' nil else date = value.is_a?(Date) || value.is_a?(Time) ? value : Date.parse(value.to_s) Time.utc(date.year, date.month, date.day) end rescue nil end |