UNPKG

lunar-lite

Version:

精简版的农历和阳历日期转换库。

30 lines (29 loc) 904 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLeapDays = exports.getLeapMonth = void 0; var constants_1 = require("./constants"); /** * 返回农历年闰月是哪个月;若没有闰月 则返回0 * @param year 农历年份 * @return Number (0-12) * @example * leapMonth = getLeapMonth(1987) ; // leapMonth=6 */ var getLeapMonth = function (year) { return constants_1.LUNAR_INFO[year - 1900] & 0xf; }; exports.getLeapMonth = getLeapMonth; /** * 返回农历年闰月的天数 若该年没有闰月则返回0 * @param year 农历年份 * @return Number (0、29、30) * @example * leapMonthDay = getLeapDays(1987) ; //leapMonthDay=29 */ var getLeapDays = function (year) { if ((0, exports.getLeapMonth)(year)) { return constants_1.LUNAR_INFO[year - 1900] & 0x10000 ? 30 : 29; } return 0; }; exports.getLeapDays = getLeapDays;