diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2016-04-23 16:27:37 +0100 |
---|---|---|
committer | Andrew White <pixeltrix@users.noreply.github.com> | 2016-04-23 16:27:37 +0100 |
commit | f5dcc141ec19ae585326f5b424b81c0217a386c0 (patch) | |
tree | 58164a5e255d2d863a381e9d09571a178e04f0e2 /activesupport/lib/active_support/core_ext/date_time/calculations.rb | |
parent | c9c5788a527b70d7f983e2b4b47e3afd863d9f48 (diff) | |
parent | 941eee5c8ebb82f97434f93fb233502cbb4f8270 (diff) | |
download | rails-f5dcc141ec19ae585326f5b424b81c0217a386c0.tar.gz rails-f5dcc141ec19ae585326f5b424b81c0217a386c0.tar.bz2 rails-f5dcc141ec19ae585326f5b424b81c0217a386c0.zip |
Merge pull request #24700 from yui-knk/refactor_localtime
Move `DateTime#getlocal` to `/core_ext/date_time/calculations.rb`
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time/calculations.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_time/calculations.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index ac46f5ffe8..e6eaa02a60 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -152,6 +152,18 @@ class DateTime end alias_method :getutc, :utc + # Returns a <tt>Time.local()</tt> instance of the simultaneous time in your + # system's <tt>ENV['TZ']</tt> zone. + def localtime(utc_offset = nil) + utc = getutc + + Time.utc( + utc.year, utc.month, utc.day, + utc.hour, utc.min, utc.sec + utc.sec_fraction + ).getlocal(utc_offset) + end + alias_method :getlocal, :localtime + # Returns +true+ if <tt>offset == 0</tt>. def utc? offset == 0 |