tithi_engine library

Accurate Vedic tithi, lunar month, and festival date calculator.

The public surface mirrors the Java tithi-engine library: a single entry point (Panchang) plus immutable value types. The astronomy engine, tithi-number utilities, month converter, and festival-finder functions are internal (src/) and intentionally not exported — drive everything through Panchang.

import 'package:tithi_engine/tithi_engine.dart';
import 'package:tithi_engine/data/all.dart';

final panchang = Panchang([registerAllCities]);
final info = panchang.tithiOnDate(DateTime.utc(2026, 2, 15), City.ujjain);
print(info.displayName); // "Phalguna Krishna Trayodashi"

final diwali = panchang.dateFor(festivals.firstWhere((f) => f.id == 'diwali'),
    2026, City.seattle);

Classes

City
A supported city: a canonical name plus an optional region/country qualifier. Construct via City.of / City.tryOf (validated against the supported-city registry) or use a City constant (e.g. City.ujjain); a City value therefore always denotes a supported city.
FestivalDate
Result of finding a festival date, including muhurta window and tithi span.
FestivalDef
Static definition of a Hindu festival.
Location
A place to compute for: either a registered city, or raw coordinates.
Panchang
Primary entry point for the tithi engine.
PanchangAt
A Panchang bound to a Location; forwards to the city-keyed API.
Tithi
A tithi as a value: a lunar day identified by its paksha and position.
TithiInfo
Complete tithi information for a date.
TithiSegment
A contiguous span of a single tithi within an enumeration window.

Enums

LocationSource
Accuracy tier of a resolved Location.
LunarMonth
MonthSystem
Month system: Purnimant (North India) or Amant (South India).
MuhurtaRule
Muhurta rule that determines the observance day for a festival.
Paksha
SunriseConvention
Which point of the Sun's disk defines the sunrise/sunset instant.

Constants

defaultCity → const City
The single default reference city used wherever no city is specified (month/tithi resolution, sunrise, UI defaults). Change this one value to swap the app-wide default. Must be a supported city (see City.values).
festivals → const List<FestivalDef>
All supported festivals.

Functions

getTithiName(int tithiNumber) String
Get tithi name from tithi number (1-30).
resolveCityName(String city) String?
Resolve any reasonable city spelling to a registered city name, or null if it matches no supported city.