Created
January 13, 2020 08:40
-
-
Save sharuzzaman/9f20627d6c291c1fdf36e792c0e7c0e5 to your computer and use it in GitHub Desktop.
last sunday of the month for the year
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
#!/bin/env python3 | |
import calendar | |
import datetime | |
now = datetime.datetime.now() | |
cal = calendar.Calendar() | |
month = 1 | |
while month <= 12: | |
sundays_in_month = [x for x in cal.itermonthdays2(now.year,month) if x[0] != 0 and x[1] == 6] | |
last_sunday = sundays_in_month[-1] | |
print(last_sunday[0], calendar.month_name[month], now.year) | |
month = month + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment