Created
December 8, 2014 02:38
-
-
Save agmarrugo/e74853dd3914513af1d2 to your computer and use it in GitHub Desktop.
ago.py
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 | |
from datetime import date | |
import sys | |
now = date.today() | |
inputDate= sys.argv[1].split() | |
day = int(inputDate[0]) | |
month = int(inputDate[1]) | |
#day = int(sys.argv[1]) | |
#month = int(sys.argv[2]) | |
try: | |
#year = int(sys.argv[3]) | |
year = int(inputDate[2]) | |
if 50 <= year < 100: # assume 20th century | |
year += 1900 | |
if 0 <= year < 50: # assume 21st century | |
year += 2000 | |
except IndexError: # assume this year | |
year = now.year | |
then = date(year, month, day) | |
ago = now - then | |
print ago.days,'days' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment