Skip to main content

Checking the date for belonging to a non-working day, according to official decrees and orders.

Project description

isdayoff

Production Calendar API

Description:

  • Checking the date for belonging to a non-working day, according to official decrees and orders.

Official API website — https://isdayoff.ru

Install

pip install isdayoff-api

Requires Python 3.11+.

Supported locales

Code Country
ru Russia
kz Kazakhstan
by Belarus
us USA
uz Uzbekistan
tr Turkey
lv Latvia

Quick start

Async (recommended)

import asyncio
from datetime import date

from isdayoff import DateType, ProdCalendar


async def main():
    async with ProdCalendar(locale="us") as calendar:
        if await calendar.today() == DateType.WORKING:
            print("Today is a working day")
        else:
            print("Today is a day off")


asyncio.run(main())

Sync

from datetime import date

from isdayoff import DateType, SyncProdCalendar


with SyncProdCalendar(locale="us") as calendar:
    if calendar.today() == DateType.WORKING:
        print("Today is a working day")
    else:
        print("Today is a day off")

API

All methods are available on both ProdCalendar (async) and SyncProdCalendar (sync).

Parameters

Parameter Type Default Description
locale str "ru" Country code (see table above)
pre bool False Mark shortened working days
covid bool False Mark working days due to COVID-19
sd bool False Consider 6-day work week

Methods

# Async
await calendar.today(locale="ru", pre=True, covid=True, sd=True)
await calendar.tomorrow()
await calendar.date(date(2024, 8, 25))
await calendar.month(date(2024, 8, 1))
await calendar.year(date(2024, 1, 1))
await calendar.range_date(date(2024, 1, 1), date(2024, 5, 1))
calendar.is_leap(date(2024, 1, 1))

# Sync
calendar.today(locale="ru", pre=True, covid=True, sd=True)
calendar.tomorrow()
calendar.date(date(2024, 8, 25))
calendar.month(date(2024, 8, 1))
calendar.year(date(2024, 1, 1))
calendar.range_date(date(2024, 1, 1), date(2024, 5, 1))
calendar.is_leap(date(2024, 1, 1))

Return types

Method Returns
today() / tomorrow() / date() DateType enum
month() / year() / range_date() dict[str, DateType] — ISO date → type
is_leap() bool

DateType values

Value Meaning
DateType.WORKING (0) Working day
DateType.NOT_WORKING (1) Day off / holiday
DateType.SHORTENED (2) Shortened pre-holiday day
DateType.WORKING_DAY (4) Working day (special period)

Full example

import asyncio
from datetime import date

from isdayoff import DateType, ProdCalendar


async def main():
    async with ProdCalendar(locale="us") as calendar:
        res = await calendar.month(date(2024, 8, 1), locale="ru")
        days_off = sum(
            1 for v in res.values() if v == DateType.NOT_WORKING
        )
        print(f"Days off in August 2024: {days_off}")


asyncio.run(main())

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

# Build
uv build

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

isdayoff_api-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

isdayoff_api-1.0.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file isdayoff_api-1.0.0.tar.gz.

File metadata

  • Download URL: isdayoff_api-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for isdayoff_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 191081bcb13e281358efce82b253286e777ef3529df3e3f6ce4544a616b3394a
MD5 33df9c83cbbcd2559c53cf381bb749c0
BLAKE2b-256 52341d9c2ef2868f8e622f55997471a7d6de2025c74a4b0ee71506a4339e17a1

See more details on using hashes here.

File details

Details for the file isdayoff_api-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: isdayoff_api-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for isdayoff_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e309019fc85e86b121409b49e321b09de3cd04f4dc254ec8c248e878e1480b9
MD5 0c618a458f85cc98a85b77cbc845a1a8
BLAKE2b-256 db5542d148112aedc396683ea140fa468514d551951fb3526c9782beb0d237b6

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