Do you have a flag duty to help your child go to school as a local safety activity? In my area, only the number of people on duty in the area in charge and the next person to pass on are known. Therefore, there was a problem that I couldn't schedule work because I didn't know the date and time when the next flag would come around after the flag was on duty.
I made a program in python that counts this and checks when the flag turns.
python 3.7.7 (anaconda environment)
Install jpholiday with pip install jpholiday
import datetime
import jpholiday
# -------Initial setting--------------
#The day when the flag was on duty
day = datetime.date(2020,6,29)
NumberOfPeople = 31 #Turn by person
# -------Initial setting up to here------
daycount = 0
for i in range(0,365):
#Skip only at the beginning
if i != 0:
day = day + datetime.timedelta(days =1)
#Saturday and Sunday skip 0: Getsuyoubi 6:Sunday
if day.weekday() == 5 or day.weekday() == 6:
continue
#Holiday skip
if jpholiday.is_holiday(day):
continue
#Write summer vacation skip here 8/8 -23 is summer vacation
if day >= datetime.date(2020,8,8) and day <= datetime.date(2020,8,23):
continue
#Search for a specified date based on too much
q,mod = divmod(daycount,NumberOfPeople)
if mod == 0:
#Print date
print(day)
#On-duty count up
daycount = daycount+1
Print the number of days from the specified day, counting the days of holidays, Saturdays, Sundays, and summer vacation. You can see the day of the next flag turn.
2020-06-29
2020-08-27
2020-10-13
2020-11-27
2021-01-13
2021-03-01
2021-04-13
2021-06-01
Who would use this code?
Recommended Posts