mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added Numeric#in_milliseconds, like 1.hour.in_milliseconds, so we can feed them to JavaScript functions like getTime().
This commit is contained in:
parent
db41eb8a6e
commit
423249504a
3 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
* Added Numeric#in_milliseconds, like 1.hour.in_milliseconds, so we can feed them to JavaScript functions like getTime().
|
||||
|
||||
*DHH*
|
||||
|
||||
* Calling ActiveSupport::JSON.decode with unsupported options now raises an error.
|
||||
|
||||
*Godfrey Chan*
|
||||
|
|
|
@ -76,4 +76,10 @@ class Numeric
|
|||
|
||||
# Reads best without arguments: 10.minutes.from_now
|
||||
alias :from_now :since
|
||||
|
||||
# Used with the standard time durations, like 1.hour.in_milliseconds --
|
||||
# so we can feed them to JavaScript functions like getTime().
|
||||
def in_milliseconds
|
||||
self * 1000
|
||||
end
|
||||
end
|
||||
|
|
|
@ -440,4 +440,8 @@ class NumericExtFormattingTest < ActiveSupport::TestCase
|
|||
assert_equal BigDecimal, BigDecimal("1000010").class
|
||||
assert_equal '1 Million', BigDecimal("1000010").to_s(:human)
|
||||
end
|
||||
|
||||
def test_in_milliseconds
|
||||
assert_equal 10_000, 10.seconds.in_milliseconds
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue