Skip to content

Instantly share code, notes, and snippets.

@jrabbit
Created July 8, 2010 16:56
Show Gist options
  • Save jrabbit/468298 to your computer and use it in GitHub Desktop.
Save jrabbit/468298 to your computer and use it in GitHub Desktop.
Keith Olbermann's closing simulator
import time
daynum=int(time.strftime('%j'))
year=int(time.strftime('%y'))
composite=(year*365)+daynum
def ordinal(n):
if 10 <= n % 100 < 20:
return str(n) + 'th'
else:
return str(n) + {1 : 'st', 2 : 'nd', 3 : 'rd'}.get(n % 10, "th")
#thanks http://stackoverflow.com/questions/739241/python-date-ordinal-output/739301#739301
print "It is the %s day since President Bush declared mission accomplished in Iraq, \
the %s day since he declared victory in the Afghanistan, \
and %s day of the Deepwater Horizon disaster in the Gulf."% (ordinal(composite - 1214), ordinal(composite - 1625), ordinal(composite - 3759))
#Composite dates - date of occurance for July 8th -- 2625 Iraq 2214 Afg 80 Oil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment