Skip to content

Latest commit

 

History

History
75 lines (55 loc) · 2.64 KB

README.md

File metadata and controls

75 lines (55 loc) · 2.64 KB

cky-lunar-calendar

Features!

  • Convert solar date with timezone to lunar date
  • And revert lunar date to solar date

This package use lib of Ho Ngoc Duc, convert a date to lunar date with timezone (default timezone is GMT+7)

Copyright 2004 Ho Ngoc Duc (Am lich - Ho Ngoc Duc). All Rights Reserved. Permission to use, copy, modify, and redistribute this software and its documentation for personal, non-commercial use is hereby granted provided that this copyright notice appears in all copies.

Installation

$ npm install cky-lunar-calendar --save

function

  • solar2Lunar (date, month, yeaer, timezone)
    • date <number>: solar date
    • month <number>: solar month
    • year <number>: solar year
    • timezone <number>: optional, timezone in GMT of your location you want, default is 7
  • return Array [date, month, year]

convert solar date to lunar date with timezone optional.


  • lunar2Solar (date, month, yeaer, timezone)
    • date <number>: lunar date
    • month <number>: lunar month
    • year <number>: lunar year
    • timezone <number>: optional, timezone in GMT of your location you want, default is 7
  • return Array [date, month, year]

convert lunar date to solar date with timezone optional.


Test script

const lunar = require('cky-lunar-calendar');

let now = new Date();

let dateLunar = lunar.solar2Lunar(now.getDate(), now.getMonth() + 1, now.getFullYear());
console.log('Solar -> Lunar:', [now.getDate(), now.getMonth() + 1, now.getFullYear()].join('/') , '->', dateLunar[0], dateLunar[1], dateLunar[2]);


let dateSolar = lunar.lunar2Solar(now.getDate(), now.getMonth() + 1, now.getFullYear());
console.log('Lunar -> Solar:', [now.getDate(), now.getMonth() + 1, now.getFullYear()].join('/') , '->', dateSolar[0], dateSolar[1], dateSolar[2]);

Test command

$ npm test

will output like:

Solar -> Lunar: 3/6/2019 -> 1 5 2019
Lunar -> Solar: 3/6/2019 -> 5 7 2019

License

MIT

- Chickyky -

kikikikikiki