aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-01-23 02:11:00 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-01-23 02:11:00 +0000
commit2e7b2f03448e5759113ce0c182ed99897342c7a9 (patch)
treeec35655e12924d0075abc7a0e36aa1eea1e6e545
parent022d9f7ce6d1237c4103a2aed561220e1c0f4dcc (diff)
downloadrails-2e7b2f03448e5759113ce0c182ed99897342c7a9.tar.gz
rails-2e7b2f03448e5759113ce0c182ed99897342c7a9.tar.bz2
rails-2e7b2f03448e5759113ce0c182ed99897342c7a9.zip
Adding alternate_utc_string option to TimeZone#formatted_offset. Removing unneeded TimeZone#offset
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8697 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb12
-rw-r--r--activesupport/test/time_zone_test.rb6
3 files changed, 10 insertions, 10 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index fa3e94dbf2..d2d8353cd8 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Adding alternate_utc_string option to TimeZone#formatted_offset. Removing unneeded TimeZone#offset. [Geoff Buesing]
+
* Introduce ActiveSupport::TimeWithZone, for wrapping Time instances with a TimeZone. Introduce instance methods to Time for creating TimeWithZone instances, and class methods for managing a global time zone. [Geoff Buesing]
* Replace non-dst-aware TimeZone class with dst-aware class from tzinfo_timezone plugin. TimeZone#adjust and #unadjust are no longer available; tzinfo gem must now be present in order to perform time zone calculations, via #local_to_utc and #utc_to_local methods. [Geoff Buesing]
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 92d6febda3..689ba5a6e5 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -156,17 +156,9 @@ class TimeZone
end
# Returns the offset of this time zone as a formatted string, of the
- # format "+HH:MM". If the offset is zero, this returns the empty
- # string. If +colon+ is false, a colon will not be inserted into the
- # result.
- def formatted_offset(colon=true)
- utc_offset == 0 ? '' : offset(colon)
- end
-
- # Returns the offset of this time zone as a formatted string, of the
# format "+HH:MM".
- def offset(colon=true)
- utc_offset.to_utc_offset_s(colon)
+ def formatted_offset(colon=true, alternate_utc_string = nil)
+ utc_offset == 0 && alternate_utc_string || utc_offset.to_utc_offset_s(colon)
end
# Compare this time zone to the parameter. The two are comapred first on
diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb
index 939d928b3e..8dea36f20e 100644
--- a/activesupport/test/time_zone_test.rb
+++ b/activesupport/test/time_zone_test.rb
@@ -77,6 +77,12 @@ class TimeZoneTest < Test::Unit::TestCase
assert_equal "-0500", zone.formatted_offset(false)
end
+ def test_formatted_offset_zero
+ zone = TimeZone['London']
+ assert_equal "+00:00", zone.formatted_offset
+ assert_equal "UTC", zone.formatted_offset(true, 'UTC')
+ end
+
def test_zone_compare
zone1 = TimeZone['Central Time (US & Canada)'] # offset -0600
zone2 = TimeZone['Eastern Time (US & Canada)'] # offset -0500