Pure-Python Japan Business Day Generator
Project description
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
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
jpbizday-0.0.3.tar.gz
(4.4 kB
view details)
File details
Details for the file jpbizday-0.0.3.tar.gz
.
File metadata
- Download URL: jpbizday-0.0.3.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66f3d77456d3550c17bca2c125a632cecbf41ade8971b47fbd7f35a722eb992c |
|
MD5 | e9b883048c4fef17837d85337532f7cd |
|
BLAKE2b-256 | bb21a10b610bc2a79c8fcc217525df8928d9d90b183b57298dac7af85d88c34e |