Skip to content

Instantly share code, notes, and snippets.

@drdrang
Last active August 4, 2016 21:13
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drdrang/c1c81ae19dac35acc861 to your computer and use it in GitHub Desktop.
Save drdrang/c1c81ae19dac35acc861 to your computer and use it in GitHub Desktop.
Prints Emoji clockface of the given time rounded to the nearest half-hour. Uses current time if none given. After https://github.com/RobTrew/txtquery-tools/blob/master/utilities/emotime.sh
#!/usr/bin/python
# -*- coding: utf-8 -*-
from sys import argv
from time import strftime
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(round(float(minute)/30)*30)
if rminute == 60:
rminute = 0
hour = 1 if hour == 12 else hour + 1
print clocks['%d:%02d' % (hour, rminute)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment