qiuquanwu / solarlunar-es

一个公历农历转化工具,支持esmodule
MIT License
30 stars 3 forks source link
esm lunar solar

solarlunar-es

公历农历(阳历阴历)转换库

支持esmodule

1900 年至 2100 年公历、农历互转

支持年份:1900-2100

用法:

import solarLunar from 'solarlunar-es';

const solar2lunarData = solarLunar.solar2lunar(2015, 10, 8); // 输入的日子为公历
const lunar2solarData = solarLunar.lunar2solar(2015, 8, 26); // 输入的日子为农历

output:

{
    lYear: 2015,
    lMonth: 8,
    lDay: 26,
    animal: '羊',
    monthCn: '八月',
    dayCn: '廿六',
    cYear: 2015,
    cMonth: 10,
    cDay: 8,
    gzYear: '乙未',
    gzMonth: '丙戌',
    gzDay: '丁巳',
    isToday: false,
    isLeap: false,
    nWeek: 4,
    ncWeek: '星期四',
    isTerm: true,
    term: '寒露',
    lunarFestival:'',
    festival: ''
}

API

solarLunar.solar2lunar(2015, 10, 8);
solarLunar.solar2lunar(2015, 10, 08); // 等价于上者
solarLunar.lunar2solar(2015, 8, 26);
solarLunar.lunar2solar(2015, 08, 26); // 等价于上者
solarLunar.lunar2solar(2015, 8, 26, true);  // 闰月

返回值