From 250f04026167498d84bf8e751fe429a47e2d8ad7 Mon Sep 17 00:00:00 2001 From: Levin Alexander Date: Mon, 26 Jan 2009 16:10:41 +0100 Subject: [PATCH] make TimeWithZone#to_formatted_s an alias to TimeWithZone#to_s --- activesupport/lib/active_support/time_with_zone.rb | 1 + activesupport/test/core_ext/time_with_zone_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 1a59b2a..73aafc6 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -155,6 +155,7 @@ module ActiveSupport "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby 1.9 Time#to_s format end end + alias_method :to_formatted_s, :to_s # Replaces %Z and %z directives with +zone+ and +formatted_offset+, respectively, before passing to # Time#strftime, so that zone information is correct diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index 4dc1fec..d0bb36e 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -93,6 +93,12 @@ class TimeWithZoneTest < Test::Unit::TestCase end end + def test_to_formatted_s + silence_warnings do # silence warnings raised by tzinfo gem + assert_equal '1999-12-31 19:00:00 -0500', @twz.to_formatted_s + end + end + def test_to_s_db silence_warnings do # silence warnings raised by tzinfo gem assert_equal '2000-01-01 00:00:00', @twz.to_s(:db) -- 1.6.0.4