Giter Club home page Giter Club logo

khmercal's Introduction

Khmer Lunar Calendar

A simple and lightweight Khmer lunar calendar.

npm install khmercal
import { lunar } from 'khmercal';

lunar(new Date())

// output
({
  day: 18,
  period: [ 3, 'R' ],
  sequence: 3,
  zodiac: 'KARL',
  years: { JE: 1383, CE: 2022, BE: 2566 },
  length: 354,
  monthLength: 30,
  month: { name: 'KÂTDĔK', index: 11 },
  months: [
    'MĬKÔSĔR', 'BŎSS',
    'MÉAKH',   'PHÂLKŬN',
    'CHÉTR',   'VĬSAKH',
    'CHÉSTH',  'ASATH',
    'SRAPÔNÂ', 'PHÔTRÔBÂT',
    'ÂSSŎCH',  'KÂTDĔK'
  ]
})

CLI

npm install -g khmercal
  1. Basic output
khmercal "2022-11-11T10:11:54.654Z"

The date defaults to current date!

Result

Day: 3R (18 of 30)
Month: KÂTDĔK
Years: 2566 B.E, 1383 J.E, 2022 C.E
Days: 354 days 
Zodiac: KARL
Sequence: IV ចត្វាស័ក
  1. JSON output
khmercal "2022-11-11T10:11:54.654Z" --json
{
  "day": 18,
  "period": [
    3,
    "R"
  ],
  "sequence": 3,
  "zodiac": "KARL",
  "years": {
    "JE": 1383,
    "CE": 2022,
    "BE": 2566
  },
  "length": 354,
  "monthLength": 30,
  "month": {
    "name": "KÂTDĔK",
    "index": 11
  },
  "months": [
    "MĬKÔSĔR",
    "BŎSS",
    "MÉAKH",
    "PHÂLKŬN",
    "CHÉTR",
    "VĬSAKH",
    "CHÉSTH",
    "ASATH",
    "SRAPÔNÂ",
    "PHÔTRÔBÂT",
    "ÂSSŎCH",
    "KÂTDĔK"
  ]
}

CLI Manual

khmercal [date]

Convert

Positionals:
  date  ISO Date string                            [string] [default: (default)]

Options:
      --help     Show help                                             [boolean]
      --version  Show version number                                   [boolean]
  -j, --json     JSON output                          [boolean] [default: false]

Related

khmercal's People

Contributors

seanghay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

khmercal's Issues

Result showing next day after 7PM

I found one more strange
I run CLI at 5PM Local Time :

khmercal "2023-05-05T17:58:01+07:00"

Day: 1R (16 of 30)
Month: VĬSAKH
Years: 2567 B.E, 1384 J.E, 2023 C.E
Days: 384 days
Zodiac: THOS
Sequence: V បញ្ចស័ក

it's look fine but after 7PM it's showing next day:

khmercal "2023-05-05T19:58:01+07:00"

Day: 2R (17 of 30)
Month: VĬSAKH
Years: 2567 B.E, 1384 J.E, 2023 C.E
Days: 384 days
Zodiac: THOS
Sequence: V បញ្ចស័ក

False calculation for Zodiac (Animal) and Sequence 10 cycle (Sak)

I try this

khmercal "2023-04-05T19:33:00+07:00"

Day: 1R (16 of 29)
Month: CHÉTR
Years: 2566 B.E, 1383 J.E, 2023 C.E
Days: 384 days
Animal: KARL
Sequence: IV ចត្វាស័ក

answer it's look fine then I try this

khmercal "2023-04-17T00:30:00+07:00"

Day: 12R (27 of 29)
Month: CHÉTR
Years: 2566 B.E, 1383 J.E, 2023 C.E
Days: 384 days
Animal: KARL
Sequence: IV ចត្វាស័ក

After Khmer new year the Zodiac (Animal) should change to "THOS" and Sequence (SAK) should be 'V បញ្ចស័ក' full answer should like this:

khmercal "2023-04-17T00:30:00+07:00"

Day: 12R (27 of 29)
Month: CHÉTR
Years: 2566 B.E, 1383 J.E, 2023 C.E
Days: 384 days
Animal: THOS
Sequence: V បញ្ចស័ក

At first I think maybe It's wrong cuz it's wait to change when B.E year increase at Pisak Bochea but It's not.
I tried this the day after VĬSAKH and this what I got

khmercal "2023-05-06T00:30:00+07:00"

Day: 2R (17 of 30)
Month: VĬSAKH
Years: 2567 B.E, 1383 J.E, 2023 C.E
Days: 384 days
Animal: KARL
Sequence: IV ចត្វាស័ក

B.E year increased but Animal and Sequence remind the same

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.