Skip to content

Instantly share code, notes, and snippets.

@Cameron-D
Created November 12, 2012 02:44
Show Gist options
  • Save Cameron-D/4057227 to your computer and use it in GitHub Desktop.
Save Cameron-D/4057227 to your computer and use it in GitHub Desktop.
from util import hook
import random
from dateutil.relativedelta import relativedelta
import datetime
import math
@hook.command('cd')
@hook.command
def countdown(inp, say=None):
now = datetime.datetime.now()
ponyTimes = [datetime.datetime(2012,11,11,1,0),
datetime.datetime(2012,11,18,1,0),
datetime.datetime(2012,11,25,1,0),
datetime.datetime(2012,12,2,1,0),
datetime.datetime(2012,12,9,1,0),
datetime.datetime(2012,12,16,1,0),
#ep8 datetime.datetime(2012,12,18,1,0)
datetime.datetime(2012,12,23,1,0),
datetime.datetime(2012,12,30,1,0)]
ponyEpisodes = ["S3E01+2: The Crystal Empire",
"S3E03: Too Many Pinkie Pies",
"S3E04: One Bad Apple",
"S3E05: Magic Duel",
"S3E06: Sleppless in Ponyville",
"S3E07: Wonderbolt Academy",
#"S3E08: TBA",
"S3E09: Apple Family Reunion",
"S3E10: Spike at Your Service"]
#get the next non past episode
for idx, episode in enumerate(ponyTimes):
time1 = episode.timetuple()
time2 = now.timetuple()
episodeString = ponyEpisodes[idx]
if (time1 >= time2):
break
rainbowDelta = relativedelta(now,episode)
derp = rainbowDelta.__dict__
string = "%(days)d days, %(hours)d hours, %(mins)d minutes and %(seconds)d seconds until %(episodeString)s" % \
{"episodeString": episodeString, "days": abs(derp['days']), "hours": abs(derp['hours']), "mins": abs(derp['minutes']), "seconds": abs(derp['seconds'])}
say(string)
# say("Soonish!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment