Loading
Code Deb

Nepali Calendar SDK: BS/AD Dates, Historical Coverage and Integration Design

Integrate Bikram Sambat and Gregorian dates reliably with documented conversion ranges, timezone-safe calendar days, test cases and source provenance.

Two blue calendar panels connected by bidirectional arrows illustrate Bikram Sambat and Gregorian date conversion.

A date conversion library can round-trip a date perfectly while still returning the wrong calendar day. If both conversion directions share the same incorrect table, the internal consistency test passes. Calendar correctness therefore requires independent anchors and a declared supported range.

Turn the supported year range into a test inventory

The Code Deb Nepali Calendar documentation distinguishes the default BS 2080–2083 conversion range, the historical BS 1975–2083 month data and a wider website converter. Four inclusive years represent 48 months. The 109 historical year labels represent 1,308 potential monthly entries. A plan that checks first day, last day, day zero and day after the last for every historical month would contain 5,232 cases. These are generated coverage counts, not executed calendar-accuracy tests or proof of independently verified dates.

Keep a calendar day separate from an instant

type CalendarDay = {
  calendar: "BS" | "AD";
  year: number; month: number; day: number;
  datasetVersion?: string;
};
// A check-in timestamp is a separate UTC instant.
// Business deadlines additionally need a named time zone.

A holiday or leave day should not change because the device timezone changes. A timestamp should represent an instant with explicit timezone semantics. MDN's Temporal.PlainDate reference describes a calendar-date abstraction; it does not by itself implement Bikram Sambat conversion. Use the IANA timezone database for time-zone rules rather than a hand-coded fixed offset for all historical dates.

Why a round-trip is necessary but insufficient

For each supported date, BS to AD to BS should return the original value. This catches some indexing and off-by-one problems, especially around month and year boundaries. But a shared incorrect month length can shift every later date consistently in both directions. Compare independent dated references, especially around an observed mismatch. Record the provenance of every source and distinguish independently checked anchors from table-derived dates.

Fiscal periods and public holidays are not conversion functions

An application can convert a leave date without knowing whether it is a working day. Fiscal year labels, holiday lists and payroll policies must be configured separately with their own sources. Do not infer a government holiday from a festival name or calculate a fiscal year by adding a fixed year offset. Our BS/AD and holiday guide explains the distinctions, while invoice sequence research shows why fiscal policy needs explicit ownership.

A reliable integration has a migration policy

Reject unsupported days rather than extrapolating BS month lengths. Persist the source representation and dataset release where later corrections would affect business records. Use a new revision for corrected dates and review existing bookings, invoices or attendance instead of silently rewriting historical evidence. The original calendar engine is credited to Aayush Acharya, with third-party data provenance retained. Try the interactive calendar and the npm package within the documented coverage. The proposed test inventory is a starting point; government-grade accuracy requires independently verified reference data.

Method and reproducibility: Generated coverage inventory. See Code Deb's recorded experiment results and reproduction script in the repository. Figures are reproducible from declared inputs, not undisclosed client outcomes. The cited external material is independent of Code Deb's experiment.

More from Code Deb

Read about our agency, explore available services, or contact the team for a project discussion.