Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #6376 from jgaskins/timestamp-microseconds

Increase numeric-timestamp precision to nanoseconds
Conflicts:
	activesupport/lib/active_support/core_ext/time/conversions.rb
  • Loading branch information...
commit 09a8b146ef9e038d6036a21fb4f80e15f9ee969a 1 parent cc99580
Jeremy Kemper jeremy authored rafaelfranca committed
2  activerecord/lib/active_record/integration.rb
View
@@ -39,7 +39,7 @@ def cache_key
when new_record?
"#{self.class.model_name.cache_key}/new"
when timestamp = self[:updated_at]
- timestamp = timestamp.utc.to_s(:number)
+ timestamp = timestamp.utc.to_s(:nsec)
"#{self.class.model_name.cache_key}/#{id}-#{timestamp}"
else
"#{self.class.model_name.cache_key}/#{id}"
2  activerecord/test/cases/base_test.rb
View
@@ -2151,7 +2151,7 @@ def test_cache_key_for_existing_record_is_not_timezone_dependent
def test_cache_key_format_for_existing_record_with_updated_at
dev = Developer.first
- assert_equal "developers/#{dev.id}-#{dev.updated_at.utc.to_s(:number)}", dev.cache_key
+ assert_equal "developers/#{dev.id}-#{dev.updated_at.utc.to_s(:nsec)}", dev.cache_key
end
def test_cache_key_format_for_existing_record_with_nil_updated_at
1  activesupport/lib/active_support/core_ext/time/conversions.rb
View
@@ -6,6 +6,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",
4 activesupport/test/core_ext/time_ext_test.rb
View
@@ -538,12 +538,14 @@ def test_next_week_near_daylight_end
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
Please sign in to comment.
Something went wrong with that request. Please try again.