Skip to main content

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

PyPI License        PyPI Downloads      PyPI Version        PyPI Python Versions

flake8 and pytest   Publish to PyPI     Publish to DockerHub RPM and DEB         CodeQL

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

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 status 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

Alternative ways

Docker

Docker Pulls Image Size

$ docker run -it sakuraiyouhei/shukujitsu --help

yum

$ 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

$ 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

Important Notice

Source Data

This python-shukujitsu package bundles the following data. (Japanese - 本ライブラリは以下のデータを同梱しています。) The license of Source Data is CC BY compatible; The exact conditions are described at 内閣府ホームページ利用規約.

Source Code

This python-shukujitsu package may contain a copy of and/or modified code from python-holidays package which is also 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-shukujitsu-2020.11.27.post5.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_shukujitsu-2020.11.27.post5-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file python-shukujitsu-2020.11.27.post5.tar.gz.

File metadata

  • Download URL: python-shukujitsu-2020.11.27.post5.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for python-shukujitsu-2020.11.27.post5.tar.gz
Algorithm Hash digest
SHA256 b6c736cf681e04331eaeb038ea3e21c151492491e5e98d4fadcad6bec4a57ae8
MD5 ca426f6ba5d918b26bc48ccbbb8a2780
BLAKE2b-256 875d996b16fb62cedce17b5a6bb18feadc00b2075d1efed2ea8eefa01cdb35d9

See more details on using hashes here.

File details

Details for the file python_shukujitsu-2020.11.27.post5-py3-none-any.whl.

File metadata

  • Download URL: python_shukujitsu-2020.11.27.post5-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for python_shukujitsu-2020.11.27.post5-py3-none-any.whl
Algorithm Hash digest
SHA256 6d2a198e40866a64c32ab1be73dd45c9203c7605c1210c9933d3c9820e7ff5f6
MD5 950a9171262f660bce5e847785893c79
BLAKE2b-256 6683199d9859f3b224d7183b179c7a941a0a4f67247ab7989f61660152be5c32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page