flutter_khmer_chankitec 0.0.8
flutter_khmer_chankitec: ^0.0.8 copied to clipboard
A Flutter plugin for Khmer lunar calendar (Chhankitek/ចន្ទគតិ) calculations. Convert Gregorian dates to Khmer lunar dates with full support for Buddhist calendar features including Sila days detection.
flutter_khmer_chankitec #
A Flutter plugin for Khmer lunar calendar (Chhankitek/ចន្ទគតិ) calculations and date conversions.
💝 Support This Project #
Scan to donate via KHQR (ស្កេនដើម្បីបរិច្ចាគតាម KHQR)
Features #
- ✅ High Precision: Uses astronomical calculations for New Year (Moha Songkran) and Era transitions.
- ✅ Comprehensive: Handles Leap Months (Athikameas) and Leap Days (Chantreathimeas).
- ✅ Pure Dart: Zero dependencies, works on all platforms.
Installation #
dependencies:
flutter_khmer_chankitec: ^0.0.5
Usage #
Main Methods #
1. Get current Khmer lunar date
// Chhankitek.now() - បង្ហាញកាលបរិច្ឆេទចន្ទគតិចប្ចុប្បន្ន
final lunarDate = Chhankitek.now();
print(lunarDate.toString());
// Output: ថ្ងៃអាទិត្យ ១០ កើត ខែបុស្ស ឆ្នាំរោង ឆស័ក ពុទ្ធសករាជ ២៥៦៨
// ត្រូវនឹងថ្ងៃទី០៨ ខែមករា ឆ្នាំ២០២៥
2. Convert from Gregorian date
// Chhankitek.fromDate(DateTime) - បំប្លែងថ្ងៃខែសកល ទៅជា ចន្ទគតិ
final date = Chhankitek.fromDate(DateTime(2024, 4, 13));
3. Get proper format date
// Custom format string
// Tokens: W=DayOfWeek, d=Day, m=Month, a=Zodiac, e=Era, b=BE, c=SolarYear
print(lunarDate.format("ថ្ងៃW d ខែm ឆ្នាំa e ព.ស. b"));
// Output: ថ្ងៃអាទិត្យ ១០ កើត ខែបុស្ស ឆ្នាំរោង ឆស័ក ព.ស. ២៥៦៨
4. Get New Year Time (Moha Songkran)
// 2025 (Standard 3 days)
int year = 2025;
print('Year: $year');
print('New Year Time: ${Chhankitek.getKhmerNewYear(year)}');
print('Duration: ${Chhankitek.getNewYearDuration(year)} days');
// Output: 3 days (14, 15, 16 April)
// 2028 (Leap Year - 4 days)
year = 2028;
int duration = Chhankitek.getNewYearDuration(year);
print('Year: $year');
print('Duration: $duration days');
// Output: 4 days
// List all celebration days
DateTime start = Chhankitek.getKhmerNewYear(year);
for (int i = 0; i < duration; i++) {
DateTime day = start.add(Duration(days: i));
print('Day ${i + 1}: ${day.day}/${day.month}');
}
// Output:
// Day 1: 13/4 (Moha Songkran)
// Day 2: 14/4 (Vanabat)
// Day 3: 15/4 (Vanabat)
// Day 4: 16/4 (Lerng Sak)
KhmerLunarDate Properties #
You can access individual fields for custom display.
-
dayOfWeek: Day of week in Khmer (ថ្ងៃនៃសប្ដាហ៍)
Example:ថ្ងៃអាទិត្យ,ថ្ងៃច័ន្ទ -
lunarDay: Lunar day with phase (ថ្ងៃខែចន្ទគតិ)
Example:១ កើត,១៥ រោច -
lunarMonth: Lunar month name (ឈ្មោះខែចន្ទគតិ)
Example:មិគសិរ,បុស្ស,ចេត្រ -
lunarZodiac: Zodiac animal (ឆ្នាំ ទាំង ១២)
Example:ជូត,ឆ្លូវ,រោង -
lunarEra: Era name (ស័ក)
Example:ឆស័ក,ឯកស័ក -
lunarYear: Buddhist Era year (ពុទ្ធសករាជ)
Example:២៥៦៨ -
solarDate: Formatting for solar date info (ថ្ងៃខែឆ្នាំសកល ជាភាសាខ្មែរ)
Example:ថ្ងៃទី០៨ ខែមករា ឆ្នាំ២០២៥
Helper Booleans #
Easy checks for special religious days.
- isSilaDay: Checks if it is a holy day (ថ្ងៃសីល)
- isFullMoon: Checks if it is full moon (ថ្ងៃពេញបូណ៌មី)
- isNewMoon: Checks if it is new moon (ថ្ងៃដាច់ខែ)
if (lunarDate.isSilaDay) {
print('Today is Sila day! (ថ្ងៃនេះជាថ្ងៃសីល)');
}
License #
MIT License - Copyright (c) 2026 Veng Ann