Skip to content

Instantly share code, notes, and snippets.

@Maxinary
Created May 30, 2015 12:34
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 Maxinary/49ec9b424c12780f45df to your computer and use it in GitHub Desktop.
Save Maxinary/49ec9b424c12780f45df to your computer and use it in GitHub Desktop.
Changes current time to fuzzy time
from time import localtime
hours = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"]
minutes = ["five", "ten", "quarter", "twenty", "twenty-five", "half"]
relatives = ["past", "to"]
def fuzzy():
timern = localtime()
hourrn = timern[3]%12-1
minutern = int(timern[4]/5)
strtimern = ""
if minutern > 0:
if minutern <= 6:
strtimern += minutes[minutern - 1] + " " + relatives[0] + " " + hours[hourrn]
else:
strtimern = minutes[11-minutern] + " " + relatives[1] + " " + hours[(hourrn+1)%12]
else:
strtimern += hours[hourrn] + " O'Clock"
return strtimern.title()
print(fuzzy())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment