mirror of
https://github.com/github/rails.git
synced 2026-01-29 08:18:03 -05:00
Time #in_current_time_zone and #change_time_zone_to_current return self when Time.zone is nil
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8708 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Time #in_current_time_zone and #change_time_zone_to_current return self when Time.zone is nil [Geoff Buesing]
|
||||
|
||||
* Remove unneeded #to_datetime_default_s alias for DateTime#to_s, given that we inherit a #to_default_s from Date that does exactly the same thing [Geoff Buesing]
|
||||
|
||||
* Refactor Time and DateTime #to_formatted_s: use ternary instead of nested if/else [Geoff Buesing]
|
||||
|
||||
@@ -46,7 +46,7 @@ module ActiveSupport #:nodoc:
|
||||
|
||||
# Returns the simultaneous time in Time.zone
|
||||
def in_current_time_zone
|
||||
in_time_zone(::Time.zone)
|
||||
::Time.zone ? in_time_zone(::Time.zone) : self
|
||||
end
|
||||
|
||||
# Replaces the existing zone; leaves time value intact. Examples:
|
||||
@@ -60,7 +60,7 @@ module ActiveSupport #:nodoc:
|
||||
|
||||
# Replaces the existing zone to Time.zone; leaves time value intact
|
||||
def change_time_zone_to_current
|
||||
change_time_zone(::Time.zone)
|
||||
::Time.zone ? change_time_zone(::Time.zone) : self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -170,8 +170,8 @@ uses_tzinfo 'TimeWithZoneTest' do
|
||||
assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @dt.in_current_time_zone.inspect
|
||||
end
|
||||
with_time_zone nil do
|
||||
assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @t.in_current_time_zone.inspect
|
||||
assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @dt.in_current_time_zone.inspect
|
||||
assert_equal @t, @t.in_current_time_zone
|
||||
assert_equal @dt, @dt.in_current_time_zone
|
||||
end
|
||||
end
|
||||
|
||||
@@ -196,8 +196,8 @@ uses_tzinfo 'TimeWithZoneTest' do
|
||||
assert_equal 'Sat, 01 Jan 2000 00:00:00 HST -10:00', @dt.change_time_zone_to_current.inspect
|
||||
end
|
||||
with_time_zone nil do
|
||||
assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @t.change_time_zone_to_current.inspect
|
||||
assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @dt.change_time_zone_to_current.inspect
|
||||
assert_equal @t, @t.change_time_zone_to_current
|
||||
assert_equal @dt, @dt.change_time_zone_to_current
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user