- 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.
$ npm install cky-lunar-calendar --save
- solar2Lunar (date, month, yeaer, timezone)
- return Array [date, month, year]
convert solar date to lunar date with timezone optional.
- lunar2Solar (date, month, yeaer, timezone)
- return
Array [date, month, year]
convert lunar date to solar date with timezone optional.
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]);
$ npm test
will output like:
Solar -> Lunar: 3/6/2019 -> 1 5 2019
Lunar -> Solar: 3/6/2019 -> 5 7 2019
MIT