Skip to content
96Astro API

Blog

Computing a panchang correctly: sunrise-based reckoning

· 96Astro API team · Calculation methods, Panchang

The panchang day starts at local sunrise, limbs end at their own times, and festivals are judged in their own windows. The rules that trip up most implementations.

A panchang looks like a table of five names for a date. Building one correctly is harder than it looks, because the Hindu day does not start at midnight, and the five limbs do not change at the same moment. This post explains the rules that trip up most implementations, and how to ask the API for a panchang that follows them.

The day starts at local sunrise

The civil date runs from midnight to midnight. The panchang day (and its weekday, the vara) runs from one local sunrise to the next. Two things follow:

  • At 3 a.m. on a Tuesday, the panchang weekday is still Monday, because Tuesday's sunrise has not happened yet.
  • Sunrise depends on the place. The same date in Chennai and in Delhi has a different sunrise, and so can have a different tithi or nakshatra "of the day".

That is why a panchang request always needs a place as well as a date. A panchang computed for Delhi and shown to a user in Bengaluru can be wrong for that user.

The limbs change at their own times

The five limbs (pancha anga) are:

LimbDefined byTypical length
Tithieach 12° of Moon minus Sunabout 19 to 26 hours
Nakshatrathe Moon's position, 27 divisions of 13°20′about 21 to 27 hours
Yogaeach 13°20′ of Sun plus Moonabout a day
Karanahalf a tithiabout half a day
Varasunrise to sunriseone day

Each of the first four ends at its own moment, rarely at sunrise. A correct panchang gives every limb with its end time, and often the next one, rather than one name per day.

The tithi at sunrise names the day

Calendars name the day after the tithi that is current at sunrise (the udaya tithi). Because tithis are not a day long, two edge cases happen every month or so:

  • Kshaya tithi: a tithi that begins after one sunrise and ends before the next is never current at sunrise, so no day is named after it. It is still a real tithi, with a start and an end.
  • Vriddhi (adhika) tithi: a tithi current at two successive sunrises names both days.

Code that steps through dates and asks "which tithi is it at sunrise" without handling these cases will silently skip or double a tithi, and every festival that depends on it.

Festivals are judged in their own window

Not every observance is decided at sunrise. Many rules name a different part of the day: midday (madhyahna), afternoon (aparahna), dusk (pradosha) or midnight (nishita). A festival whose tithi must be current at midnight can fall on a different civil date from one whose tithi must be current at sunrise, even when both use the same tithi. Treating every festival as a sunrise rule is a common source of off-by-one-day errors.

Timings come from sunrise and sunset too

Daily timings such as Rahu Kaal divide the daytime (sunrise to sunset) into eight equal parts and take one of them by weekday: the 2nd part on Monday, 7th on Tuesday, 5th on Wednesday, 6th on Thursday, 4th on Friday, 3rd on Saturday and 8th on Sunday. Choghadiya and the horas divide the day and the night the same way. A fixed "Rahu Kaal is 7:30 to 9:00 on Monday" table is right only near the equinoxes at one latitude.

Months: amanta and purnimanta

The lunar month ends at the new moon in the amanta system (used in much of South and West India) and at the full moon in the purnimanta system (much of North India). The same day can be in two differently named months depending on the system, for the two weeks between full moon and new moon. Show the convention your users follow, or both. A month is named from the new moon that began it, not from the Sun's sign on the day you look.

Asking the API

The daily panchang takes a date, an IANA time zone and the place:

curl https://api.96astroapi.com/v1/panchang/daily-panchang \
  -H "Authorization: Bearer $ASTRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "date": "2026-10-13",
    "timezone": "Asia/Kolkata",
    "latitude": 28.6139,
    "longitude": 77.209
  }'

The response holds the five limbs with their end times, sunrise, sunset, moonrise and moonset, the Hindu calendar (samvats, amanta and purnimanta months, adhik and kshaya flags, ritu, ayana), auspicious and inauspicious periods, choghadiya, horas and the festivals of the day. For a month view, use the monthly panchang instead of thirty separate calls.

Checklist for your own panchang code

  1. Take a place for every request, and compute sunrise for it.
  2. Use the tithi at sunrise for the day's name, and handle kshaya and vriddhi tithis.
  3. Give each limb its end time.
  4. Judge each festival in the window its rule names.
  5. Compute daily timings from that day's sunrise and sunset, never from a fixed table.
  6. Say which month convention you show.

Browse the Panchang & almanac family for every capability, from Rahu Kaal to the Tamil solar calendar.