Introduction

A calendar reflects growth and richness in human civilization. Inclined towards culture, it has equal significance in Astronomy and Mathematics.

Nepal Samvat Calendar is a lunisolar existing since 879 CE. It determines the exact date of Nepal's cultural events and festivals. There is a proper algorithm to analyze the calendar from a mathematics and scientific perspective; furthermore, it'll be helpful to create one for any given year, month or day.

Problems

NS lacks the formula for finding out tithis and dates of important festivals for following years. The dates are published only a few days before the NS new year.

This paper aims to explain the algorithm for calculating and solving NS calendar computation problem.

Emergence

Picture

Early Medieval Period & Malla Period

Unlike many calendars, NS was not named after an era or king. Instead, it was named after the Country during the Early Medieval Period (879-1199 CE) and Malla Reign (1200-1769 CE).

Movie

Saka Era

NS is the longest-running newspaper of Nepal, used across India and China since 2015. Ns was commonplace during the Saka era 1769 CE

Picture

1900s

However, in 1903, the Prime Minister, Rana Chandra Shamsher, introduced “Vikram Samvat”, a solar calendar abbreviated as BS. It was named after the king, Vikramaditya from India, Ujjain. It was not originated in Nepal yet became the prominent calendar for the same.

Location

Panchayat Period

In the Panchayat Period (1960-1990), the king and his government adopted the "One nation, one language" ideology that made NS even more inferior. The coming generations might not even know about it.

Location

1980-1990s

The Newah community of Nepal protested to gain the recognition of NS in the 1980-90s. After the significant protests, the Government agreed to come to terms with the Newah community.

Movie

2000s

In 2008, NS was declared to be the National Era of Nepal. The Prime Minister, Dr Baburam Bhattarai, announced NS as a prominent calendar for every community in Nepal. Despite being the most accurate calendar, it is still lesser known than BS. The idea is to throw light on NS's Scientific and Cultural significance.

Nepal Samvat

CORRELATION OF MOVEMENTS OF
CELESTIAL BODIES

Celestial bodies are essential for defining months, seasons and years. It initially measured the movement of how long the moon took to cycle around the earth along with the direction of celestial bodies like earth, moon, sun, and planets, which plays a significant role in many calendars, including NS.

It computes variation in speed across the celestial sphere.

Each new moon indicates the start of a new month, along with the reference of the solar year.

Movement of celestial bodies Fig: Illustration of sidereal and synodic months.

Critical astronomical phenomena playing vital roles in formulation of NS calendar algorithm

A. Sidereal Year

Sidereal year = Time taken for Earth to revolve the sun and align back in position with the sun and the star. This averages 365 days, 6 hours, 9 minutes, and 10 seconds (equivalent to 365.25636 solar days).

B. New Moon

The new moon plays a significant role in the lunar calendar as it indicates the start of the new month.

C. Sidereal Month

Sidereal month is the time it takes the moon to complete a 360° orbit around the earth. It is 27.321661 days long, i.e., 27 days, 4 hours, 43 minutes, and 12 seconds.

D. Synodic Month/Lunation

Synodic Month is the period between two consecutive new moons. The moon takes an additional 2.21 days to position itself into the same line as the earth and sun.

E. Orbit of the Moon, Apogee and Perigee

The moon's orbit around the earth is elliptical. Therefore, its distance from the earth varies. The closest distance, called perigee, is about 363104 kilometers away, whereas the farthest point, called apogee, is about 405696 kilometers away from the earth. The moon travels at its fastest when it is closest to the planet.

F. Tithi / NS Lunar Day

A lunar day of NS, also known as tithi in NS, is the time it takes the moon to traverse 12° on its orbit relative to the new moon. Day one is 0°-12°, day two is 12+°-24°, day three is 24+ °-36°, and so on. Because of the differences in the speeds of the moon and the Earth, all of these are not the same length.

G. Julian Day / Dynamic Time

It is simple to keep track of the days with continuous counting, keeping an arbitrary origin day in the past irrespective of days, months and weeks. Hence, Julian day is the day referred to as the origin day for all other days. This origin point is "epoch day", every day after epoch day is calculated accordingly, keeping the calculation consistent and efficient.

H. Kepler's Law of Planetary Motion

