aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time/zones.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-06-17 14:10:51 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-06-17 14:14:30 -0700
commit5ae7a9d31d6222b265013ab450f9d30b88113e69 (patch)
tree2e448230f3d8eb583a10d90075221ea449a9ae1f /activesupport/lib/active_support/core_ext/date_time/zones.rb
parent84d387bc0f3f3f6641b08d0ce40e924f09105c19 (diff)
downloadrails-5ae7a9d31d6222b265013ab450f9d30b88113e69.tar.gz
rails-5ae7a9d31d6222b265013ab450f9d30b88113e69.tar.bz2
rails-5ae7a9d31d6222b265013ab450f9d30b88113e69.zip
when the timezone is nil, a TimeWithZone object should not be constructed. [#4881 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time/zones.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/zones.rb2
1 files changed, 2 insertions, 0 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 98565e6750..6002d4ad2a 100644
--- a/activesupport/lib/active_support/core_ext/date_time/zones.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/zones.rb
@@ -12,6 +12,8 @@ class DateTime
#
# DateTime.new(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
def in_time_zone(zone = ::Time.zone)
+ return self unless zone
+
ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.__send__(:get_zone, zone))
end
end