Last active
December 18, 2015 18:49
-
-
Save moskytw/5828799 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
for y in (2011, 2012, 2100, 2400): | |
print 'year:', y | |
for m in range(1, 12+1): | |
m_days = 30 + (m+(m>=8))%2 - 2*(m==2) + (m==2 and (not y%4 and not not y%100 or not y%400)) | |
print m, m_days | |
# output: | |
# year: 2011 | |
# 1 31 | |
# 2 28 | |
# 3 31 | |
# 4 30 | |
# 5 31 | |
# 6 30 | |
# 7 31 | |
# 8 31 | |
# 9 30 | |
# 10 31 | |
# 11 30 | |
# 12 31 | |
# | |
# year: 2012 | |
# 1 31 | |
# 2 29 | |
# 3 31 | |
# 4 30 | |
# 5 31 | |
# 6 30 | |
# 7 31 | |
# 8 31 | |
# 9 30 | |
# 10 31 | |
# 11 30 | |
# 12 31 | |
# | |
# year: 2100 | |
# 1 31 | |
# 2 28 | |
# 3 31 | |
# 4 30 | |
# 5 31 | |
# 6 30 | |
# 7 31 | |
# 8 31 | |
# 9 30 | |
# 10 31 | |
# 11 30 | |
# 12 31 | |
# | |
# year: 2400 | |
# 1 31 | |
# 2 29 | |
# 3 31 | |
# 4 30 | |
# 5 31 | |
# 6 30 | |
# 7 31 | |
# 8 31 | |
# 9 30 | |
# 10 31 | |
# 11 30 | |
# 12 31 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment