Skip to content

Instantly share code, notes, and snippets.

@tomotaka
Created June 11, 2012 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomotaka/2908487 to your computer and use it in GitHub Desktop.
Save tomotaka/2908487 to your computer and use it in GitHub Desktop.
# to parse datetime expression like: "2012-01-01 24:00:01"
def my_time_parse(str)
y, m, d, hour, min, sec = str.split(/[^0-9]/).map{|x| x.to_i }
base = Time.local(y, m, d)
return (base + (hour*60*60 + min*60 + sec))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment