jnunemaker/mongomapper — pull request #443 by leifcr (2012-08-16 09:23:35+00:00)
Title: Fixes Time objects to have same time as when saved in mongodb

Rounds all times float precision to three digits, so time is same as saved in DB when set. This makes comparing times easier. Milliseconds is still kept, but nanoseconds are rounded. Nanoseconds are not stored in MongoDB time objects, so it should not make a difference to applications. Custom storage must be used anyhow if nanosecond precision is needed in mongodb data.

Before patch: (using mmconsole)
```ruby
class Thing
include MongoMapper::Document
key :date, Time
end

thing = Thing.new
thing.date = Time.now
thing.date.to_f
# => 1345106294.1552615
thing.save
thing.reload
thing.date.to_f
# => 1345106294.155
# Not equal before/after save
```

After patch:
```ruby
class Thing
include MongoMapper::Document
key :date, Time
end

thing = Thing.new
thing.date = Time.now
thing.date.nsec
# => 921000000
thing.date.to_f
# => 1345105899.921
thing.save
thing.reload
thing.date.to_f
# => 1345105899.921
#equal before/after save
```