aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-17 03:04:11 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-17 03:04:11 +0530
commit0ab30637dd5bc7536c5accd66b45ce0263134a14 (patch)
tree7fd200d06318208ca26cd2a5bbdcc320248c74bb /activerecord/lib
parentcd90dcb1bde5c411a55bcec97597a8fe22b56a5d (diff)
downloadrails-0ab30637dd5bc7536c5accd66b45ce0263134a14.tar.gz
rails-0ab30637dd5bc7536c5accd66b45ce0263134a14.tar.bz2
rails-0ab30637dd5bc7536c5accd66b45ce0263134a14.zip
Revert "Fix #microseconds conversion and #fast_string_to_time"
This reverts commit 717a2941e15b32d07cc456bb0d81742ecfc5b4a3. Bunch of failures when running postgresql tests.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index 5e8a01644d..520f3c8c0c 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -13,7 +13,6 @@ module ActiveRecord
module Format
ISO_DATE = /\A(\d{4})-(\d\d)-(\d\d)\z/
ISO_DATETIME = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/
- NEW_ISO_DATETIME = /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(?:\.(\d+))?\z/
end
attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale
@@ -168,11 +167,10 @@ module ActiveRecord
end
protected
- # Rational(123456, 1_000_000) -> 123456
- # The sec_fraction component returned by Date._parse is a Rational fraction of a second or nil
- # NB: This method is optimized for performance by immediately converting away from Rational.
+ # '0.123456' -> 123456
+ # '1.123456' -> 123456
def microseconds(time)
- ((time[:sec_fraction].to_f % 1) * 1_000_000).round
+ ((time[:sec_fraction].to_f % 1) * 1_000_000).to_i
end
def new_date(year, mon, mday)
@@ -196,8 +194,9 @@ module ActiveRecord
# Doesn't handle time zones.
def fast_string_to_time(string)
- if md = Format::NEW_ISO_DATETIME.match(string)
- new_time *md.to_a[1..7].map(&:to_i)
+ if string =~ Format::ISO_DATETIME
+ microsec = ($7.to_f * 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