aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_ext_test.rb
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-01-23 02:46:47 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-01-23 02:46:47 +0000
commitabb24b484fcb306be17dd06a8a2d12ca5a035aeb (patch)
tree96de38f875c4048b27e6fae61de0d00111a66014 /activesupport/test/core_ext/time_ext_test.rb
parent2e7b2f03448e5759113ce0c182ed99897342c7a9 (diff)
downloadrails-abb24b484fcb306be17dd06a8a2d12ca5a035aeb.tar.gz
rails-abb24b484fcb306be17dd06a8a2d12ca5a035aeb.tar.bz2
rails-abb24b484fcb306be17dd06a8a2d12ca5a035aeb.zip
Adding Time and DateTime #formatted_offset, for outputting +HH:MM utc offset strings with cross-platform consistency
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8698 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 5970411233..e9c7a1ed79 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -409,6 +409,21 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
def test_acts_like_time
assert Time.new.acts_like_time?
end
+
+ def test_formatted_offset_with_utc
+ assert_equal '+00:00', Time.utc(2000).formatted_offset
+ assert_equal '+0000', Time.utc(2000).formatted_offset(false)
+ assert_equal 'UTC', Time.utc(2000).formatted_offset(true, 'UTC')
+ end
+
+ def test_formatted_offset_with_local
+ with_timezone 'US/Eastern' do
+ assert_equal '-05:00', Time.local(2000).formatted_offset
+ assert_equal '-0500', Time.local(2000).formatted_offset(false)
+ assert_equal '-04:00', Time.local(2000, 7).formatted_offset
+ assert_equal '-0400', Time.local(2000, 7).formatted_offset(false)
+ end
+ end
protected
def with_timezone(new_tz = 'US/Eastern')