-
-
Save fcrespo82/d64bae8db60fdf2a2ceb to your computer and use it in GitHub Desktop.
I don't know why I did it, but this version shows the minutes past the represented in the emoji
This file contains 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 | |
# -*- coding: utf-8 -*- | |
from sys import argv | |
from time import strftime | |
from math import floor | |
clocks = {'12:00': 'π', '12:30': 'π§', '1:00': 'π', '1:30': 'π', | |
'2:00': 'π', '2:30': 'π', '3:00': 'π', '3:30': 'π', | |
'4:00': 'π', '4:30': 'π', '5:00': 'π', '5:30': 'π ', | |
'6:00': 'π', '6:30': 'π‘', '7:00': 'π', '7:30': 'π’', | |
'8:00': 'π', '8:30': 'π£', '9:00': 'π', '9:30': 'π€', | |
'10:00': 'π', '10:30': 'π₯', '11:00': 'π', '11:30': 'π¦'} | |
# Get the argument, which should be a time string, like "8:10." | |
# If there's no argument, use the current time. | |
try: | |
oclock = argv[1] | |
except IndexError: | |
oclock = strftime('%I:%M') | |
hour, minute = [ int(x) for x in oclock.split(':') ] | |
# Round to the nearest half-hour, because there are no | |
# emoji clockfaces for other times. | |
rminute = int(floor(float(minute)/30)*30) | |
if rminute == 60: | |
rminute = 0 | |
hour = 1 if hour == 12 else hour + 1 | |
print clocks['%d:%02d' % (hour, rminute)], ' {:02}'.format(minute-rminute) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment