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).
- ✅ Bilingual: Full support for Khmer and English output.
- ✅ Pure Dart: Zero dependencies, works on all platforms.
Installation
dependencies:
flutter_khmer_chankitec: ^0.1.0
Usage
Main Methods
1. Get current Khmer lunar date
// Get current Khmer lunar date - ទទួលកាលបរិច្ឆេទចន្ទគតិចប្ចុប្បន្ន
final lunarDate = Chhankitek.now();
// Print in Khmer (default)
print(lunarDate.toString());
// Output: ថ្ងៃអាទិត្យ ១០ កើត ខែបុស្ស ឆ្នាំរោង ឆស័ក ពុទ្ធសករាជ ២៥៦៨
// ត្រូវនឹងថ្ងៃទី០៨ ខែមករា ឆ្នាំ២០២៥
// Print in English
print(lunarDate.toStringEn());
// Output: Sunday 10 Waxing month of Boss year of Dragon Chor Sak BE 2568
// Equivalent to 8 January 2025
2. Convert from Gregorian date
// Convert Gregorian to Khmer lunar date - បំប្លែងថ្ងៃខែសកល ទៅជា ចន្ទគតិ
final date = Chhankitek.fromDate(DateTime(2024, 4, 13));
print(date.toString());
3. Access individual date components
In Khmer:
final lunarDate = Chhankitek.now();
print(lunarDate.dayOfWeek); // អាទិត្យ (Sunday)
print(lunarDate.dayOfWeekShort); // អាទិត្យ (Sun) - short form
print(lunarDate.lunarDay); // ១០ កើត (10 Waxing)
print(lunarDate.lunarMonth); // បុស្ស (Boss)
print(lunarDate.lunarZodiac); // រោង (Dragon)
print(lunarDate.lunarEra); // ឆស័ក (Chor Sak)
print(lunarDate.lunarYear); // ២៥៦៨ (2568 BE)
print(lunarDate.solarDate); // ថ្ងៃទី០៨ ខែមករា ឆ្នាំ២០២៥
In English:
final lunarDate = Chhankitek.now();
print(lunarDate.dayOfWeekEn); // Sunday
print(lunarDate.dayOfWeekShortEn); // Sun - short form
print(lunarDate.shortLunarDayEn); // 10 Waxing
print(lunarDate.lunarMonthEn); // Boss
print(lunarDate.lunarMonthIndex); // 1
print(lunarDate.lunarZodiacEn); // Dragon
print(lunarDate.lunarEraEn); // Chor Sak
print(lunarDate.lunarYearInt); // 2568
print(lunarDate.solarDateEn); // 8 January 2025
As Numbers:
final lunarDate = Chhankitek.now();
print(lunarDate.lunarDay.moonCountEn); // 10 (integer)
print(lunarDate.lunarMonthIndex); // 1 (Boss month)
print(lunarDate.lunarYearInt); // 2568
print(lunarDate.solarYearInt); // 2025
print(lunarDate.solarDayInt); // 8
4. Custom format date
final lunarDate = Chhankitek.now();
// Khmer format
print(lunarDate.format("ថ្ងៃW d N ខែm ឆ្នាំa e ព.ស. b"));
// Output: ថ្ងៃអាទិត្យ ១០ កើត ខែបុស្ស ឆ្នាំរោង ឆស័ក ព.ស. ២៥៦៨
// English format
print(lunarDate.formatEn("W d N m a e BE:b"));
// Output: Sunday 10 Waxing Boss Dragon Chor Sak BE:2568
// Format tokens:
// W = Day of week, d = Lunar day number, N = Moon phase
// m = Lunar month, a = Zodiac animal, e = Era
// b = BE year, c = Solar/Gregorian year
5. 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
Access individual fields for custom display in Khmer, English, or as Numbers.
Khmer Properties (ជាភាសាខ្មែរ)
-
dayOfWeek: Day of week (full)
Example:អាទិត្យ,ច័ន្ទ,ព្រហស្បតិ៍ -
dayOfWeekShort: Day of week (short)
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: Solar date info
Example:ថ្ងៃទី០៨ ខែមករា ឆ្នាំ២០២៥
English Properties
-
dayOfWeekEn: Day of week in English (full)
Example:Sunday,Monday,Thursday -
dayOfWeekShortEn: Day of week in English (short)
Example:Sun,Mon,Thu -
shortLunarDayEn: Lunar day with phase in English
Example:1 Waxing,15 Waning -
lunarMonthEn: Lunar month name in English
Example:Migasir,Boss,Cheit -
lunarMonthIndex: Lunar month index (0-13)
Example:0(Migasir),1(Boss),5(Pisakh) -
lunarZodiacEn: Zodiac animal in English
Example:Rat,Ox,Dragon -
lunarEraEn: Era name in English
Example:Chor Sak,Aek Sak -
solarDateEn: Solar date in English
Example:8 January 2025
Number Properties (ជាលេខ)
-
lunarYearInt: Buddhist Era year as integer
Example:2568 -
solarYearInt: Gregorian year as integer
Example:2025 -
solarDayInt: Gregorian day as integer
Example:8 -
lunarDay.moonCountEn: Lunar day count as integer
Example:10,15
Helper Booleans
Easy checks for special religious days (ថ្ងៃសំខាន់ៗ).
- isSilaDay: Checks if it is a holy day (ថ្ងៃសីល - 8កើត, 15កើត, 8រោច, 14/15រោច)
- isFullMoon: Checks if it is full moon (ថ្ងៃពេញបូណ៌មី - 15កើត)
final lunarDate = Chhankitek.now();
if (lunarDate.isSilaDay) {
print('Today is Sila day! (ថ្ងៃនេះជាថ្ងៃសីល)');
}
if (lunarDate.isFullMoon) {
print('Full moon tonight! (ពេញបូណ៌មីយប់នេះ)');
}
Lunar Month Indices (លេខសម្គាល់ខែចន្ទគតិ)
Reference table for Khmer lunar months with their indices and special notes.
| Index | Khmer Name | Pronunciation | Notes |
|---|---|---|---|
| 0 | មិគសិរ | Migasir | First month of the lunar year |
| 1 | បុស្ស | Boss | |
| 2 | មាឃ | Meak | |
| 3 | ផល្គុន | Phalkun | |
| 4 | ចេត្រ | Cheit | Contains Khmer New Year (សង្ក្រាន្ត) |
| 5 | ពិសាខ | Pisakh | 🙏 Contains Visakha Bochea (១៥កើត) |
| 6 | ជេស្ឋ | Jesth | ➕ Can have leap day (30 days instead of 29) |
| 7 | អាសាឍ | Asadh | |
| 8 | ស្រាពណ៍ | Srap | |
| 9 | ភទ្របទ | Phatrabot | |
| 10 | អស្សុជ | Assoch | Contains Pchum Ben (១៥រោច) |
| 11 | កត្ដិក | Kadeuk | Contains Water Festival (១៥កើត) |
| 12 | បឋមាសាឍ | Pathamasadh | 🌟 Only exists in leap month years (Athikameas) |
| 13 | ទុតិយាសាឍ | Tutiyasadh | 🌟 Only exists in leap month years (Athikameas) |
Special Notes (កំណត់សម្គាល់)
- Leap Month Years: In some years, there are 13 months instead of 12. When this happens, months 12 and 13 (បឋមាសាឍ and ទុតិយាសាឍ) appear between អាសាឍ (7) and ស្រាពណ៍ (8).
- Leap Day: Month 6 (ជេស្ឋ/Jesth) can have 30 days instead of the usual 29 in certain years.
- Religious Days: Many important Buddhist holidays occur on specific lunar dates (usually 15កើត or 15រោច).
Usage Example
final lunarDate = Chhankitek.fromDate(DateTime(2025, 5, 11));
print('Month Index: ${lunarDate.lunarMonthIndex}'); // Example: 5
print('Month Name: ${lunarDate.lunarMonth}'); // Example: ពិសាខ
print('Day: ${lunarDate.lunarDay}'); // Example: ១៥ កើត
Days of Week (ថ្ងៃក្នុងសប្ដាហ៍)
Reference table for days of the week in Khmer and English (full and short forms).
| Index | Khmer (Full) | Khmer (Short) | English (Full) | English (Short) |
|---|---|---|---|---|
| 1 | ច័ន្ទ | ច័ន្ទ | Monday | Mon |
| 2 | អង្គារ | អង្គារ | Tuesday | Tue |
| 3 | ពុធ | ពុធ | Wednesday | Wed |
| 4 | ព្រហស្បតិ៍ | ព្រហ | Thursday | Thu |
| 5 | សុក្រ | សុក្រ | Friday | Fri |
| 6 | សៅរ៍ | សៅរ៍ | Saturday | Sat |
| 7 | អាទិត្យ | អាទិត្យ | Sunday | Sun |
Usage Example
final lunarDate = Chhankitek.now();
// Full names
print(lunarDate.dayOfWeek); // អាទិត្យ
print(lunarDate.dayOfWeekEn); // Sunday
// Short names
print(lunarDate.dayOfWeekShort); // អាទិត្យ
print(lunarDate.dayOfWeekShortEn); // Sun
Animal Years / Zodiac (ឆ្នាំសត្វទាំង១២)
Reference table for the 12-year animal cycle in the Khmer calendar.
| Index | Emoji | Khmer | English | Pronunciation |
|---|---|---|---|---|
| 0 | 🐀 | ជូត | Rat | Chhut |
| 1 | 🐂 | ឆ្លូវ | Ox | Chlov |
| 2 | 🐅 | ខាល | Tiger | Khal |
| 3 | 🐇 | ថោះ | Rabbit | Thos |
| 4 | 🐉 | រោង | Dragon | Rong |
| 5 | 🐍 | ម្សាញ់ | Snake | Masagn |
| 6 | 🐎 | ममីរ | Horse | Momee |
| 7 | 🐐 | ममែ | Goat | Momae |
| 8 | 🐒 | វក | Monkey | Vok |
| 9 | 🐓 | រកា | Rooster | Roka |
| 10 | 🐕 | ច | Dog | Cho |
| 11 | 🐖 | កុរ | Pig | Kor |
Usage Example
final lunarDate = Chhankitek.now();
// Get zodiac animal
print(lunarDate.lunarZodiac); // ម្សាញ់
print(lunarDate.lunarZodiacEn); // Snake
// Check specific year
final date2024 = Chhankitek.fromDate(DateTime(2024, 5, 1));
print(date2024.lunarZodiacEn); // Dragon 🐉
Era Years / Sak (ស័កទាំង១០)
Reference table for the 10-year era cycle (Sak) in the Khmer calendar.
| Index | Khmer | English | Pronunciation |
|---|---|---|---|
| 0 | សំរឹទ្ធិស័ក | Samroeut Sak | Samroeut Sak |
| 1 | ឯកស័ក | Aek Sak | Aek Sak |
| 2 | ទោស័ក | Tou Sak | Tou Sak |
| 3 | ត្រីស័ក | Trey Sak | Trey Sak |
| 4 | ចត្វាស័ក | Jatva Sak | Jatva Sak |
| 5 | បញ្ចស័ក | Pancha Sak | Pancha Sak |
| 6 | ឆស័ក | Chor Sak | Chor Sak |
| 7 | សប្តស័ក | Sapta Sak | Sapta Sak |
| 8 | អដ្ឋស័ក | Attha Sak | Attha Sak |
| 9 | នព្វស័ក | Nuppea Sak | Nuppea Sak |
Usage Example
final lunarDate = Chhankitek.now();
// Get era
print(lunarDate.lunarEra); // សប្តស័ក
print(lunarDate.lunarEraEn); // Sapta Sak
License
MIT License - Copyright (c) 2026 Veng Ann
Libraries
- flutter_khmer_chankitec
- Flutter Khmer Chankitec - Khmer Lunar Calendar Plugin Clean, reusable implementation for converting Gregorian dates to Khmer lunar dates
- khmer_chhankitek/khmer_chhankitek
- Khmer Chhankitek - Khmer Lunar Calendar Library Clean, reusable implementation for converting Gregorian dates to Khmer lunar dates
- khmer_chhankitek/src/chhankitek
- khmer_chhankitek/src/constants/khmer_constants
- khmer_chhankitek/src/models/khmer_lunar_date
- khmer_chhankitek/src/models/lunar_day
- khmer_chhankitek/src/utils/khmer_number_utils