Skip to content
This repository
Browse code

Make TimeWithZone#to_formatted_s an alias to TimeWithZone#to_s [#1796

…state:resolved]
  • Loading branch information...
commit 18d636934492fd657a67dc980b8556bcf69a818d 1 parent 5fbacde
Levin Alexander levinalex authored gbuesing committed
2  activesupport/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *Edge*
2 2
  3 +* Make TimeWithZone#to_formatted_s an alias to TimeWithZone#to_s #1796 [Levin Alexander]
  4 +
3 5 * Introduce Array.wrap(foo) to wrap the argument in an array unless it's already an array. Wraps nil as an empty array. Use instead of Array(foo) and foo.to_a since they treat String as Enumerable. [Jeremy Kemper]
4 6
5 7
1  activesupport/lib/active_support/time_with_zone.rb
@@ -155,6 +155,7 @@ def to_s(format = :default)
155 155 "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby 1.9 Time#to_s format
156 156 end
157 157 end
  158 + alias_method :to_formatted_s, :to_s
158 159
159 160 # Replaces <tt>%Z</tt> and <tt>%z</tt> directives with +zone+ and +formatted_offset+, respectively, before passing to
160 161 # Time#strftime, so that zone information is correct
6 activesupport/test/core_ext/time_with_zone_test.rb
@@ -93,6 +93,12 @@ def test_to_s
93 93 end
94 94 end
95 95
  96 + def test_to_formatted_s
  97 + silence_warnings do # silence warnings raised by tzinfo gem
  98 + assert_equal '1999-12-31 19:00:00 -0500', @twz.to_formatted_s
  99 + end
  100 + end
  101 +
96 102 def test_to_s_db
97 103 silence_warnings do # silence warnings raised by tzinfo gem
98 104 assert_equal '2000-01-01 00:00:00', @twz.to_s(:db)

1 comment on commit 18d6369

Levin Alexander

thank you

Please sign in to comment.
Something went wrong with that request. Please try again.