Skip to main content

Lightweight fiscal and ISO calendar utilities.

Project description

PyPI Version

Calendar-Smith is a zero-dependency, high-performance Python utility for fiscal year calculations, ISO week mapping, and safe date parsing.

It was built for data engineers and analysts who need to process CSVs or perform calendar math without the overhead of heavy libraries like Pandas or Arrow.

Key Features

  • Safety-First Parsing: Strictly rejects ambiguous 6-digit (460614) and 7-digit (2026123) strings to prevent century errors and data corruption.

  • Fiscal Logic: Built-in support for US (October 1 start) and Japanese (April 1 start) fiscal systems.

  • Fast-Path Execution: Utilizes datetime.fromisoformat for high-performance processing of standard data.

  • Ordinal Formatting: Human-friendly outputs (e.g., “1st week”, “3rd week”).

  • Zero External Dependencies: Uses only the Python Standard Library (3.10+).

Installation

pip install calendar-smith

To contribute or run tests:

git clone https://github.com/youruser/calendar-smith.git
cd calendar-smith
pip install -e ".[dev]"
pytest

CLI Commands

1. calendar-smith-csv

Appends a fiscal_year column to an existing CSV file.

calendar-smith-csv records.csv records_with_fy.csv --system jp --date-column created_at

2. calendar-smith-solve

Lists the Monday-to-Sunday date ranges for every ISO week in a given year.

calendar-smith-solve 2026

3. calendar-smith-nth

Interactive tool to find the ordinal week of the month and the ISO week of the year for any date.

$ calendar-smith-nth
Date? [yyyy-mm-dd] >> 2026-02-17
Result:
  Date:       2026-02-17 (Tuesday)
  Month Week: The 3rd week
  Year Week:  The 8th week

Date Parsing Rules

To ensure data integrity, calendar-smith follows these parsing rules:

  • Accepted: 2026-02-17, 2026/02/17, 2026.02.17, 2026-2-17, 20260217.

  • Rejected:
    • 260217 (6-digit): Rejected to avoid century ambiguity (1926 vs 2026).

    • 2026123 (7-digit): Rejected because it could be Jan 23rd or Dec 3rd.

API Example

from calendar_smith import get_fiscal_year, to_date, get_nth_week_of_month

# Parse a messy but valid string
d = to_date("2026/4/1")

# Get Japanese Fiscal Year (2026)
fy_jp = get_fiscal_year(d, system="jp")

# Get US Fiscal Year (2026 - starts Oct 2025)
fy_us = get_fiscal_year(d, system="us")

# Get week of month
week_num = get_nth_week_of_month(d)

License

MIT License. See LICENSE for details.

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

calendar_smith-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

calendar_smith-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file calendar_smith-0.1.0.tar.gz.

File metadata

  • Download URL: calendar_smith-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for calendar_smith-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34b6a1240a802b2d1bbfc61e4b7f9e11d927ac88a446b750accf9fc5ed590611
MD5 cd5f25643d97e9584451327a977f6cae
BLAKE2b-256 7ca3e71a6e8a64d3f689919967a26aef9a2a35f6409f607bf16fd27f6e4635a4

See more details on using hashes here.

File details

Details for the file calendar_smith-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: calendar_smith-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for calendar_smith-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e0e42d46eaef97d2ba211acc455f8dcb74b3eb41e6afdaea456b4f11379b9f1
MD5 09ac11a58c8c5b298657e111eea2827b
BLAKE2b-256 3d705044caa738b02475b319d43e96cee4f7c341b97ad851f32fe716193d31cd

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