New pull request because of incorrect pushes in the previous pull request.
One line for both REE and 1.9.3, instead of version dependent solution. Basically same as #443
Fixes time to round to 3 digits on float. (mongodb driver has same pr…
…ecision). Makes comparing times possible before/after save. Still keeps milliseconds.
Fixes for ruby versions prior to 1.9
Merge remote-tracking branch 'upstream/master' into timefix
Merge branch 'master' into timefix
Timefix for both 1.9.3 and REE using iso8601 instead of round.
Travis fails on compound keys. Time tests and extensions passes.
iso8601 is ridiculously slow. Given that the core type conversions are core to read/write performance, I'd be really hesitant to endorse that solution.
Additionally, using #round explicitly breaks this test, which was added in response to a bugfix. If we're to preserve this test, then any millisecond-rounding feature must perform a floor rather than a round.
I'd propose just:
- at(time.to_f).utc if time # ensure milliseconds are preserved with to_f (issue #308)
+ at((time.to_f * 1000.0).to_i / 1000.0).utc if time
This isn't as fast as #round, but it's cross-version compliant and doesn't break any tests.
When performing Time#to_mongo, round times off to milliseconds and di…
…scard microseconds. Closes #455.
Sorry about not answering before. I agree that it is slow using iso8601...
I think the pull you just did is perfect, as 1.8.x is end of life.
Initial pull request was similar to your proposal, however, it was removed as it was not 1.8.x compatible.
Discussion here, about why it was changed.
Thanks for fixing this in master 👍
I was about to go mongoid on a project, but now I got a reason to stick with MM!