aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJosh Pencheon <josh.pencheon@googlemail.com>2018-05-30 13:42:07 +0100
committerJosh Pencheon <josh.pencheon@googlemail.com>2018-05-30 13:47:39 +0100
commit45762cec03ee1218d5a257d2920678f37bd9bdb4 (patch)
tree3f0e6c688fc5e032c0e50551552a1b13a3f2c2cd /activesupport/lib
parent0d7f13a622259ccafe3822d4e4eb7177107974ab (diff)
downloadrails-45762cec03ee1218d5a257d2920678f37bd9bdb4.tar.gz
rails-45762cec03ee1218d5a257d2920678f37bd9bdb4.tar.bz2
rails-45762cec03ee1218d5a257d2920678f37bd9bdb4.zip
Allow Time.zone.at to receive a second argument
For parity with Ruby's Time::at
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 5f709c5fd9..792c88415c 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -354,8 +354,13 @@ module ActiveSupport
# Time.zone = 'Hawaii' # => "Hawaii"
# Time.utc(2000).to_f # => 946684800.0
# Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00
- def at(secs)
- Time.at(secs).utc.in_time_zone(self)
+ #
+ # A second argument can be supplied to specify sub-second precision.
+ #
+ # Time.zone = 'Hawaii' # => "Hawaii"
+ # Time.at(946684800, 123456.789).nsec # => 123456789
+ def at(*args)
+ Time.at(*args).utc.in_time_zone(self)
end
# Method for creating new ActiveSupport::TimeWithZone instance in time zone