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
Important notices
- This python-shukujitsu package covers only holidays in Japan from 1955 to 2023; will expand to holidays in 2014 in February 2023.
- This python-shukujitsu package has ZERO relation to the Government of Japan - NEVER EVER assume any authorization as this is just a personal project.
Installation
pip3 install python-shukujitsu
Usage
Play the dict-like object.
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 dict-like object also accepts misc. date(time)-like strings
# 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)]
Command-Line interface
shukujitsu command is bundled.
$ shukujitsu --help # or python3 -m shukujitsu --help
usage: shukujitsu [-h] [-i] [-n] [-V] [DATE ...]
Select Japanese holidays from 1955 to 2023
positional arguments:
DATE date to be examined
options:
-h, --help show this help message and exit
-i, --invert-match select non-holidays
-n, --holiday-name output holiday name instead
-V, --version display version information and exit
With no DATE, read standard input. Exit status is 0 if any date is selected, 1 otherwise.
Pass any dates through command-line arguments or STDIN.
$ # With logical operators
$ shukujitsu 1/1/2020 && echo Holiday found || echo Holiday not found
1/1/2020
Holiday found
$ # Select holidays
$ cat <<EOF | shukujitsu > holidays.txt
> 2020-05-02
> 2020-05-03
> 2020-05-04
> 2020-05-05
> 2020-05-06
> 2020-05-07
> EOF
$ # Select holidays
$ shukujitsu 2020/7/22 2020/7/23 2020/7/24
2020/7/23
2020/7/24
$ # Output each holiday name
$ shukujitsu -n 2020/7/22 2020/7/23 2020/7/24
海の日
スポーツの日
$ # Select non-holidays
$ shukujitsu -i 2020/7/22 2020/7/23 2020/7/24
2020/7/22
Docker image
$ docker run -it sakuraiyouhei/shukujitsu --help
yum repository
$ sudo yum install -y curl
$ curl -fsSL https://sakurai-youhei.github.io/python-shukujitsu/rpm/python-shukujitsu.repo | sudo tee /etc/yum.repos.d/python-shukujitsu.repo
$ sudo yum install -y python-shukujitsu
$ shukujitsu --help
apt repository
$ sudo apt install -y curl gpg
$ curl -fsSL https://sakurai-youhei.github.io/python-shukujitsu/gpg | sudo apt-key add -
$ curl -fsSL https://sakurai-youhei.github.io/python-shukujitsu/deb/python-shukujitsu.list | sudo tee /etc/apt/sources.list.d/python-shukujitsu.list
$ sudo apt update
$ sudo apt install -y python-shukujitsu
$ shukujitsu --help
Source data
This python-shukujitsu package bundles the following source data, which is distributed by the Government of Japan under the CC BY compatible conditions according to 内閣府ホームページ利用規約.
- 2022年2月1日時点の 内閣府ホームページ で公開されていた「昭和30年(1955年)から令和5年(2023年)国民の祝日(csv形式:20KB)」( https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv )
- 2021年2月1日時点の 内閣府ホームページ で公開されていた「昭和30年(1955年)から令和4年(2022年)国民の祝日(csv形式:19KB)」( https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv )
- 2020年11月27日時点の 内閣府ホームページ で公開されていた「昭和30年(1955年)から令和3年(2021年)国民の祝日(csv形式:19KB)」( https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv )
- 2020年11月18日時点の 内閣府ホームページ で公開されていた「昭和30年(1955年)から令和3年(2021年)国民の祝日(csv形式:19KB)」( https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv )
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-2023.2.1.tar.gz.
File metadata
- Download URL: python-shukujitsu-2023.2.1.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
653b3b63242c7ee68321ad40bb77a7d23c6d05a59f7a93d86a98f82433e8e794
|
|
| MD5 |
11d0707f3d5f71c454e2ce2835d6714e
|
|
| BLAKE2b-256 |
b871465c73c8ee61c4ad7d266c405889b414ce0f1d6d2b1999692af485fb936e
|
File details
Details for the file python_shukujitsu-2023.2.1-py3-none-any.whl.
File metadata
- Download URL: python_shukujitsu-2023.2.1-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63126cca5d12570fe43cceb17de34826f63da1be7496ea056a126d9d021bc9f1
|
|
| MD5 |
db04e7860541e2a1dbf030e2298865e1
|
|
| BLAKE2b-256 |
6ae26c6dbdca272d1ac1f8dd549a0adeefcd91e9641b41bd645dbf3c65bd691d
|