aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorAgis- <corestudiosinc@gmail.com>2014-09-01 15:54:29 +0300
committerAgis- <corestudiosinc@gmail.com>2014-09-04 22:21:38 +0300
commit57b2c371f03982813f6dc2e7f07467b4fca3a6ce (patch)
tree47e244ea91e21fedd889d7a934d381200635e3f6 /activesupport/lib/active_support
parent703a2e8da1d3a68b3902d9024c6f0d1cd32435aa (diff)
downloadrails-57b2c371f03982813f6dc2e7f07467b4fca3a6ce.tar.gz
rails-57b2c371f03982813f6dc2e7f07467b4fca3a6ce.tar.bz2
rails-57b2c371f03982813f6dc2e7f07467b4fca3a6ce.zip
Time#change throws exception with an out-of-range :usec
https://github.com/rails/rails/commit/98b46bf5e201307cae56ee14bf41363a539779c5 did not properly handled out-of-range `:usec`s. Passing a `:usec` that's out of range now throws an `ArgumentError` as it should. Fixes #16759.
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 89cd7516cd..6a7bf7445a 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -87,6 +87,7 @@ class Time
elsif zone
::Time.local(new_year, new_month, new_day, new_hour, new_min, new_sec, new_usec)
else
+ raise ArgumentError, 'argument out of range' if new_usec > 999999
::Time.new(new_year, new_month, new_day, new_hour, new_min, new_sec + (new_usec.to_r / 1000000), utc_offset)
end
end