Created
June 26, 2013 10:11
-
-
Save ungarj/5866338 to your computer and use it in GitHub Desktop.
converts a date into an ANSI number
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/env python | |
import sys | |
from datetime import datetime, timedelta, date, time | |
# ANSI constant | |
ANSI_DATE_START = datetime(1601, 1, 1) | |
if (len(sys.argv) <> 2): | |
print 'Usage: date2ansi.py [date, e.g. 2013-06-26]' | |
else: | |
coverage_date = sys.argv[1] | |
coverage_date = datetime.strptime(coverage_date, "%Y-%m-%d") | |
diff = coverage_date - ANSI_DATE_START | |
print diff.days |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment