Skip to content

Instantly share code, notes, and snippets.

@meagtan
Last active May 15, 2017 22:40
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 meagtan/29b155fdf0f4d1859d32c0fb7f3111fe to your computer and use it in GitHub Desktop.
Save meagtan/29b155fdf0f4d1859d32c0fb7f3111fe to your computer and use it in GitHub Desktop.
Fuzzy clock script for Geektool
#!/usr/bin/python
from datetime import datetime
numwrds = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "quarter", "sixteen", "seventeen",
"eighteen", "nineteen", "twenty", "twenty-one", "twenty-two", "twenty-three",
"twenty-four", "twenty-five", "twenty-six", "twenty-seven", "twenty-eight",
"twenty-nine", "half"]
now = datetime.now()
hrs = now.hour
mins = now.minute
# workaround
hrs %= 12
if hrs == 0:
hrs = 12
if mins == 0:
print "It is %s o'clock." % (numwrds[hrs - 1])
elif mins < 31:
print "It is %s past %s." % (numwrds[mins - 1], numwrds[hrs - 1])
else:
print "It is %s to %s." % (numwrds[59 - mins], numwrds[hrs])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment