diff options
author | Richard Schneeman <richard.schneeman+no-recruiters@gmail.com> | 2018-08-29 10:43:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-29 10:43:29 -0700 |
commit | 0d0f48a20a5885c51b4f5c32d039f10960515f4f (patch) | |
tree | 93748ed6b8141db8f939c0e3c3fb5d967ad938f4 /activemodel/lib/active_model/type/helpers | |
parent | 96d7504da9273e8fcd18823173537678f4cf2321 (diff) | |
parent | e81b0ddd7ac9fe6de0ec65a2aa59224108344470 (diff) | |
download | rails-0d0f48a20a5885c51b4f5c32d039f10960515f4f.tar.gz rails-0d0f48a20a5885c51b4f5c32d039f10960515f4f.tar.bz2 rails-0d0f48a20a5885c51b4f5c32d039f10960515f4f.zip |
Merge pull request #33750 from schneems/schneems/time_value
Faster time_value.rb
Diffstat (limited to 'activemodel/lib/active_model/type/helpers')
-rw-r--r-- | activemodel/lib/active_model/type/helpers/time_value.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/type/helpers/time_value.rb b/activemodel/lib/active_model/type/helpers/time_value.rb index cb6aa67a9d..da56073436 100644 --- a/activemodel/lib/active_model/type/helpers/time_value.rb +++ b/activemodel/lib/active_model/type/helpers/time_value.rb @@ -70,7 +70,13 @@ module ActiveModel # Doesn't handle time zones. def fast_string_to_time(string) if string =~ ISO_DATETIME - microsec = ($7.to_r * 1_000_000).to_i + microsec_part = $7 + if microsec_part && microsec_part.start_with?(".") && microsec_part.length == 7 + microsec_part[0] = "" + microsec = microsec_part.to_i + else + microsec = (microsec_part.to_r * 1_000_000).to_i + end new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec end end |