Python Japanese holidays library based on static data published by Cabinet Office, Government of Japan
Project description
python-shukujitsu
Python Japanese holidays library based on static data published by Cabinet Office, Government of Japan
Usage is similar to python-holidays package. But note that this python-shukujitsu package covers only holidays in Japan from the year 1955 to 2021 as of today.
import shukujitsu
import shukujitsu
jp_holidays = shukujitsu.Japan()
# or:
# jp_holidays = shukujitsu.JP()
# or:
# jp_holidays = shukujitsu.CountryHoliday('JP')
from datetime import date
date(2020, 7, 24) in jp_holidays # True
date(2019, 7, 24) in jp_holidays # False
# The Holiday class will also recognize strings of any format
# and int/float representing a Unix timestamp
'2014-01-01' in jp_holidays # True
'1/1/2014' in jp_holidays # True
1388597445 in jp_holidays # True
jp_holidays.get('2014-01-01') # "元日"
jp_holidays['2014-01-01': '2014-01-03'] # [date(2014, 1, 1)]
Installation
pip3 install python-shukujitsu
Command-Line interface
shukujitsu command becomes available by installing this python-shukujitsu package.
$ shukujitsu --help # or python3 -m shukujitsu --help
usage: shukujitsu [-h] [-i] [-n] [-V] [DATE ...]
Utility to match Japanese holidays from the year 1955 to 2021
positional arguments:
DATE date to be matched
optional arguments:
-h, --help show this help message and exit
-i, --invert-match select non-matching dates
-n, --holiday-name output holiday name instead
-V, --version display version information and exit
Exit code stays 0 if one or more dates are matched. Otherwise, it always goes 1.
One or some dates can be input to the command through command-line arguments or STDIN.
$ # You can start a conditional branch from shukujitsu command.
$ shukujitsu 2020-01-01 && echo This is a holiday || echo This is not a holiday
2020-01-01
This is a holiday
$ # You can also filter dates by using shukujitsu command.
$ cat <<EOF | shukujitsu > holidays.txt
> 2020-05-02
> 2020-05-03
> 2020-05-04
> 2020-05-05
> 2020-05-06
> 2020-05-07
> EOF
$ # You can check multiple dates at once.
$ shukujitsu 2020/7/22 2020/7/23 2020/7/24
2020/7/23
2020/7/24
$ # You can also check the name of each holiday.
$ shukujitsu -n 2020/7/22 2020/7/23 2020/7/24
海の日
スポーツの日
$ # You can also pick up non-holiday.
$ shukujitsu -i 2020/7/22 2020/7/23 2020/7/24
2020/7/22
Docker
docker run -it sakuraiyouhei/shukujitsu --help
Important Notice
Source Data
This python-shukujitsu package is based on the following data. (Japanese - 本ライブラリは以下のデータを加工して作成しています。) The license of Source Data is CC BY compatible; The exact conditions are described at 内閣府ホームページ利用規約.
- 内閣府ホームページの「国民の祝日」についてで公開されている「昭和30年(1955年)から令和3年(2021年)国民の祝日(csv形式:19KB)」(内閣府) (https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv)
Source Code
This python-shukujitsu package may contain a copy of and/or modified code from python-holidays package which is licensed under MIT License.
Relation to the Government of Japan
Nothing - NEVER EVER imagine relation to Government of Japan. This is just a personal project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python-shukujitsu-2020.11.18.post4.tar.gz.
File metadata
- Download URL: python-shukujitsu-2020.11.18.post4.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
776fbbe142274b300bd25f1c1834c73a627b7fb39ca4129aebaf42b0e77dd9a7
|
|
| MD5 |
6a30207f28f22e1f569924798dfd5d46
|
|
| BLAKE2b-256 |
1ed80d8ef25e069df8984a083650dd039bb9e4b04c6a8fe1c3ad3b98dfe0eb01
|
File details
Details for the file python_shukujitsu-2020.11.18.post4-py3-none-any.whl.
File metadata
- Download URL: python_shukujitsu-2020.11.18.post4-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfaea0f9e14f8ee50853ae8895e516e1f6f9bf9c80362c9ea554fc4b4415a9e7
|
|
| MD5 |
61f9498653710132ee9208964032c970
|
|
| BLAKE2b-256 |
a8e68d2993850b7e0998478443d295343d413e6391921502076ac2442f88c503
|