Three laws to describe the motion of the planetary bodies around the sun:

  1. Planets revolve around the sun in an elliptical orbit with the sun at one of the ellipse's foci.
  2. A planet can cover equal area, length, and time regardless of its orbit's position.
  3. A planet's orbital period is proportional to the size of its semi-major axis, the square of its revolution time is proportional to the cube of its semi-major axis.
T2 ∝ a3 (T is the time taken, a is the semi-major axis)

Sunrise

NS lunar day (tithi) is determined when the moon traverses to an angle multiple of 12° relative to the moon's position at the new moon —resulting in the crossover of tithi happening at any time during 24 hours. Consequently, a single 24-hour cycle can overlap two tithis. NS came up with a solution for this confusion by using sunrise as a reference point for the entire day.

The most critical component of NS calendar is Sunrise, day as the whole is named after whichever the tithi moon is at Sunrise.

Hanuman dhoka Fig: Artist’s depiction of Kaal Bhairab.

A specific location is mandatory to compute the sunrise. NS uses the site of Kalabhairava, located at Hanuman Dhoka in Kathmandu, Nepal.

A. Computation of hour angle

The earth rotates at an angular velocity of 15° per hour, representing the time for an observer on the earth's surface. From the observer's perspective, the meridian directly under the sun is called the solar noon. The earth's angle would decide if the observer is far or close from the solar noon, called the hour angle, which is zero at solar noon.

A unit sphere is a radius around a given center, mainly used to calculate angles at a distance. To compute the hour angle, take a unit sphere with the sun as the celestial reference point. The calculation is provided below for the unit sphere at the time of Sunrise:

where, Celestial Equator = projection of earth's Equator into space Horizon = imaginary horizontal plane at 90° from observer's zenith.
X = point of interest (in this case, position of the sun)
Z = zenith (a point in the celestial sphere directly above the observer)
P = north celestial pole
α = angle of the ascension of the sun eastward of horizon
δ = angle of declination of the sun measured north/south of the celestial Equator
φ = latitude of the observer concerning the earth's Equator
ω = hour angle

Calculate sunrise

The hour angle of a point is the angle between two planes: one containing the earth’s axis and the meridian plane, and the other containing the earth’s axis and the given point. The hour angle may be measured in degrees or in time, with 24 hours equaling to exactly 360°, i.e., 1 hour = 15°. Computation of the hour angle makes computation of the time of sunrise and sunset easier.

Using spherical law of cosines on above unit sphere, we get:
$$ cos(Π/2 - α)= cos(Π/2 - δ).cos(Π/2 - θ) + sin(Π/2 - δ).sin(Π/2 - θ) cosω $$

Or,

$$ 𝑠𝑖𝑛𝛼 = 𝑠𝑖𝑛𝛿. 𝑠𝑖𝑛𝜙 + 𝑐𝑜𝑠𝛿. 𝑐𝑜𝑠𝜙. 𝑐𝑜𝑠𝜔 $$
Since, at sunrise, α =0, the hour angle at sunrise 𝜔𝑜 is given by,
$$ θ=𝑠𝑖𝑛δ. 𝑠𝑖𝑛Φ+𝑐𝑜𝑠δ.𝑐𝑜𝑠Φ.𝑐𝑜𝑠ω_ο $$

Thus,
$$ 𝑐𝑜𝑠ω_ο = -tanδ.tanΦ $$

B. Algorithm to compute time of sunrise

Astronomical Algorithms by Jean Meeus, is used to derive the algorithm to compute the time of sunrise for a given day as below:
jd = julian day of a given day (input parameter)

To use the pre-known constants, the epoch date is set at noon of Jan 1, 2000. The number of days since this date (n) can be computed as:
$$ n = [ jd-2451545.0 + 0.0008 ] $$
$$ mean‐solar‐time = n- λ/360° $$ where, λ is the longitude of observer

Solar mean anomaly (M) can then be defined as:
$$ M = (357.5291 + 0.9856008 × mean - solar- time)mod 360 $$
Equation of the center is then defined as,
$$ C = 1.9148 sin(M) + 0.0200sin(2M) + 0.0003sin(3M) $$ Ecliptic longitude can then be computed as,
$$ λ_e = (M+C+ 180 + 102.9372) mod 360 $$
Declination of the sun can thus be computed as,
$$ sinδ = sinλ_e × sin22.44° $$
Adjusting for atmospherical refraction, the hour angle be computed as:
$$ cosω_0 = {sin(-0.83°) - sinΦ×sinδ} / {cosΦ×cosδ} $$

