Created
August 24, 2015 11:33
-
-
Save godfat/3dff9f88f46a58f56927 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sequel' | |
module FasterSequelTimeParser # from activerecord | |
module_function | |
def parse string | |
string =~ /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)(\.\d+)?\z/ | |
microsec = ($7.to_r * 1_000_000).to_i | |
::Time.utc($1.to_i, $2.to_i, $3.to_i, $4.to_i, | |
$5.to_i, $6.to_i, microsec) | |
end | |
def now | |
::Time.now | |
end | |
end | |
Sequel.datetime_class = FasterSequelTimeParser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment