Check the date of the flag duty with Python

Introduction

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.

Operating environment

python 3.7.7 (anaconda environment)

Install jpholiday with pip install jpholiday

Execution code



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

Execution result

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

in conclusion

Who would use this code?

Recommended Posts

Check the date of the flag duty with Python
Check the existence of the file with python
Check the scope of local variables with the Python locals function.
Check the behavior of destructor in Python
Check the path of the Python imported module
Prepare the execution environment of Python3 with Docker
2016 The University of Tokyo Mathematics Solved with Python
[Note] Export the html of the site with python.
Calculate the total number of combinations with python
the zen of Python
[Python] Get the last updated date of the website
Domain check with Python
Get date with python
[Python] Split the date
Convert the character code of the file with Python3
[Python] Determine the type of iris with SVM
Check version with python
Get the update date of the Python memo file.
Easy way to check the source of Python modules
Extract the table of image files with OneDrive & Python
Learn Nim with Python (from the beginning of the year).
Destroy the intermediate expression of the sweep method with Python
Visualize the range of interpolation and extrapolation with python
Calculate the regression coefficient of simple regression analysis with python
Summary of the basic flow of machine learning with Python
Get the operation status of JR West with Python
Extract the band information of raster data with python
Check the asymptotic nature of the probability distribution in Python
Towards the retirement of Python2
Check python coverage with pytest-cov
Python --Check type of values
About the ease of Python
Check OpenSSL version of python 2.6
Check the code with flake8
Call the API with python3.
About the features of Python
[Python] Check the installed libraries
The Power of Pandas: Python
I tried to find the entropy of the image with python
Try scraping the data of COVID-19 in Tokyo with Python
I tried "gamma correction" of the image with Python + OpenCV
The story of implementing the popular Facebook Messenger Bot with python
Unify the environment of the Python development team starting with Poetry
Calculate the square root of 2 in millions of digits with python
I wrote the basic grammar of Python with Jupyter Lab
Tank game made with python About the behavior of tanks
Run the intellisense of your own python library with VScode.
Check the memory status of the server with the Linux free command
I evaluated the strategy of stock system trading with Python.
Let's touch the API of Netatmo Weather Station with Python. #Python #Netatmo
Check the operating status of the server with the Linux top command
The story of rubyist struggling with python :: Dict data with pycall
[Homology] Count the number of holes in data with Python
Try to automate the operation of network devices with Python
Rewrite the record addition node of SPSS Modeler with Python.
Estimate the attitude of AR markers with Python + OpenCV + drone
Play with the password mechanism of GitHub Webhook and Python
Get the source of the page to load infinitely with python.
[Python] Check the current directory, move the directory
The story of Python and the story of NaN
Check the behavior when assigning Python