diff options
author | Josua Schmid <josua.schmid@renuo.ch> | 2016-10-19 18:43:57 +0200 |
---|---|---|
committer | Josua Schmid <josua.schmid@renuo.ch> | 2016-10-20 10:49:59 +0200 |
commit | fc72d6815ad6ed447f1aea2dd98579305ea1cca4 (patch) | |
tree | 47d18f722d002f02af59702cbe630bbeb7ac083e /activesupport/lib/active_support | |
parent | 125ecfbbff339c25ff81fdb48739e603b66ce406 (diff) | |
download | rails-fc72d6815ad6ed447f1aea2dd98579305ea1cca4.tar.gz rails-fc72d6815ad6ed447f1aea2dd98579305ea1cca4.tar.bz2 rails-fc72d6815ad6ed447f1aea2dd98579305ea1cca4.zip |
Fix copy_time_to: Copy nsec instead of usec
`copy_time_to` is a helper function for date and time calculations.
It's being used by `prev_week`, `next_week` and `prev_weekday` to keep
the time fraction when jumping around between days.
Previously the nanoseconds part was lost during the operation. This
lead to problems in practice if you were using the `end_of_day`
calculation. Resulting in the time fraction of `end_of_day` not being
the same as next week's `end_of_day`.
With this fix `copy_time_to` doesn't forget the `nsec` digits.
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_and_time/calculations.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb index c614f14289..f2ba7fdda5 100644 --- a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb @@ -334,7 +334,7 @@ module DateAndTime end def copy_time_to(other) - other.change(hour: hour, min: min, sec: sec, usec: try(:usec)) + other.change(hour: hour, min: min, sec: sec, nsec: try(:nsec)) end end end |