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

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 Pulls Image Size

$ 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 内閣府ホームページ利用規約.

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-2022.2.1.post3.tar.gz (12.6 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-2022.2.1.post3-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

Details for the file python-shukujitsu-2022.2.1.post3.tar.gz.

File metadata

File hashes

Hashes for python-shukujitsu-2022.2.1.post3.tar.gz
Algorithm Hash digest
SHA256 9d86cd171ca4d4e1e01ee2e11bce6cbcee3d3ce23e16443fef83ecc28641c944
MD5 0fc6b23c9abc82e3f3e12f3df03f2d43
BLAKE2b-256 3c025618ef833f6cbb688f8fe6cc694c2a04893d42739c373918027289d44478

See more details on using hashes here.

File details

Details for the file python_shukujitsu-2022.2.1.post3-py3-none-any.whl.

File metadata

File hashes

Hashes for python_shukujitsu-2022.2.1.post3-py3-none-any.whl
Algorithm Hash digest
SHA256 24e1ab29be2cfc5ae9b51c81a87b2b17444d6eeb820c80b6cf59d236a98d6d50
MD5 a8c0f01e6fbeb0359f43e23c0be362ca
BLAKE2b-256 9d4634f9f3abecc172c9bad8c35545fafc00692f8a9f5d74c606a70284f6a750

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