Created
August 26, 2009 07:32
-
-
Save lestrrat/175364 to your computer and use it in GitHub Desktop.
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
months = [ 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ] | |
def is_leap_year(year): | |
if (year % 4): | |
return 0 | |
elif (year % 100): | |
return 1 | |
elif (year % 400): | |
return 0 | |
else: | |
return 1 | |
def last_day_of_month(year, month): | |
if (month == 2): | |
if (is_leap_year(year)): | |
return 29 | |
else: | |
return 28 | |
return months[ month - 1 ] | |
data = [ [1900, 2], [2000, 2], [2009, 8], [2009, 9] ] | |
for data in data: | |
print str(data[0]) + "/" + str(data[1]) + " -> " + str(last_day_of_month(data[0], data[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment