Skip to content

Instantly share code, notes, and snippets.

@mharju
Created December 21, 2011 06:27
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 mharju/1504903 to your computer and use it in GitHub Desktop.
Save mharju/1504903 to your computer and use it in GitHub Desktop.
8h 12m 23s to hours representation. Used as python -c '<script here>'
import re
import sys
i = sys.stdin.readline()
print "%.2f" % sum( [ x*y for x, y in zip([int(a) for a in re.match(r'(\d+)h (\d+)m (\d+)s', i).groups()], (1, 1/60., 1/(60.*60.))) ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment