aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJamie Gaskins <jgaskins@gmail.com>2012-05-18 18:42:35 +0800
committerJamie Gaskins <jgaskins@gmail.com>2012-05-19 08:20:08 +0800
commit900dbc54f17500e14e481eab2ebf88acfc5448aa (patch)
treed34cc01afa34e5782eef3cdbcfee6fdc77c827e4 /activesupport
parent88949f8ac1759d07fe8502f863dac20f509163c3 (diff)
downloadrails-900dbc54f17500e14e481eab2ebf88acfc5448aa.tar.gz
rails-900dbc54f17500e14e481eab2ebf88acfc5448aa.tar.bz2
rails-900dbc54f17500e14e481eab2ebf88acfc5448aa.zip
Increase `AR#cache_key` precision to nanoseconds
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/time/conversions.rb1
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb4
2 files changed, 4 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 4f852fd780..10ca26acf2 100644
--- a/activesupport/lib/active_support/core_ext/time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/time/conversions.rb
@@ -5,6 +5,7 @@ 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',
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 4c1ed4b1ae..8f5fd79d7d 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -557,12 +557,14 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
end
def test_to_s
- time = Time.utc(2005, 2, 21, 17, 44, 30)
+ time = Time.utc(2005, 2, 21, 17, 44, 30.12345678901)
assert_equal time.to_default_s, time.to_s
assert_equal time.to_default_s, time.to_s(:doesnt_exist)
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 "20050221174430", time.to_s(:number)
+ assert_equal "20050221174430123456789", time.to_s(:nsec)
assert_equal "February 21, 2005 17:44", time.to_s(:long)
assert_equal "February 21st, 2005 17:44", time.to_s(:long_ordinal)
with_env_tz "UTC" do