Skip to content

Instantly share code, notes, and snippets.

@GUI
Created March 16, 2014 14:56
Show Gist options
  • Save GUI/9584445 to your computer and use it in GitHub Desktop.
Save GUI/9584445 to your computer and use it in GitHub Desktop.
def fast_string_to_time(string)
matches = string.match(Format::ISO_DATETIME)
if matches
microsec = (matches[7].to_r * 1_000_000).to_i
new_time matches[1].to_i, matches[2].to_i, matches[3].to_i, matches[4].to_i, matches[5].to_i, matches[6].to_i, microsec
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment