From 64281fb6e742fddd4a1f67abfe5554a84349e8b7 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 11 Dec 2012 21:38:49 -0200 Subject: Add :nsec format only for Ruby 1.9 Ruby 1.8 does not support this format in Time, so the format will only be added to the available date formats on Ruby 1.9. Changelog entry was changed to explain that as well. --- activesupport/lib/active_support/core_ext/time/conversions.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb index cb175e8751..d180e1e588 100644 --- a/activesupport/lib/active_support/core_ext/time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/time/conversions.rb @@ -6,7 +6,6 @@ class Time DATE_FORMATS = { :db => "%Y-%m-%d %H:%M:%S", :number => "%Y%m%d%H%M%S", - :nsec => '%Y%m%d%H%M%S%9N', :time => "%H:%M", :short => "%d %b %H:%M", :long => "%B %d, %Y %H:%M", @@ -14,6 +13,8 @@ class Time :rfc822 => lambda { |time| time.strftime("%a, %d %b %Y %H:%M:%S #{time.formatted_offset(false)}") } } + DATE_FORMATS[:nsec] = '%Y%m%d%H%M%S%9N' if RUBY_VERSION >= '1.9' + # Converts to a formatted string. See DATE_FORMATS for builtin formats. # # This method is aliased to to_s. -- cgit v1.2.3