mm-cal-js
TypeScript icon, indicating that this package has built-in type declarations

0.1.10 • Public • Published

Myanmar Calendar JS

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.

🚧 🚧 Only certain features are available for now 🚧 🚧

  • [x] western date to Myanmar date

  • [x] Sabbath day calculation

Installation

npm i mm-cal-js

Usage

Western date to Myanmar Date

import { getMyanmarDate } from "mm-cal-js";

console.log(getMyanmarDate(new Date(2000, 1, 1)));

Output

{
  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
}

Checking Sabbath day

import { isSabbath } from "mm-cal-js";

console.log(isSabbath(new Date()));
// output: [1=Sabbath, 2=Sabbath Eve, 0=else]

Documenation

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.

Motivation

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.

Dependents (0)

Package Sidebar

Install

npm i mm-cal-js

Weekly Downloads

10

Version

0.1.10

License

none

Unpacked Size

96.1 kB

Total Files

23

Last publish

Collaborators

  • ninnwoo