Last active
May 15, 2017 22:40
-
-
Save meagtan/29b155fdf0f4d1859d32c0fb7f3111fe to your computer and use it in GitHub Desktop.
Fuzzy clock script for Geektool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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