This repository is the TypeScript fork of chanmratekoko/mmcalendar and the opinionated TypeScript implementation of the original yan9a/mmcal, and based on this very awesome article by yan9a/mmcal's author: Algorithm, Program and Calculation of Myanmar Calendar.
-
[x] western date to Myanmar date
-
[x] Sabbath day calculation
npm i mm-cal-js
import { getMyanmarDate } from "mm-cal-js";
console.log(getMyanmarDate(new Date(2000, 1, 1)));
{
myanmarYear: 1361,
myanmarYearType: 1, // [0=common, 1=little watat, 2=big watat]
yearLength: 384,
// Tagu=1, Kason=2, Nayon=3, 1st Waso=0, 2nd Waso=4,
// Wagaung=5, Tawthalin=6, Thadingyut=7, Tazaungmon=8,
// Nadaw=9, Pyatho=10, Tabodwe=11, Tabaung=12,
// Late Tagu=13, Late Kason=14]
month: 10,
monthType: 0, // [0=Hnaung, 1=Oo]
monthLength: 30, // [29 or 30]
monthDay: 27, // [1 to 30]
weekDay: 3, // [0=sat, 1=sun, 2=mon, 3=tue, 4=wed, 5=thu, 6=fri]
julianDay: 2451575.5
}
import { isSabbath } from "mm-cal-js";
console.log(isSabbath(new Date()));
// output: [1=Sabbath, 2=Sabbath Eve, 0=else]
The code is very well-documented. I suggest you explore into the source code. You can also read more about the implementation details here.
Essentially, the Gregorian date is converted into Julian day number, and it's converted into Myanmar date.
Although Dr. Yan Naing Aye's original codebase is flawless, it's not type-safe and the variable names are very confusing. This implementation aims to appeal to modern web developers with type-safety and functional API.