mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
TimeWithZone #in_time_zone returns +self+ if zone argument is the same as #time_zone
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8853 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* TimeWithZone #in_time_zone returns +self+ if zone argument is the same as #time_zone [Geoff Buesing]
|
||||
|
||||
* Adding TimeWithZone #to_a, #to_f, #to_i, #httpdate, #rfc2822 [Geoff Buesing]
|
||||
|
||||
* Pruning unneeded TimeWithZone#change_time_zone_to_current [Geoff Buesing]
|
||||
|
||||
@@ -29,6 +29,7 @@ module ActiveSupport
|
||||
|
||||
# Returns the simultaneous time in the specified zone
|
||||
def in_time_zone(new_zone)
|
||||
return self if time_zone == new_zone
|
||||
utc.in_time_zone(new_zone)
|
||||
end
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ uses_tzinfo 'TimeWithZoneTest' do
|
||||
def test_in_time_zone
|
||||
assert_equal ActiveSupport::TimeWithZone.new(@utc, TimeZone['Alaska']), @twz.in_time_zone('Alaska')
|
||||
end
|
||||
|
||||
def test_in_time_zone_with_new_zone_equal_to_old_zone_does_not_create_new_object
|
||||
assert_equal @twz.object_id, @twz.in_time_zone(TimeZone['Eastern Time (US & Canada)']).object_id
|
||||
end
|
||||
|
||||
def test_in_current_time_zone
|
||||
Time.use_zone 'Alaska' do
|
||||
|
||||
Reference in New Issue
Block a user