Local true solar transit (or solar noon) at the location for given day can then be computed as: Solar-transit = 2451545.0 + mean-solar-time + 0.0053 sin (M) – 0.0069 sin (2 $$ λ $$)

We can now define the sunrise equation for a given day (jd) at location (with longitude $$ λ $$ and latitude $$ Φ $$) as:
sunrise-equation(jd, location) $$ =↖ {def}$$ solar‐transit + $$ ω_0/ 360° $$
This equation is used to compute the time of sunrise for the NS calendar algorithm.

Movements of moon

The NS calendar is highly dependent on the motion of the moon in the celestial sphere. The month starts with the new moon, and each day is defined as the time it takes the moon to traverse 12°.

As a result, calculating the moon's movements is critical in developing an algorithm for the NS calendar.

A. Solar Logitudes

Solar longitude defines the position of the sun in the celestial space relative to the observer on Earth. This angular value plays a very significant role in the formulation of the NS calendar algorithm.

The sun appears to move in orbit around the Earth when viewed from Earth (denoted by E in the above Fig). Assume the sun is in an elliptical orbit around the earth to calculate its position. We know from Kepler's law that a planet covers the same amount of space in the same amount of time regardless of its orbital position. The speed may vary depending on the sun's proximity to the earth. Consider Kepler's orbit around the ecliptic path, in which the sun moves in a circle around the earth at a constant speed rather than along the elliptic path that it follows

Calculate solar longitude Fig Geometry to compute solar longitude

Mean anomaly, $$ M_o $$, which is the angle between perigee and the sun with respect to epoch can be computed as:
$$ M_o= 360/365.2422×d + εg-ωg $$

where,

d = number of Julian days since epoch,
$$ εg $$= ecliptic longitude at epoch,
$$ ωg $$= ecliptic longitude of perigee at epoch
For the epoch of Jan 1, 1980, values of εg 𝑎𝑛𝑑 ωg are 278.833540 and 282.596403, respectively.

Eccentric anomaly, E is calculated as:
$$ E - e ×sin E = M_o radians $$
where,

e is eccentricity of orbit at epoch (at epoch 1980 it’s taken as 0.016718)
The following steps can further be run to get more accurate values:
Step 1: Set initial condition as, E = E _ 0 = M _ 0
Step 2: Find the value of $$ δ = E – e × sin 𝐸– 𝑀_0 $$
Step 3: If $$ ∣δ∣ ≤ ε $$ go to step 6.
Step 4: Find $$ ΔE= δ/(1- e × cos E) $$
Step 5: Take new value $$ E = E − ΔE $$. Go to step 2.
Step 6: Current value of E is the solution, correct to within $$ ε $$ of the true value.
Once we get the true value, we can now get the true anomaly ($$ v $$) by following equation:

$$ v = 2 × tan^{-1}(√{(1 + e)/(1-e)} × tan (E/2)) $$

Conversion from radians to degrees is required for as the solar longitude computed below is in degrees.
Thus, the sun’s ecliptic longitude can now be defined as:
$$ λ = v + ω_g degrees $$
For usage of this value in our NS calendar algorithm, we will define solar longitude as:
solar-logitude (jd) = $$ λ $$

B. Lunar Longitude

The figure below shows the movement of the moon in sidereal and synodic months.

Lunar solar longitude Fig. Orbits of Moon and Earth relative to each other

There are three main effects of perturbations caused by the sun on the moon’s apparent orbit around the earth.

  1. The first is due to the evection in which the apparent value of the eccentricity of the moon’s orbit varies slightly.
  2. The second is due to the variation of the earth-sun distance as the earth travels in its own ellipse around the sun. This correction is called the annual equation.
  3. The third inequality takes account of the motion of the moon in the sun’s gravitational field.

These corrections, together with the usual correction, is called the equation of the center.
We calculate factors for the moon as below:
Moon’s mean longitude, $$ l_m $$, given by
$$ l_m = 13.1763966 × D + L_o $$
where,
D is the number of days since the epoch to the required date and time, and $$ L_o $$ is the mean longitude of the moon at the epoch. For the epoch of 1980.0, the value is 278.833540
Moon’s mean anomaly, $$ M_m $$, given by
$$ 𝑀_m = 𝑙_m - 0.1114041 × D - P_o $$

