aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time
diff options
context:
space:
mode:
authorGilad Zohari <gzohari@gmail.com>2013-07-31 21:02:01 +0300
committerGilad Zohari <gzohari@gmail.com>2013-08-01 00:27:25 +0300
commit3102a9aa4cfd747e116adc12dce6f5faf1453ea9 (patch)
tree241ba59b12fc66ad4ce1b2ddd3bba722c0cbcc94 /activesupport/lib/active_support/core_ext/date_time
parent742d1f2eda24dd411e018835680645d3921883f5 (diff)
downloadrails-3102a9aa4cfd747e116adc12dce6f5faf1453ea9.tar.gz
rails-3102a9aa4cfd747e116adc12dce6f5faf1453ea9.tar.bz2
rails-3102a9aa4cfd747e116adc12dce6f5faf1453ea9.zip
Refactor Date, Time, DateTime timezone methods
Similar implementations of #in_time_zone exists for Date, Time and DateTime so method is extracted into its own module. Also some logic is extracted into private method.
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/zones.rb23
1 files changed, 2 insertions, 21 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/zones.rb b/activesupport/lib/active_support/core_ext/date_time/zones.rb
index 01a627f8af..c39f358395 100644
--- a/activesupport/lib/active_support/core_ext/date_time/zones.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/zones.rb
@@ -1,25 +1,6 @@
require 'date'
-require 'active_support/core_ext/time/zones'
+require 'active_support/core_ext/date_and_time/zones'
class DateTime
- # Returns the simultaneous time in <tt>Time.zone</tt>.
- #
- # Time.zone = 'Hawaii' # => 'Hawaii'
- # DateTime.new(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00
- #
- # This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt>
- # as the local zone instead of the operating system's time zone.
- #
- # You can also pass in a TimeZone instance or string that identifies a TimeZone
- # as an argument, and the conversion will be based on that zone instead of
- # <tt>Time.zone</tt>.
- #
- # DateTime.new(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
- def in_time_zone(zone = ::Time.zone)
- if zone
- ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.find_zone!(zone))
- else
- self
- end
- end
+ include DateAndTime::Zones
end