thai_lunar 0.1.0 copy "thai_lunar: ^0.1.0" to clipboard
thai_lunar: ^0.1.0 copied to clipboard

Pure-Dart Thai lunar calendar: Gregorian conversion, athikamat/athikavar year types, and Buddhist holiday full moons (Makha, Visakha, Asalha).

example/main.dart

import 'package:thai_lunar/thai_lunar.dart';

String fmt(DateTime t) => '${t.year}-${t.month.toString().padLeft(2, '0')}-'
    '${t.day.toString().padLeft(2, '0')}';

void main() {
  // 1. Convert a Gregorian date to the Thai lunar calendar.
  final newYear2000 = DateTime.utc(2000, 1, 1);
  final lunar = gregorianToThaiLunar(newYear2000);
  print('2000-01-01 = $lunar');
  print('  full moon? ${lunar.isFullMoon}   wan phra? ${lunar.isWanPhra}');
  print('  BE ${lunar.beYear} / CE ${lunar.ceYear}');

  // 2. Classify 2026 (a leap-month / athikamat year).
  final type2026 = lunarYearType(2026, era: ThaiEra.ce);
  print('\nCE 2026 lunar year type: $type2026');
  print('  isAthikamat: ${isAthikamat(2026, era: ThaiEra.ce)}');
  print('  isAthikavar: ${isAthikavar(2026, era: ThaiEra.ce)}');

  // 3. Visakha Bucha 2026. Because 2026 is athikamat, Visakha shifts from the
  //    full moon of month 6 to month 7.
  final visakha2026 = fullMoonOf(2026, 7, era: ThaiEra.ce);
  print('\nVisakha Bucha 2026: ${fmt(visakha2026)}');

  // Asalha (second month 8) and the day after = Khao Phansa.
  final asalha2026 = fullMoonOf(2026, 8, era: ThaiEra.ce, secondEighth: true);
  print('Asalha Bucha 2026:  ${fmt(asalha2026)}');
  print('Khao Phansa 2026:   ${fmt(asalha2026.add(const Duration(days: 1)))}');

  // 4. เสาร์ห้า (Sao Ha): the rare auspicious Saturday on the 5th of lunar
  //    month 5 — the strongest day for consecrating amulets.
  print('\nเสาร์ห้า in 2024:');
  for (final d in saoHaDatesIn(2024)) {
    final grade = saoHaType(d) == SaoHaType.major ? 'ใหญ่ major' : 'น้อย minor';
    print('  ${fmt(d)} ($grade)');
  }
  final next = nextSaoHa(DateTime.utc(2021, 1, 1));
  print('Next เสาร์ห้า on/after 2021-01-01: ${fmt(next!)}');
}
0
likes
160
points
69
downloads

Documentation

API reference

Publisher

verified publisher10v3n4m.cc

Weekly Downloads

Pure-Dart Thai lunar calendar: Gregorian conversion, athikamat/athikavar year types, and Buddhist holiday full moons (Makha, Visakha, Asalha).

Repository (GitHub)
View/report issues

Topics

#thai #calendar #lunar #buddhist #date

License

MIT (license)

More

Packages that depend on thai_lunar