Moon Orbit Fig: Defining Moon’s orbit
where,
$$ P_o $$ is the moon’s mean longitude of the perigee at the epoch. For the epoch of 1980.0, the value is 64.975464.
Next, we calculate the corrections for evection $$ (E_v) $$ ; the annual equation, $$ (A_e) $$; and a third correction, $$ (A_3) $$
$$ Ev = 1.2793 × sin(2(l_m - λ)- M_m) $$
$$ Ae = 0.1858 × sin(M_m) $$
$$ A_3 = 0.37 × sin(M_m) $$
where,
$$ λ $$ = solar coordinate for given jd
With these corrections, we can find the moon’s corrected anomaly, $$ M{^'}_m $$:
$$ M{^'}_m = M_m + Mv - Ae - A_3 $$
Correction for the equation of the center can be computed:
$$ Ec = 6.2886 × sin(2M{^'}_m) $$
Then, another correction term A4 is computed as:
$$ A_4 = 0.214 × sin (2M{^'}_m ) $$
Now, we can find the value of the moon’s corrected longitude, $$ l{^'} $$ from:
$$ l{^'} = l_m + Ev + Ec + Ae + A_4 $$
The final correction to apply to the moon’s longitude is the variation, V, given by:
$$ V = 0.6583 × sin (2(l{^'} - λ)) $$
Then, the moon’s true orbital longitude is defined as:
lunar-longitude(jd) $$ =↖ {def} l{^'} + V$$

C. New Moon

The most important astronomical event on the NS calendar is the new moon.

The key to the success of the algorithm for NS depends on the computation of the day and time of the new moon.

The following algorithm can be used to find the day and time of new moons closest to a given day (converted to Julian day, jd). We will call the new moon that occurs before jd as "last new moon" and the one after as "next new moon."

The epoch used for this algorithm is noon of Jan 1, 1900. All epoch-specific constants are used based on this date

New moon

Traverse 45 days earlier to given date as:
$$ jd = jd - 45 $$ Number of lunar cycles passed since 1900 is given by:
$$ k = l (j/ (jd_{year}) + (jd_{month} - 1) /12 - 1900) × 12.985 $$
Where, 12.985 is the number of lunar cycles per year Number of days since 1900 can be computed as:
$$ jd = jd - 45 $$
Number of centuries passed can be defined as:
number-of-centuries(n) = $$ n/36525 $$
Number of centuries since 1900 to given day given by:
t = number-of-centuries(jd - 2415021)
Approximate day of a new moon can be derived from following equation:
Mean-new-moon $$ (jd, k, t) = (2415020.75933 + 29.5306 × k + 0.0001178 × t^2 - 0.000000155 × t^3 + 0.00033 × sin (166.56 + 132.87 × t - 0.009173 × t^2)) $$
where,
k = number of lunar cycles and t = number of centuries since 1900 for a given day (jd)
The value of the approximate new moon date can now be:
nt = d = mean-new-moon (jd, k, t)
We can now adjust this approximate value further by using the following steps:
Step 1: Calculate parameters for next new moon:
$$ d = d + 29.5306 $$
$$ k^' = k + 1 $$
$$ t = number-of-centuries( d - 2415021) $$
Step 2: Get the approximate new moon day
$$ nt^' = d^' = $$ new-moon-calc $$ (d, k1, t) $$
Step 3: If $$ nt ≤ d $$ and $$ d < nt^' $$, go to step 5.
Step 4: Go to Step 1 with reassigned values:
$$ nt = nt^' $$ ; and $$ k = k^' $$
Step 5: The final value for the lunar cycle is $$ k^' $$

True Phase Algorithm:
Now that we have the final value for the lunar cycle, the following steps can further be utilized to get the true value for the new moon:
true-phase-nm $$ k^' $$ is defined as:
Get the value of centuries from the number of lunar cycles:
$$ t = k^' / {1236.85} $$
Where, 1236.85 is the number of lunar cycles in a century. Calculating the mean new moon phase for this lunar cycle:
nt1 = mean-new-moon $$ (jd, k^', t) $$
Other factors for corrections to get the true phase are:
Solar mean anomaly:
$$ M = 359.2242 + 29.10535608 × k^' - 0.0000333 × t^2 - 0.00000347 × t^3 $$
Lunar mean anomaly:
$$ M_m = 306.0253 + 385.81691806 × k^' + 0.0107306 × t^2 + 0.00001236 × t^3 $$
Moon’s argument of latitude:
$$ L_m = 21.2964 + 390.67050646 × k^' - 0.0016528 × t^2 - 0.00000239 × t^3 $$

We get the final true time of the new moon for the given date.
$$ nm^{'} = nt1 + (0.1734-0.000393 × t) × sin(M) + 0.0021 × sin(2M) - 0.4068 × sin(M_m) + 0.0161 × sin(2M_m)-0.0004 × sin(3M_m) + 0.0104 × sin(2L_m) - 0.0051 × sin(M + M_m) + 0.0074 × sin(M - M_m) + 0.0004 × sin(2L_m + M) - 0.0004 × sin(2L_m - M) - .0006 × sin(2L_m + M_m) + 0.0010 × sin(2L_m - M_m) + 0.0005 × sin(M + 2M_m)) $$
True phase of the new moon for lunar cycle $$ 𝑘^{'} $$ can be defined as:
get-last-new-moon(jd) = $$ =↖{def} true‐phase-nm(k^{'}) $$
The equation to compute the day and time of the next new moon for a given day (jd) can be defined as:
get-next-new-moon(jd) = $$ =↖{def} true‐phase-nm(k^{'} + 1) $$

Representation of NS Calendar

Unlike other solar or lunar calendars, each month of NS is divided into two parts called Tho and Ga Paksha. NS calendar faces obnoxious behavior when a month number is reused or skipped. Moreover, when a day is repeated or missed. NS came up with a new structure to represent a day in the NS calendar to avoid these abnormalities

Reference [1], Coding and Decoding of NS Tithis by Dr. Bhagawandas Manandhar, is used for the representation of a day in the NS calendar as below:

Date Representation Fig: Day format of NS calendar

Representation format is defined as:
NS-Day-Format $$ =↖ {def} yyyy.MMmP.DDdw $$
where,
yyyy = NS year is represented with 4 digits
MM = Month of the year (from 1 to 12)
m = 3 if Analā, 4 if Nhalā, 0 otherwise
P = 1 if Tho, 2 if Ga
DD = Day of the month (from 1 to 15)
d = 8 if the day is repeated, 9 if the day is after a skipped day, 0 otherwise
w = day of the week

A. Paksha

Paksha Fig: Pakshas in NS

One fortnight is called "Paksha", and a month has two pakshas in the NS calendar consisting of maximum 15 days. The first Paksha, "Shukla paksha" or "tho", represents the luminosity of the moon's crescent getting brighter by the day. Whereas the second Paksha, "Ga" or "Krishna Paksha", is most likely to lower the same luminosity. Hence, paksha and month number determine the month in the NS calendar.

B. Month

There are 12 months, followed by a month type and paksha number. Perhaps, a leap year would make a year split into 13 months, followed by a number 3, denoting Analā in the same month number.

Months Fig: Months in NS Calendar

For example: if a leap month falls in the second month of the year, it will consist of two months denoted by 2,0 and 2,3. Similarly, with Nhalā, the same month number can be repeated. For example – if the third month is skipped in a given year, the months be sequenced as 2,0 then 2,4 followed by 4,0.

C. Tithi

Tithis are days, denoted by 1-15 numbers. Day 15 represents a full moon for Tho Paksha and a new moon for Ga Paksha. However, tithis can be repeated or skipped at times. If repeated, the second tithi would be added as a suffix of 8 to denote repeat and 9 if it is skipped. For example: 1,0 | 1,8 | 2,0 | 4,9 is a valid tithi sequence.

Tithis Fig: Tithis in NS calendar

Nepal Samvat Calendar Algorithm

A. Epoch and Julian day

Every calendar has an epoch or starting date. The NS era began on Oct. 24, AD 879.

The Julian day number represents a given date as the number of days that have passed since the creation of the world, which was then considered to be on Jan. 1, 712 BCE at noon.

Below are a few epochs and corresponding Julian days that were utilized to test this algorithm. Any other epoch date can be used in place of these.
ns‐epoch $$ =↖ {def} 2042404.5 $$ | Oct 24, 879
ad‐epoch $$ =↖ {def} 2451545.5 $$ | Jan 1, 2020
Using these values, a Julian day of any given date can be computed as below. This value is utilized to compute other components of the calendar in this algorithm.
jd $$ =↖ {def} $$ epoch‐jd + number of days from epoch

B. Sunrise

The time at sunrise plays a very significant role in the computation of the NS calendar. We use the following constants for computing time of sunrise:
location $$ =↖ {def} \{\table \ city = kathmandu; longitude (λ) = 27.7172; latitude (Φ) = 85.3240 $$
The time of sunrise is computed by passing these constants to the sunrise equation:
sunrise‐time (jd) = sunrise‐equation(jd, location)

C. Lunar angle at sunrise

The lunar angle in a new moon is effectively 0 degrees. Similarly, during a full moon, the lunar angle is 180 degrees. Lunar angles are relied upon heavily for calculations in lunar calendars and lunisolar calendars.
The lunar angle or lunar phase at any given time (t) can be computed as:
lunar‐angle(t) = lunar‐longitude(t) − solar‐longitude(t)

D. Tithi (Lunar Day)

The lunar day (tithi) in NS is defined as:
tithi $$ =↖ {def} ⌈{lunar‐angle‐at‐sunrise}/ 12 $$

E. Paksha (half lunar cycle)

Paksha in NS is defined as:
paksha $$ =↖ {def} \{\table \ 1(Tho) , tithi ≤ 15; 2 (Ga), otherwise $$

F. Tithi Names (Representation)

Tithi names in NS are defined as:
tithi‐name $$ =↖ {def} \{\table \ tithi , paksha = 1; tithi-15, paksha = 2 $$

NS CALENDAR TITHI NAMES

Numerical representation is used as the day number in the calendrical representation scheme. Traditional names each day represented by numbers from the above equation can be mapped as:

tithi-name Traditional Names of a Tithi
In English In Nepal Bhasha
1 Paru पारु
2 Dwitiya द्वितीय
3 Tritiya तृतीया
4 Chaturthi चतुर्थी
5 Panchami पञ्चमि
6 Sashthi षष्ठी
7 Saptami सप्तमी
8 Astami अष्टमी
9 Nawami नवमी
10 Dashami दशमी
11 Ekadashi एकादशी
12 Dwadashi द्वादशी
13 Trayodashi त्रयोदशी
13 Chaturdashi चतुर्दशी
15 Punhi (at Tho), Ammai (at Ga) पुन्ही (थ्व), आमै (ग)
Data collected from traditional printed calendars and experts in Nepal Bhasa

G. Duration of Tithi

The first lunar day (Tho, Paru) begins when the lunar angle is zero degrees and ends when it is twelve degrees. The temperature ranges from 12 to 24 degrees on the second day, and so on. However, the time at which the lunar angle will be at a given angle cannot be calculated using the equation because it is dependent on lunar longitude and solar longitude, both of which can vary independently at any given time. To solve this problem, we use the Lagrange Inversion theorem, as shown below:
Calculate lunar angle degrees left to reach a multiple of 12:
Degrees-left = $$ (l {lunar‐angle‐at‐sunrise}/12 ) × 12 - $$ lunar‐angle‐at‐sunrise
Define offsets for one day (number of offsets can vary):
$$ x $$ = [0.25, 0.50, 0.75, 1.0]
$$ y $$ = [lunar‐angle (sunrise‐time + t) – lunar‐angle‐at‐sunrise]; where t in x
$$ y_a $$ = degrees‐left
tithi‐duration = InverseLagrange ( $$ x, y, y_a $$ ); where InverseLagrange is given by:
$$ L(y_a) = ∑↙{i=0}↖n {x_i}( ∏ ↙{0 ≤ j ≤ n} ↙{j ≠ i} {y_a - y_j} / {y_i - y_j}) $$

H. Month

Month name can be computed as:
new‐moon‐day = get‐last‐new‐moon(jd)
Solar longitude at the new moon is:
solar‐longitude‐at‐new‐moon= solar‐longitude(new‐moon‐day)
NS months are divided into 12 equal months. Therefore, dividing above longitude (in degrees) by 30 should give the numerical representation of the month‐name as:
ns‐month‐name (jd) $$ {= ↖ {def}} ⌈{solar‐logitude‐at‐new‐moon}/30 $$
If the epoch date is picked at the new moon of the first month of the NS calendar, equation above should give the correct numerical representation of the month.

I. Leap Month (Analā)

Leap month Fig: Tithis in NS calendar

An average synodic month (number of days between two new moons) is about 29.530588 days (29 days, 12 hours, 44 minutes). NS months are synonymous with the synodic month. Therefore, an NS year lasts around 354.4 days, which is more than ten days shorter than the tropical year. This causes the NS months not to sync with the seasons (which are based on the solar phase) over time. To solve this problem, a leap month is introduced every three years, making a leap year with 13 months. This month is called Analā in the NS calendar.
An Analā month can be identified for given jd as:
new‐moon = get‐last‐new‐moon (jd)
this‐month = $$ ⌈{solar‐logitude (new‐moon) }/30 $$
next‐new‐moon = get‐last‐new‐moon (jd)
next‐month = $$ ⌈{solar‐logitude (next‐new‐moon) }/30 $$

J. Skipped Month (Nahalā)

Nhalā occurs when an extra solar month is skipped between two new moons, as defined by the definition. As a result, the month difference between the new moon and the next new moon should be 2.
nahalā $$ =↖ {def} \{\table \ 1(Yes) , (this‐month - next‐month) = 2; 0 (No), otherwise $$

K. Year

The Kaliyuga epoch can be used to calculate the NS year for greater precision. At the beginning of Kaliyuga, Aryabhatiya of Aryabhata mentions the conjunction of all planets, moon, and node. The Kaliyuga epoch is well defined as 17/18 February 3102 BC, which gives the Kaliyuga epoch a Julian day number of 588465.5. After adjusting it for the current month, the offset table below can be used to convert it to the appropriate year in each era.
NS CALENDAR TITHI NAMES

Era Current Year Elapsed Year
Kali Yuga +3180 +3179
Saka +1 +0
Nepal Samvat +801 +800
Vikrama +136 +135
Bengal -515
Data collected from Calendrical calculations by Reingold and Dershowitz
NS year is computed as:
$$ days‐since‐ky = jd-588465.5 $$
$$ ky‐year = ⌊{{days‐since‐ky + (10 - ns‐month) × 30} / 365.25636 } $$
$$ saka‐year = ky‐year - 3179 $$
$$ ns‐year =↖ {def} saka‐year - 800 $$

L. NS Date

NS date can be represented utilizing components derived from previous sections as:
$$ ns‐date =↖ {def} YYYY.MMmP.DDdw $$
where,
$$ YYYY = ns‐year $$ from eq.6.14
$$ MM = ns‐month $$ from eq.6.12
$$ m = ns‐month-type $$ from eq.6.10
$$ P = Paksha $$ from eq. 6.12
$$ DD = tithi‐name $$ from eq. 6.7
$$ d = tithi‐type $$ from eq. 6.6
$$ w = day of week $$

Conclusion

A new algorithm for solving the NS calendar computation problem is presented. The algorithm is based on astronomical calculations and the transformation of traditional concepts into mathematical formulas.

The proposed algorithm is computationally tested and compared to the historical calendar for accuracy.

The algorithm can generate calendars for both the past and the future.

Discussion and Opinion

NS originated, remained the most prevalent calendar throughout its history, and is still widely used in Nepal for cultural events. However, it lacks official recognition to the point where most people (even in Nepal) are unaware of the masterpiece left behind by their forefathers.

ACKNOWLEDGMENT

The author would like to thank Maninder Virk and Arun Thapa for their help with the research. Dr. Bhagawandas Manandhar, Gokul Manandhar (Paubha Sayami), and Rajendra Ranjit (Newa Suchana Kendra) were also essential in the research by providing cultural, linguistic, and traditional insights. The entire Spiralogics, Inc. team deserves credit for creating an application based on this research and assisting in the validation of the algorithm's results.

REFERENCES

[1] Jean Meeus, Astronomical Algorithms, Second Edition, 1998, pp. 100- 251

[2] Edwawrd M. Reingold and Nachum Dershowitz, Calendrical Calculations, The Ultimate Edition, 2018, pp. 335-371

[3] Shrestha, Bal G. (2015) “To Use or Not to Use: Nepal Samvat, the National Era of Nepal,” Himalaya, the Journal of the Association for Nepal and Himalayan Studies: Vol. 35: No. 1, Article 14.

[4] Central Bureau of Statistics (CBS). (2014). Population monograph of Nepal. Kathmandu: CBS. [5] Manandhar, Bhagawan D. (2021) ) “Coding and Decoding of Nepal Sambat,” Nepal Bhasa Times: Vol. 5, Article 116

[6] Peter Duffett-Smith and Jonathan Zwart, Practical Astronomy with your Calculator or Spreadsheet, Fourth Edition, 2011, pp. 161-239