Last active
October 31, 2022 15:20
-
-
Save carlosdelfino/b3505ff43eb037c0cb824b2859d6ad7b to your computer and use it in GitHub Desktop.
Obtém o primeiro e último dia útil de cada mês.
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
resmin = [] | |
for month in range(1, 13): | |
calmin = calendar.monthcalendar(year, month) | |
for i, w in enumerate(calmin): | |
for j, d in enumerate(w): | |
if 0 == d: | |
calmin[i][j] = 32 | |
day = min([week[0:5] for week in calmin][0]) | |
if day == 32: | |
day = min([week[0:5] for week in calmin][1]) | |
resmin.append( | |
"{:02d}/{:02d}/{:4d}".format(day, month, 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
import calendar | |
year = 1997 | |
resmax = [] | |
for month in range(1, 13): | |
resmax.append( | |
"{:02d}/{:02d}/{:4d}".format( | |
max(max(week[0:5] for week in calendar.monthcalendar(year, month))), month, year)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment