flutter_khmer_chankitec 0.0.4
flutter_khmer_chankitec: ^0.0.4 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 #
- ✅ Convert Gregorian to Khmer lunar dates
- ✅ Detect Sila days (ថ្ងៃសីល), full moon, and new moon
- ✅ Complete Khmer date formatting
- ✅ Pure Dart - works on all platforms
Installation #
dependencies:
flutter_khmer_chankitec: ^0.0.1
Usage #
import 'package:flutter_khmer_chankitec/flutter_khmer_chankitec.dart';
// Get current Khmer lunar date
final lunarDate = Chhankitek.now();
print(lunarDate.toString());
// Output: ថ្ងៃអាទិត្យ ១ កើត ខែមិគសិរ ឆ្នាំរោង ត្រីស័ក ពុទ្ធសករាជ ២៥៦៧
// ត្រូវនឹងថ្ងៃទី០៤ ខែមករា ឆ្នាំ២០២៦
// Convert specific date
final date = Chhankitek.fromDate(DateTime(2024, 1, 1));
// Alternative method (same as fromDate)
final dateAlt = Chhankitek.get(DateTime(2024, 1, 1));
// Check special days
if (lunarDate.isSilaDay) print('Today is Sila day! 🙏');
if (lunarDate.isFullMoon) print('Full moon! 🌕');
if (lunarDate.isNewMoon) print('New moon! 🌑');
// Access individual properties
print('Day of Week: ${lunarDate.dayOfWeek}'); // អាទិត្យ, ច័ន្ទ, ...
print('Lunar Day: ${lunarDate.lunarDay}'); // ១ កើត, ១៥ កើត, ១ រោច, ...
print('Lunar Month: ${lunarDate.lunarMonth}'); // មិគសិរ, បុស្ស, ...
print('Lunar Zodiac: ${lunarDate.lunarZodiac}'); // ជូត, ឆ្លូវ, ខាល, ...
print('Lunar Era: ${lunarDate.lunarEra}'); // ត្រីស័ក, ចត្វាស័ក, ...
print('Lunar Year: ${lunarDate.lunarYear}'); // ២៥៦៧
print('Solar Day: ${lunarDate.solarDay}'); // ០៤
print('Solar Month: ${lunarDate.solarMonth}'); // មករា, កុម្ភៈ, ...
print('Solar Year: ${lunarDate.solarYear}'); // ២០២៦
// Short lunar day formats (two options)
print('With space: ${lunarDate.shortLunarDay}'); // ១ កើត
print('Compact: ${lunarDate.shortLunarDayCompact}'); // ១កើត
// Convert numbers to Khmer numerals
String khmerNum = KhmerNumberUtils.toKhmerNumber(2024); // ២០២៤
String khmerNum2 = KhmerNumberUtils.toKhmerNumber(12345); // ១២៣៤៥
// Get day of week in Khmer
String dayOfWeek = KhmerNumberUtils.getDayOfWeekInKhmer(DateTime.now());
// អាទិត្យ, ច័ន្ទ, អង្គារ, etc.
// Get solar month in Khmer
String monthKh = KhmerNumberUtils.getSolarMonthKh(1); // មករា (January)
String monthKh2 = KhmerNumberUtils.getSolarMonthKh(12); // ធ្នូ (December)
API #
Main Methods #
Chhankitek.now()- Get current Khmer lunar dateChhankitek.fromDate(DateTime)- Convert Gregorian to lunar dateChhankitek.get(DateTime)- Alternative method (same as fromDate)
KhmerLunarDate Properties #
dayOfWeek- Day of week in Khmer (អាទិត្យ, ច័ន្ទ, អង្គារ, ពុធ, ព្រហស្បតិ៍, សុក្រ, សៅរ៍)lunarDay- Lunar day with phase (e.g., ១ កើត, ១៥ រោច)shortLunarDay- Short lunar day with space (e.g., ១ កើត, ១៥ រោច)shortLunarDayCompact- Compact format without space (e.g., ១កើត, ១៥រោច)lunarMonth- Lunar month name (មិគសិរ, បុស្ស, មាឃ, ផល្គុន, ចេត្រ, ពិសាខ, ជេស្ឋ, អាសាឍ, ស្រាពណ៍, ភទ្របទ, អស្សុជ, កក្ដិក)lunarZodiac- Zodiac animal (ជូត, ឆ្លូវ, ខាល, ថោះ, រោង, ម្សាញ់, មមីរ, មមែ, វក, រកា, ច, កុរ)lunarEra- Era name (សំរឹទ្ធិស័ក, ឯកស័ក, ទោស័ក, ត្រីស័ក, ចត្វាស័ក, បញ្ចស័ក, ឆស័ក, សប្តស័ក, អដ្ឋស័ក, នព្វស័ក)lunarYear- Buddhist Era year in Khmer numeralssolarDay- Solar day in Khmer numeralssolarMonth- Solar month in Khmer (មករា, កុម្ភៈ, មីនា, មេសា, ឧសភា, មិថុនា, កក្កដា, សីហា, កញ្ញា, តុលា, វិច្ឆកា, ធ្នូ)solarYear- Solar year in Khmer numeralsisSilaDay- Check if it's a Sila day (ថ្ងៃសីល)isFullMoon- Check if it's full moon (ថ្ងៃពេញបូណ៌មី)isNewMoon- Check if it's new moon (ថ្ងៃបាតមាស)toString()- Get full formatted date string
KhmerNumberUtils Methods #
KhmerNumberUtils.toKhmerNumber(int)- Convert integer to Khmer numerals (e.g., 2024 → ២០២៤)KhmerNumberUtils.getDayOfWeekInKhmer(DateTime)- Get day of week in KhmerKhmerNumberUtils.getSolarMonthKh(int)- Get solar month name in Khmer (1-12)
Constants Available #
Access Khmer constants through KhmerConstants:
KhmerConstants.khmerNumerals- Map of digits to Khmer numerals (០១២៣៤៥៦៧៨៩)KhmerConstants.daysOfWeek- Days of week in KhmerKhmerConstants.lunarMonths- List of lunar month namesKhmerConstants.solarMonthsKh- List of solar month names in KhmerKhmerConstants.animalYears- List of zodiac animal namesKhmerConstants.eraYears- List of era namesKhmerConstants.moonStatusKh- Moon status (កើត/រោច)
Example #
Run the example app:
cd example
flutter run
Contributing #
Contributions welcome! Please submit a Pull Request.
License #
MIT License - Copyright (c) 2026 Veng Ann