📦 lunar-lite
精简版的农历和阳历日期转换库。
安装
npm i lunar-lite -S
你也可以用你熟悉的任何包管理软件安装依赖。
类型定义
export type LunarDate = {
lunarYear: number;
lunarMonth: number;
lunarDay: number;
isLeap: boolean;
toString: (toCnStr?: boolean) => string;
};
export type SolarDate = {
solarYear: number;
solarMonth: number;
solarDay: number;
toString: () => string;
};
方法定义
type solar2lunar = (dateStr: string | Date) => LunarDate;
type lunar2solar = (dateStr: string, isLeapMonth?: boolean) => SolarDate;
使用方法
import {solar2lunar, lunar2solar} from 'lunar-lite';
const solarDate = lunar2solar('1990-10-10', true);
const lunarDate = solar2lunar('2023-10-23');