Skip to main content

Pure-Python Japan Business Day Generator

Project description

https://img.shields.io/pypi/v/jpbizday.svg https://img.shields.io/pypi/l/jpbizday.svg https://img.shields.io/pypi/pyversions/jpbizday.svg https://img.shields.io/github/contributors/sig9org/jpbizday.svg

JPBizDay

日本の営業日を取得するライブラリです。 jpholiday に依存しています (作者の Lalcs さんに感謝します)。

インストール

pip でインストールします。

$ pip install jpbizday

サンプルコード

指定日が営業日かを判定する

> import jpbizday
> import datetime
> jpbizday.is_bizday(datetime.date(2020, 1, 1))
False
> jpbizday.is_bizday(datetime.date(2020, 1, 6))
True

指定年の営業日を取得する

> jpbizday.year_bizdays(2020)
[datetime.date(2020, 1, 6),
 datetime.date(2020, 1, 7),
 datetime.date(2020, 1, 8),
 datetime.date(2020, 1, 9),
 datetime.date(2020, 1, 10),
 datetime.date(2020, 1, 14),
 datetime.date(2020, 1, 15),
    .
    .
    .
 datetime.date(2020, 12, 23),
 datetime.date(2020, 12, 24),
 datetime.date(2020, 12, 25),
 datetime.date(2020, 12, 28),
 datetime.date(2020, 12, 29),
 datetime.date(2020, 12, 30),
 datetime.date(2020, 12, 31)]
> len(jpbizday.year_bizdays(2020))
259
> len(jpbizday.year_bizdays(2021))
260
> len(jpbizday.year_bizdays(2022))
259
> len(jpbizday.year_bizdays(2023))
258
> len(jpbizday.year_bizdays(2024))
259
> len(jpbizday.year_bizdays(2025))
258

指定月の営業日を取得する

> jpbizday.month_bizdays(2020, 1)
[datetime.date(2020, 1, 6),
 datetime.date(2020, 1, 7),
 datetime.date(2020, 1, 8),
 datetime.date(2020, 1, 9),
 datetime.date(2020, 1, 10),
 datetime.date(2020, 1, 14),
 datetime.date(2020, 1, 15),
 datetime.date(2020, 1, 16),
 datetime.date(2020, 1, 17),
 datetime.date(2020, 1, 20),
 datetime.date(2020, 1, 21),
 datetime.date(2020, 1, 22),
 datetime.date(2020, 1, 23),
 datetime.date(2020, 1, 24),
 datetime.date(2020, 1, 27),
 datetime.date(2020, 1, 28),
 datetime.date(2020, 1, 29),
 datetime.date(2020, 1, 30),
 datetime.date(2020, 1, 31)]
> len(jpbizday.month_bizdays(2020, 1))
19

指定月の営業日を取得する

> jpbizday.bizdays(datetime.date(2020, 1, 1), datetime.date(2020, 1, 18))
[datetime.date(2020, 1, 6),
 datetime.date(2020, 1, 7),
 datetime.date(2020, 1, 8),
 datetime.date(2020, 1, 9),
 datetime.date(2020, 1, 10),
 datetime.date(2020, 1, 14),
 datetime.date(2020, 1, 15),
 datetime.date(2020, 1, 16),
 datetime.date(2020, 1, 17)]
> len(jpbizday.bizdays(datetime.date(2020, 1, 1), datetime.date(2020, 1, 18)))
9

指定月の最初の営業日を取得する

> jpbizday.first_bizday(2020, 1)
datetime.date(2020, 1, 6)
> jpbizday.first_bizday(datetime.date(2020, 1, 1))
datetime.date(2020, 1, 6)
> datetime.datetime.today()
datetime.datetime(2020, 2, 2, 4, 54, 15, 305254)
> jpbizday.first_bizday(datetime.datetime.today())
datetime.date(2020, 2, 3)

指定月の最後の営業日を取得する

> jpbizday.last_bizday(2020, 5)
datetime.date(2020, 5, 29)
> jpbizday.last_bizday(datetime.date(2020, 5, 15))
datetime.date(2020, 5, 29)
> datetime.datetime.today()
datetime.datetime(2020, 2, 2, 4, 55, 33, 664474)
> jpbizday.last_bizday(datetime.datetime.today())
datetime.date(2020, 2, 28)

指定月の最初の営業日なのかを判定する

> jpbizday.is_first_bizday(datetime.date(2020, 1, 1))
False
> jpbizday.is_first_bizday(datetime.date(2020, 1, 6))
True
> datetime.datetime.today()
datetime.datetime(2020, 2, 2, 4, 58, 5, 843849)
> jpbizday.is_first_bizday(datetime.datetime.today())
False

指定月の最後の営業日なのかを判定する

> jpbizday.is_last_bizday(datetime.date(2020, 1, 31))
True
> jpbizday.is_last_bizday(datetime.date(2020, 1, 30))
False
> datetime.datetime.today()
datetime.datetime(2020, 2, 2, 4, 59, 6, 89896)
> jpbizday.is_last_bizday(datetime.datetime.today())
False

Project details


Download files

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

Files for jpbizday, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size jpbizday-0.0.3.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page