lib/mongo_mapper/extensions/time.rb in mongo_mapper-0.11.0 vs lib/mongo_mapper/extensions/time.rb in mongo_mapper-0.11.1
- old
+ new
@@ -6,11 +6,10 @@
if value.nil? || value == ''
nil
else
time_class = ::Time.try(:zone).present? ? ::Time.zone : ::Time
time = value.is_a?(::Time) ? value : time_class.parse(value.to_s)
- # strip milliseconds as Ruby does micro and bson does milli and rounding rounded wrong
- at(time.to_i).utc if time
+ at(time.to_f).utc if time # ensure milliseconds are preserved with to_f (issue #308)
end
end
def from_mongo(value)
if ::Time.try(:zone).present? && value.present?
\ No newline at end of file