Skip to content

Instantly share code, notes, and snippets.

@fcrespo82
Forked from drdrang/clockface
Last active August 29, 2015 14:04
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 fcrespo82/d64bae8db60fdf2a2ceb to your computer and use it in GitHub Desktop.
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
#!/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