Expand description
Shahanshahi (Imperial Iranian) calendar.
This crate is spec-first: SPEC.md
defines calendar rules (SPEC_VERSION). Golden rows in data/reference-dates.json anchor tests;
public APIs may still evolve before 1.0.0 (see SemVer policy in the repo changelog).
§Types
ShahanshahiDate— civil year / month / day with 1925 month lengths and Mode A leap (33-year arithmetic on the underlying Hijri Shamsi year). By default, only dates inside the documented legal Shahanshahi civil era are accepted; see that type’s docs for bounds and errors.GregorianDate— proleptic Gregorian anchor calendar for bidirectional conversion via Rata Die (ShahanshahiDate::to_gregorian,ShahanshahiDate::try_from_gregorian).
§Features
std(default) —std::error::Errorfor date errors; disable withdefault-features = falsefor#![no_std]builds (core-only algorithms and types).proleptic—ShahanshahiDate::try_new_prolepticvalidates the same calendar grid without enforcing the legal era (SPEC.md § Proleptic use).serde—serdeSerialize/DeserializeonShahanshahiDateandGregorianDate(optional dependency withdefault-features = false).chrono—chrono::NaiveDateconversions onGregorianDateandShahanshahiDate(impliesstd).time—time::Dateconversions onGregorianDateandShahanshahiDate(impliesstd).
Structs§
- Chrono
Naive Date OutOf Range - The Gregorian civil date is valid for
GregorianDatebut cannot be represented as achrono::NaiveDate(chrono limits the representable year range). - Gregorian
Date - A valid proleptic Gregorian civil date (
year,month1..=12,dayconsistent with month/leap rule). - Shahanshahi
Date - A valid civil date in the Shahanshahi (Imperial Iranian) calendar: 1 = Farvardin … 12 = Esfand,
with month lengths from the 1925 solar civil law (SPEC.md § Months). Leap Esfand uses Mode A
(33-year arithmetic) on the underlying Hijri Shamsi year
Y_H = Y_S − 1180.
Enums§
- Gregorian
Date Error - Why a
GregorianDatecould not be constructed. - Shahanshahi
Date Error - Why a
ShahanshahiDatecould not be constructed.
Constants§
- SPEC_
VERSION - Tracks which written specification version this build targets.
Functions§
- is_
shahanshahi_ leap_ arithmetic - Shahanshahi leap year using Mode A (same solar year as underlying Hijri Shamsi).
- is_
solar_ hijri_ leap_ arithmetic - Solar Hijri leap year per the 33-year arithmetic rule (Heydari-Malayeri / Borkowski range).
- shahanshahi_
to_ hijri_ shamsi_ year - Underlying Solar Hijri year from Shahanshahi year (proleptic offset).