Created
July 17, 2017 17:55
-
-
Save chun37/7faf9b57fa8f4d3e90815a7f1d2dfde8 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
# -*- coding: utf-8 -*- | |
import datetime | |
import sys | |
try: | |
g, y, m, d = sys.argv | |
except: | |
exit() | |
try: | |
t = datetime.date(int(y), int(m), int(d)) | |
try: | |
print {"1, 1": u"元日", "4, 29": u"昭和の日", "5, 3": u"憲法記念日", "5, 4": u"みどりの日", "5, 5": u"こどもの日", "8, 11": u"山の日", "11, 3": u"文化の日", "11, 23": u"勤労感謝の日", "12, 23": u"天皇誕生日"}[str([int(m), int(d)])[1:-1]] | |
except: | |
pass | |
try: | |
print {"1, 2, 0": u"成人の日", "7, 3, 0": u"海の日", "9, 3, 0": u"敬老の日", "10, 2, 0": u"体育の日"}[str([int(m), (t.day - 1) // 7 + 1, t.weekday()])[1:-1]] | |
except: | |
pass | |
try: | |
print {'3, {}'.format(int(20.8431 + 0.242194 * (int(y) - 1980) - int((int(y) - 1980) / 4))): u'春分の日', '9, {}'.format(int(23.2488 + 0.242194 * (int(y) - 1980) - int((int(y) - 1980) / 4))): u'秋分の日'}[str([int(m), int(d)])[1:-1]] | |
except: | |
pass | |
print u"%s月の第%s週%s曜日" % (int(m), (t.day - 1) // 7 + 1, [u"月", u"火", u"水", u"木", u"金", u"土", u"日"][t.weekday()]) | |
except: | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From line 8:
このほうがよくね