Engineering Architecture: The Mechanics of Sidereal Solar Conversion
Converting dates between the Western Gregorian calendar and Nepal's Bikram Sambat civil calendar involves fundamental differences in astronomical celestial reference frames. The documentation below outlines the mathematical principles and compression techniques utilized by this kernel.
Sidereal vs. Tropical Solar Years
The Gregorian calendar is a tropical solar calendar tied to the vernal equinox (365.2422 days). Bikram Sambat is a sidereal solar calendar (365.2563 days) based on the Sun's apparent entry into fixed zodiacal constellations (Sankranti). Because the Earth travels on an elliptical orbit, month lengths vary from 29 to 32 days depending on orbital velocity.
O(1) Bit-Packed Month Matrix
Instead of shipping hundreds of kilobytes of JSON day structures, this engine compresses each year's 12 months into a single 24-bit integer. Each month occupies exactly 2 bits, offset from a baseline of 29 days (producing 29, 30, 31, or 32 days). All 131 verified years (1970 to 2100 BS) consume only 524 bytes in memory.
Astronomical Tithi Formulation
A Vedic Tithi represents a 12-degree elongation of the Moon relative to the Sun. Using truncated terms from the Jean Meeus lunar perturbation model, the engine computes real-time solar and lunar ecliptic longitudes directly at the Kathmandu meridian (27.7172° N, 85.3240° E) to identify the active Tithi, Paksha, and Nakshatra.
Calendar Systems Comparative Matrix
| Parameter | Bikram Sambat (BS) | Gregorian Calendar (AD) | Engine Handling |
|---|---|---|---|
| Calendar Class | Sidereal Solar (Surya Siddhanta) | Tropical Solar | Continuous Julian day conversion |
| Month Lengths | Variable (29 to 32 days based on Sankranti) | Fixed (28 to 31 days with leap rules) | 2-bit bitwise unpacked per month |
| Epoch Anchor | 57 BCE (Commemorating Vikramaditya) | 1 CE (Anno Domini) | Calibrated to 1913-04-13 UTC = 1970-01-01 BS |
| Official Status | Constitutional & Civil Calendar of Nepal | International Standard (ISO 8601) | Bidirectional legal fidelity |
Frequently Asked Chronometry Questions
Why does converting AD to BS require an astronomical lookup table instead of simple addition?
While Bikram Sambat is approximately 56.7 years ahead of the Gregorian calendar, a simple addition of 56 years and 8 months causes legal and administrative errors of up to 4 days. Bikram Sambat is a sidereal solar calendar governed by the Surya Siddhanta, where month lengths fluctuate between 29 and 32 days based on the exact moment the Sun transits into a new zodiac sign (Sankranti). Because Earth moves faster at perihelion and slower at aphelion, an astronomical matrix is mandatory for official legal validity.
How does the date engine compute Vedic Tithi without external network calls?
The engine runs a client-side implementation of Jean Meeus astronomical algorithms and NOAA solar coordinates. It calculates the Julian Day Ephemeris, determines the true ecliptic longitudes of both the Sun and the Moon with major periodic perturbation terms, and computes the angular phase separation (Moon Longitude minus Sun Longitude). Dividing this 360-degree lunar phase into 30 equal 12-degree arcs yields the exact Tithi (Pratipada through Purnima or Amavasya) in real time.
What is the memory and execution footprint of this converter?
The core month matrix is bit-packed using 2 bits per month (values 0 to 3 representing 29 to 32 days). All 12 months fit into a single 24-bit integer per year, allowing the entire 131-year solar continuum (1970 to 2100 BS) to be stored in just 524 bytes. A bidirectional conversion executes in under 0.05 milliseconds with O(1) algorithmic time complexity.
Is Bikram Sambat the official calendar for legal and civil purposes in Nepal?
Yes. Bikram Sambat (वि.सं.) is the sole constitutional and civil calendar recognized by the Government of Nepal for citizenship certificates (नागरिकता), passports, land ownership deeds (लालपुर्जा), banking transactions, court documents, and civil service appointments.