Skip to main content

Crate nepdate_patro

Crate nepdate_patro 

Source
Expand description

NepDate logo

nepdate-patro

nepdate-patro on crates.io docs.rs CI License: MIT

The patro (पात्रो, the Nepali almanac) for the nepdate crate: tithi, the Nepal public holiday flag and events for each Bikram Sambat day. no_std, no heap allocation, no unsafe. Every lookup is O(1) over per-day tables compiled into the crate, and every name is a &'static str.

Status: 0.1.0-beta.1, the first public pre-release. The API may still change before 0.1.0. Holiday data is informational, not an official calendar.

§Quick start

[dependencies]
nepdate = "=0.1.0-beta.1"
nepdate-patro = "=0.1.0-beta.1"
use nepdate::{Lang, NepaliDate};

let info = nepdate_patro::info(NepaliDate::new(2081, 1, 1)?);
assert_eq!(info.tithi().map(|t| t.name(Lang::En)), Some("Panchami"));
assert!(info.is_public_holiday());
assert_eq!(info.events().next().map(|e| e.name(Lang::En)), Some("New Year"));
assert_eq!(info.events().next().map(|e| e.name(Lang::Ne)), Some("नयाँ वर्ष"));

// Every public holiday in the data, in order.
let first = nepdate_patro::public_holidays().next();
assert!(first.is_some_and(|d| nepdate_patro::coverage().contains(d)));

info never fails: a day without data, inside or outside the coverage, gets an empty info (no tithi, not a holiday, no events).

§Data coverage

DataFromTo
Days with data (coverage())BS 2077-01-01BS 2084-08-20
TithiBS 2078-01-02BS 2083-12-30
Public holidaysBS 2077-01-01BS 2084-08-18

Coverage grows through patch releases when the shared data is updated. Holidays the government announces late are missing until the next data update.

§Versions

This crate’s version always equals nepdate’s. Both are released together from one tag, and nepdate-patro X.Y.Z depends on nepdate ~X.Y.0. A pre-release such as 0.1.0-beta.1 depends on exactly that nepdate pre-release (=0.1.0-beta.1), so one beta of this crate never runs with another beta of the core. Use the same version for both.

§Data, provenance and license

The tithi, holiday and event data come from NepDate by Raju Prasai and contributors, used under the MIT License. Its notice ships in this crate as LICENSE-THIRD-PARTY. NepDate has not published where its tithi, holiday and event data came from. That question is open with its author (known data questions).

Holiday data is informational. This crate is not affiliated with the Government of Nepal; check the government’s official notice before relying on a holiday.

This crate is MIT licensed (LICENSE). Semantics of every field: PATRO.md.

§More

TopicWhere
What changed in each versionCHANGELOG.md
Speed against C# NepDate and other cratesbenchmarks
Reporting a vulnerabilitySECURITY.md
A wrong date, holiday or tithithe hub’s data error form
The other languagessanamhub/nepdate

Structs§

CalendarInfo
What the patro says about one day, from info. Six bytes, Copy.
Event
One event of a day, from Events.
Events
The events of one day, from CalendarInfo::events.
Tithi
A tithi (lunar day), from CalendarInfo::tithi.

Functions§

coverage
The smallest BS range that holds every day with any data: 2077-01-01 to 2084-08-20 with the data compiled into this version.
info
The tithi, public holiday flag and events of one BS day (PATRO §2).
public_holidays
Every public holiday, in ascending date order.