aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-17 10:19:33 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-17 10:19:33 -0700
commit8f4ee48687b7b4c2df123a078923f3d5b3b065ec (patch)
treed7cabeef7412ae0da3b0539e00a477f51c0f5499 /activerecord/lib/active_record/connection_adapters
parentcbbf6bf87c9220c3a21f90c2dcdeea044f583d54 (diff)
parent53ca22f2e11cd3050d75385bc31b6bb5055a2738 (diff)
downloadrails-8f4ee48687b7b4c2df123a078923f3d5b3b065ec.tar.gz
rails-8f4ee48687b7b4c2df123a078923f3d5b3b065ec.tar.bz2
rails-8f4ee48687b7b4c2df123a078923f3d5b3b065ec.zip
Merge pull request #7352 from aripollak/microsecond-timestamp
Fix occasional microsecond conversion inaccuracy
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/column.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb
index b9045cf1e7..1445bb3b2f 100644
--- a/activerecord/lib/active_record/connection_adapters/column.rb
+++ b/activerecord/lib/active_record/connection_adapters/column.rb
@@ -208,7 +208,7 @@ module ActiveRecord
# '0.123456' -> 123456
# '1.123456' -> 123456
def microseconds(time)
- ((time[:sec_fraction].to_f % 1) * 1_000_000).to_i
+ time[:sec_fraction] ? (time[:sec_fraction] * 1_000_000).to_i : 0
end
def new_date(year, mon, mday)
@@ -233,7 +233,7 @@ module ActiveRecord
# Doesn't handle time zones.
def fast_string_to_time(string)
if string =~ Format::ISO_DATETIME
- microsec = ($7.to_f * 1_000_000).to_i
+ microsec = ($7.to_r * 1_000_000).to_i
new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec
end
end