aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/time/conversions.rb1
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb1
3 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index a4f286b42f..b1747b3ed0 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added Time#to_s(:time) which will just return H:M, like 17:44 [DHH]
+
* Add Module#attr_accessor_with_default to initialize value of attribute before setting it. Closes #6538. [Stuart Halloway, Marcel Molina Jr.]
* Hash#to_xml handles keys with the same name as Kernel methods. #6613 [Catfish]
diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb
index c141d082e2..6e8dae21f1 100644
--- a/activesupport/lib/active_support/core_ext/time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/time/conversions.rb
@@ -8,6 +8,7 @@ module ActiveSupport #:nodoc:
module Conversions
DATE_FORMATS = {
:db => "%Y-%m-%d %H:%M:%S",
+ :time => "%H:%M",
:short => "%d %b %H:%M",
:long => "%B %d, %Y %H:%M",
:rfc822 => "%a, %d %b %Y %H:%M:%S %z"
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 657be1aecc..8d14be38c1 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -272,6 +272,7 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
time = Time.local(2005, 2, 21, 17, 44, 30)
assert_equal "2005-02-21 17:44:30", time.to_s(:db)
assert_equal "21 Feb 17:44", time.to_s(:short)
+ assert_equal "17:44", time.to_s(:time)
assert_equal "February 21, 2005 17:44", time.to_s(:long)
time = Time.utc(2005, 2, 21, 17, 44, 30)