Skip to content

Instantly share code, notes, and snippets.

@ungarj
Created June 26, 2013 10:11
Show Gist options
  • Save ungarj/5866338 to your computer and use it in GitHub Desktop.
Save ungarj/5866338 to your computer and use it in GitHub Desktop.
converts a date into an ANSI number
#!/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