The Sun and the Moon
The positions of the Sun and the Moon come from the JPL DE421 planetary ephemeris, the numerical model of the solar system published by NASA's Jet Propulsion Laboratory and used in astronomical almanacs. The positions are apparent and geocentric: as seen from the centre of the Earth, allowing for the time light takes to arrive and for the Earth's motion. They are referred to the ecliptic and equinox of the date.
From the two longitudes come the limbs of the panchang. The tithi is the angle by which the Moon is ahead of the Sun, twelve degrees to a tithi; the karana is half a tithi. The nakshatra is the Moon's place among the twenty-seven stations of thirteen degrees twenty minutes each, and the yoga the sum of the two longitudes divided the same way.
The ayanamsa
Nakshatra, yoga and the rashis are sidereal: they are measured from a fixed point among the stars, not from the moving equinox. The difference between the two is the ayanamsa. This site uses the Lahiri or Chitrapaksha ayanamsa, the standard of the Indian national calendar: twenty-three degrees fifteen minutes and 0.66 seconds on the 21st of March 1956, carried forward as a fixed direction in space, so that it grows with the precession of the equinoxes, about fifty seconds of arc a year. The tithi needs no ayanamsa, being a difference of two longitudes.
Sunrise, sunset, moonrise
Sunrise and sunset are the moments the upper edge of the Sun's disc touches the horizon, allowing for the bending of light in the atmosphere, which lifts the Sun by about thirty-four minutes of arc. This is the definition most published panchangs use. Moonrise and moonset are taken for the centre of the Moon's disc as seen from the city, with the Moon's parallax allowed for.
Each city is computed at its centre. Across a large metropolitan area the sunrise can differ by a minute or two from one edge to the other.
The Hindu day
A Hindu day runs from sunrise to the next sunrise. The tithi, nakshatra, yoga and karana of a day are those in force at its sunrise; a page lists every change up to the following sunrise, with the time of each. A time marked as the next day is after midnight but before that sunrise. Moonrise and moonset are likewise those of the Hindu day, which is why a moonrise after midnight is listed under the day before.
The weekday changes at sunrise too. The lunar month is named in two reckonings: amanta, ending at the new moon, used in the south and west of India; and purnimanta, ending at the full moon, used in the north. An intercalary month, adhika, is the same span in both.
Muhurtas and Choghadiya
The day from sunrise to sunset is divided into eight parts for Rahu Kaal, Yamaganda and Gulika, a different part on each weekday, and into fifteen muhurtas, of which Abhijit is the eighth, around midday, except on Wednesdays, when that muhurta is a Dur Muhurta and Abhijit is not used. The night is divided into fifteen muhurtas too, and Brahma Muhurta is the second-last before sunrise. Choghadiya divides day and night into eight parts each: by day the names follow the order of the planetary hours from the weekday's lord; by night they begin from the lord of the fifth weekday and follow another order. Because all of these are fractions of the local day, they move with the seasons and with the place.
Fasts and festivals
A fast or festival is tied to a tithi and to a part of the day in which that tithi must be in force: sunrise for most, midday for Ganesh Chaturthi, the evening after sunset for Diwali and Pradosh, midnight for Shivaratri and Janmashtami, moonrise for Sankashti Chaturthi and Karwa Chauth. When the tithi is in force at that part on two consecutive days, or on neither, a rule of preference decides. The preferences used here follow the published panchangs of North India, and were checked against them, city by city, over many months before any date was published. Ekadashi follows its own rule: the fast is kept on the day Ekadashi is in force at sunrise, but moves a day earlier when Dwadashi would be over before the next sunrise, so that the fast can be broken in Dwadashi.
Precision and rounding
Times are rounded to the nearest minute. The instants of new and full moon computed here agree with the astronomical almanac to within seconds. Other panchangs may show a tithi's end a minute or two apart from this one, from different conventions for the time scale or the ayanamsa; a sunrise a few seconds apart can round to a different minute. Where a tithi ends within a minute of sunrise, the day's tithi itself can differ between panchangs, and a reader with a fast on that day should look at both.
Sources
JPL DE421 planetary ephemeris, NASA Jet Propulsion Laboratory; Skyfield, the open astronomy library by Brandon Rhodes, for the positions, risings and settings; the IAU 2006 precession and IAU 2000B nutation models; the Lahiri ayanamsa as defined for the Indian national calendar; the IANA time zone database for each city's clock and daylight saving.