Skip to content

Instantly share code, notes, and snippets.

@nicokruger
Created March 1, 2012 19:49
Show Gist options
  • Select an option

  • Save nicokruger/1952620 to your computer and use it in GitHub Desktop.

Select an option

Save nicokruger/1952620 to your computer and use it in GitHub Desktop.
find the bug part one
import calendar
import sys
def ConvertDays(days):
year = 1980
while days > 365:
if calendar.isleap(year):
if days > 366:
days -= 366
year += 1
else:
days -= 365
year += 1
return year
if len(sys.argv) < 2:
print("Specify number of days since 1980")
sys.exit(1)
print("Year: %i" % ConvertDays(int(sys.argv[1])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment