diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-11 21:38:49 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-11 21:38:49 -0200 |
commit | 64281fb6e742fddd4a1f67abfe5554a84349e8b7 (patch) | |
tree | fc04e7c654e18e33ef474d630a272d349b687bd4 /activesupport/lib/active_support/core_ext | |
parent | 87a7e8752dcba5179f75a77b000d2e7eec29c736 (diff) | |
download | rails-64281fb6e742fddd4a1f67abfe5554a84349e8b7.tar.gz rails-64281fb6e742fddd4a1f67abfe5554a84349e8b7.tar.bz2 rails-64281fb6e742fddd4a1f67abfe5554a84349e8b7.zip |
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.
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/conversions.rb | 3 |
1 files changed, 2 insertions, 1 deletions
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 <tt>to_s</tt>. |