A Python library for the Gorman Calendar
Project description
dateutil-gorman
A Python library for the Gorman Calendar: a 13-month calendar where each month has 28 days, plus one or two intermission days at the end of the year.
- 13 months of 28 days each (364 days)
- Intermission: 1 day in common years, 2 days in leap years (Intermission 1 and Intermission 2), each a separate 24-hour day
- Month names: March, April, May, June, Quintilis, Sextilis, September, October, November, December, January, February, Gormanuary
Requires Python 3.10+.
Installation
pip install dateutil-gorman
Or with uv:
uv add dateutil-gorman
Quick start
from datetime import date
from dateutil_gorman import GormanDate, gregorian_to_gorman, gorman_to_gregorian, parse_gorman
# Gregorian → Gorman
g = gregorian_to_gorman(date(2024, 6, 15))
print(g) # 15 June 2024
# Gorman → Gregorian
d = gorman_to_gregorian(2024, 6, 15)
print(d) # 2024-06-15
# Parse a Gorman date string
dt = parse_gorman("28 Gormanuary 2024")
print(dt) # 2024-02-28 00:00:00
Examples
Intermission days
The last day(s) of the Gregorian year are intermission in Gorman: one day in common years, two in leap years.
from datetime import date
from dateutil_gorman import gregorian_to_gorman, Intermission
# Common year: Dec 31 is Intermission 1
g = gregorian_to_gorman(date(2023, 12, 31))
print(g) # Intermission 1 2023
print(type(g).__name__) # Intermission
print(g.to_gregorian()) # 2023-12-31
# Leap year: Dec 30 = Intermission 1, Dec 31 = Intermission 2
g1 = gregorian_to_gorman(date(2024, 12, 30))
g2 = gregorian_to_gorman(date(2024, 12, 31))
print(g1) # Intermission 1 2024
print(g2) # Intermission 2 2024
From ISO and ordinal
from dateutil_gorman import GormanDate
# Parse a Gregorian ISO date (YYYY-MM-DD) and convert to Gorman
g = GormanDate.fromisoformat("2024-07-04")
print(g) # 4 Quintilis 2024
# From proleptic Gregorian ordinal (same as datetime.date)
g = GormanDate.fromordinal(738000)
print(g.to_gregorian()) # 2024-01-15
Gorman week calendar
Each Gorman month has 4 weeks; the year has 52 weeks (intermission days are outside any week).
from dateutil_gorman import GormanDate
g = GormanDate(2024, 6, 15)
year, week, weekday = g.gorman_week_calendar()
print(f"Year {year}, week {week}, weekday {weekday}") # Year 2024, week 21, weekday 6
# Week of month (1–4) and week of year (1–52)
print(g.week_of_month()) # 3
print(g.week_of_year()) # 21
# Build a GormanDate from (year, week, weekday)
g2 = GormanDate.from_gorman_week_calendar(2024, 21, 6)
print(g2) # 15 June 2024
Immutable updates with replace
from dateutil_gorman import GormanDate
g = GormanDate(2024, 6, 15)
g2 = g.replace(day=1)
print(g2) # 1 June 2024
# g is unchanged
print(g) # 15 June 2024
Parsing Gorman date strings
from dateutil_gorman import parse_gorman
# Day month year
parse_gorman("15 June 2024") # 2024-06-15 00:00:00
# Month day, year
parse_gorman("June 15, 2024") # 2024-06-15 00:00:00
# With time
parse_gorman("15 June 2024 14:30") # 2024-06-15 14:30:00
parse_gorman("15 June 2024 14:30:45") # 2024-06-15 14:30:45
# Intermission
parse_gorman("Intermission 1 2024") # 2024-12-30 00:00:00 (leap year)
parse_gorman("Intermission 2 2024") # 2024-12-31 00:00:00 (leap year only)
Preserving time with datetime
When you convert a datetime, the time is stored on the Gorman value and restored when converting back.
from datetime import datetime
from dateutil_gorman import gregorian_to_gorman
dt = datetime(2024, 6, 15, 14, 30, 0)
g = gregorian_to_gorman(dt)
print(g.time) # 14:30:00
print(g.to_gregorian_datetime()) # 2024-06-15 14:30:00
API overview
Types
-
GormanDate— A date within a Gorman month (year,month1–13,day1–28, optionaltime). Immutable. Methods include:to_gregorian()/to_gregorian_datetime()— convert to Gregorianfromisoformat(s)— parse ISO date string (YYYY-MM-DD) and convert to Gormanfromordinal(ordinal)— from proleptic Gregorian ordinalfrom_gorman_week_calendar(year, week, weekday)— from (year, week 1–52, weekday 1–7)gorman_week_calendar()— returns(year, week, weekday)replace(...)— return a new instance with fields updatedweekday(),isoweekday(),week_of_month(),week_of_year(),toordinal()__str__— e.g."15 June 2024"
-
Intermission— One intermission day (year,day1 or 2, optionaltime). Immutable. Methods include:to_gregorian()/to_gregorian_datetime()fromordinal(ordinal)replace(...)
Conversion
gregorian_to_gorman(d)—dateordatetime→GormanDateorIntermission(preserves time when given a datetime).gorman_to_gregorian(year, month, day)— Gorman (year, month, day) →date.intermission_to_gregorian(year, day)— Intermission (year, day 1 or 2) →date.
Parsing
parse_gorman(date_string)— Parse a Gorman date string and return a Gregoriandatetime. Supports:"15 June 2024","June 15, 2024"- Optional time:
"15 June 2024 14:30" "Intermission 1 2024","Intermission 2 2024"(leap years only for day 2)
Constants
GORMAN_MONTHS— Tuple of 13 month name strings (March … Gormanuary).
Development
git clone https://github.com/BGarber42/dateutil_gorman.git
cd dateutil_gorman
uv sync --all-extras
uv run pytest
uv run mypy src
uv run ruff check src tests
License
MIT. 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dateutil_gorman-0.1.1.tar.gz.
File metadata
- Download URL: dateutil_gorman-0.1.1.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f9d5543d7d970b5dc20a7f1cf8089da727a3998ae5ec3f89e8601f384f1a392
|
|
| MD5 |
d421440c880ef4fbc06118fd1564e7e0
|
|
| BLAKE2b-256 |
285a20cea97ebfd6970d1c8141a20b5aeb1a4b553491914033c73e32a26cf2c2
|
Provenance
The following attestation bundles were made for dateutil_gorman-0.1.1.tar.gz:
Publisher:
publish.yaml on BGarber42/dateutil_gorman
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dateutil_gorman-0.1.1.tar.gz -
Subject digest:
5f9d5543d7d970b5dc20a7f1cf8089da727a3998ae5ec3f89e8601f384f1a392 - Sigstore transparency entry: 871193634
- Sigstore integration time:
-
Permalink:
BGarber42/dateutil_gorman@5045d8e6d26735e222f4ac3a4cf7edf82f3c27f2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/BGarber42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5045d8e6d26735e222f4ac3a4cf7edf82f3c27f2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dateutil_gorman-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dateutil_gorman-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfb2a16e2341abce75dc3531dc4a82f30a50829f75c09c5f912c36804afaaf04
|
|
| MD5 |
1f6bfa4f97bcec3402044a0c830b15a3
|
|
| BLAKE2b-256 |
4cfeb8c521b888b7d096d790fa9e7f38baf771de2beb8cc1bc612573368016e7
|
Provenance
The following attestation bundles were made for dateutil_gorman-0.1.1-py3-none-any.whl:
Publisher:
publish.yaml on BGarber42/dateutil_gorman
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dateutil_gorman-0.1.1-py3-none-any.whl -
Subject digest:
cfb2a16e2341abce75dc3531dc4a82f30a50829f75c09c5f912c36804afaaf04 - Sigstore transparency entry: 871193641
- Sigstore integration time:
-
Permalink:
BGarber42/dateutil_gorman@5045d8e6d26735e222f4ac3a4cf7edf82f3c27f2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/BGarber42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5045d8e6d26735e222f4ac3a4cf7edf82f3c27f2 -
Trigger Event:
push
-
Statement type: