For all the forumulas given below, lmoon refers to the longitude of the moon, and smoon refers to the longitude of the sun at some point in time.

**D****ATE**

The date forms the basis of the information for the calendar and is the reference point.

**V****ARA**** ****(W****EEKDAY****)**

The weekday cannot be determined from astronomical factors. However, there are existing algorithms which can take any gregorian/julian day and will compute the weekday from it.

**M****AASA**** ****(M****ONTH****)**

There are three different kinds of months

Solar Month – Starts when the sun moves into a new raasi New Moon Lunar Month – Starts on new moon

Full Moon Lunar Month – Starts on full moon

The lunar months must be synced with solar months (since each lunar month has around 30 days). A lunar month is named after the solar month in which it starts. Once in a while, one of the following situations can arise:

Two consecutive lunar months are named after the same solar month. In this case, the first one is prefixed with Adhika (extra), and the second one is called Nija (correct). All festivals should be ovserved in the nija month.

Two consecutive lunar months skip a solar month. In this case, a lunar month is simply skipped. This is relatively uncommon occuring once every 60ish years.

**T****ITHI**** ****(L****UNAR**** ****DAY****)**

A tithi is the duration of time it takes for the moon to move 12 degrees furthur away from the sun. There are 360/12=30 tithis, which are divided into two groups–shukla and krishna paksha–each consisting of 15 tithis. The whole cycle of 30 tithis takes place during each lunar month. The beginning of the first tithi (prathama) depends on how the lunar month is defined.

If we calculate them with regards to the new moon lunar month, it starts with the conjunction of moon and sun. It ends when the longitude of the moon is 12 degrees away from the longitude of the sun (this would be when prathama starts).

For new-moon lunar months, the following formula can be used: difference = lmoon – lsun

if (difference < 0) difference = difference + 360

tithi = (difference / 6.0) + 12 [rounded DOWN to the nearast integer]

For full-moon lunar months, the following formula can be used:

difference = lmoon – lsun – 180

if (difference < 0) difference = difference + 360

tithi = (difference / 6.0) + 12 [rounded DOWN to the nearast integer]

**K****ARANA**** ****(L****UNAR**** ****HALF****–****DAY****)**

A karana is half a tithi. All the notes for tithi above apply. A new karana starts when the difference in longitudes between the sun and moon changes by 6 degrees, and there are 360/6=60 karanas.

The karana can be determined by the following formula. difference = lmoon – lsun

if (difference < 0) difference = difference + 360

karana = (difference / 6.0) + 1 [rounded DOWN to the nearast integer]

**N****AKSHATRA**** ****(S****TAR****)**

There are 27 nakshatras in the zodiac, each of length 360/27 degrees. What is commonly referred to as nakshatra, is usually the nakshatra in which the moon is found.

The nakshatra can be determined by the following formula.

nakshatra (lmoon / (360.0/27.0)) + 1 [rounded DOWN to the nearest integer].

**S****UN****-M****OON**** ****Y****OGA**

There are 27 sun-moon yogas defined which can be determined by the following formula. We are finding the nakshatra for the position occupied by the sum of the solar and lunar longitudes.

sum = lmoon + smoon

if (sum > 360) sum = sum – 360

sun-moon-yoga = (sum / (360.0/27.0)) + 1 [rounded DOWN to the nearest integer].