flutter_khmer_chankitec 0.0.7
flutter_khmer_chankitec: ^0.0.7 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)
// Get the exact time of Khmer New Year for a given year
final newYearTime = Chhankitek.getKhmerNewYear(2025);
print(newYearTime); // 2025-04-14 02:00:00.000 (Example)
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