(I'm assuming you do this to learn Python, so I'll point out the errors in your code).
>>> years = SecondsSinceEpoch / 31540000
Nonononono. You can't do that. Some years have 31536000 seconds, others have 31622400 seconds.
>>> if calendar.isleap(yeariterator) == True:
You don't need to test if a true value is true. :-) Do:
>>> if calendar.isleap(yeariterator):
Instead.
Also change:
>>> yeariterator = 1969
>>> iterator = 0
>>> while yeariterator < yearsfordayfunction:
>>> yeariterator = yeariterator + 1
To:
for yeariterator in range(1970, yearsfordayfunction):
That will also fix your error: You don't stop until AFTER 2009, so you get the answer -105, because there is 105 days left of the year.
And also, there's not much point in calculating month by month. Year by year works fine.
for yeariterator in range(1970, yearsfordayfunction):
if calendar.isleap(yeariterator) == True:
days = days - 366
else:
days = days - 365
And an indent of 8 spaces is a lot. 4 is more common.
Also, I'd calculate year and day of year in one method, instead of doing it twice.
def YearDay():
SecondsSinceEpoch = int(time.time())
days = SecondsSinceEpoch // 86400 # Double slash means floored int.
year = 1970
while True:
if calendar.isleap(year):
days -= 366
else:
days -= 365
year += 1
if calendar.isleap(year):
if days <= 366:
return year, days
else:
if days <= 365:
return year, days
def MonthDay(year, day):
if calendar.isleap(year):
monthstarts = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]
else:
monthstarts = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]
month = 0
for start in monthstarts:
if start > day:
return month, day - monthstarts[month-1] + 1
month += 1