lunar-lite
Advanced tools
Comparing version 0.0.3 to 0.1.0
/** | ||
* 公历每个月份的天数普通表 | ||
* 1,3,5,7,8,10,12月为 31 天 | ||
* 2月为28天,若闰年会在获取天数时+1天 | ||
* 其余月份为30天 | ||
*/ | ||
export declare const SOLAR_MONTH: readonly [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; | ||
/** | ||
* 天干速查表 | ||
@@ -16,56 +9,3 @@ */ | ||
export declare const EARTHLY_BRANCHES: readonly ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]; | ||
/** | ||
* 五虎遁 | ||
*/ | ||
export declare const RAT_RULE: { | ||
readonly 甲: "甲"; | ||
readonly 乙: "丙"; | ||
readonly 丙: "戊"; | ||
readonly 丁: "庚"; | ||
readonly 戊: "壬"; | ||
readonly 己: "甲"; | ||
readonly 庚: "丙"; | ||
readonly 辛: "戊"; | ||
readonly 壬: "庚"; | ||
readonly 癸: "壬"; | ||
}; | ||
/** | ||
* 24节气速查表 | ||
*/ | ||
export declare const SOLAR_STEM: readonly ["小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"]; | ||
/** | ||
* 数字转中文速查表 | ||
* 1. 星期取值范围从0~6,表示星期日到星期六 | ||
* 2. 日期取值范围从1~10 | ||
*/ | ||
export declare const NUM_TO_CHAR: readonly ["日", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]; | ||
/** | ||
* 日期转农历称呼速查表 | ||
* 1. 将7日显示为 初七 | ||
* 2. 将13日显示为 十三 | ||
* 3. 将24日显示为 廿四 | ||
* 4. 将31日显示为 卅一 | ||
*/ | ||
export declare const LUNAR_DAY_NAME: readonly ["初", "十", "廿", "卅"]; | ||
/** | ||
* 月份转农历称呼速查表 | ||
* 1. 1月显示为正月 | ||
* 2. 11月显示为冬月 | ||
* 3. 12月显示为腊月 | ||
* 4. 其他情况显示大写数字+月份 | ||
*/ | ||
export declare const LUNAR_MONTH_NAME: readonly ["", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊"]; | ||
/** | ||
* 农历1900-2100的润大小信息表,为二进制表示,最后5位以下3条会有共享情况 | ||
* 1. 前12位表示大小月,0表示小月(有29天),1表示大月(有30天) | ||
* 2. 最后4位表示闰月的月份(需将其转化成10进制),若当年没有闰月则为0000 | ||
* 3. 倒数第5位为闰月的大小,0表示小月(有29天),1表示大月(有30天) | ||
*/ | ||
export declare const LUNAR_INFO: readonly [19416, 19168, 42352, 21717, 53856, 55632, 91476, 22176, 39632, 21970, 19168, 42422, 42192, 53840, 119381, 46400, 54944, 44450, 38320, 84343, 18800, 42160, 46261, 27216, 27968, 109396, 11104, 38256, 21234, 18800, 25958, 54432, 59984, 28309, 23248, 11104, 100067, 37600, 116951, 51536, 54432, 120998, 46416, 22176, 107956, 9680, 37584, 53938, 43344, 46423, 27808, 46416, 86869, 19872, 42416, 83315, 21168, 43432, 59728, 27296, 44710, 43856, 19296, 43748, 42352, 21088, 62051, 55632, 23383, 22176, 38608, 19925, 19152, 42192, 54484, 53840, 54616, 46400, 46752, 103846, 38320, 18864, 43380, 42160, 45690, 27216, 27968, 44870, 43872, 38256, 19189, 18800, 25776, 29859, 59984, 27480, 23232, 43872, 38613, 37600, 51552, 55636, 54432, 55888, 30034, 22176, 43959, 9680, 37584, 51893, 43344, 46240, 47780, 44368, 21977, 19360, 42416, 86390, 21168, 43312, 31060, 27296, 44368, 23378, 19296, 42726, 42208, 53856, 60005, 54576, 23200, 30371, 38608, 19195, 19152, 42192, 118966, 53840, 54560, 56645, 46496, 22224, 21938, 18864, 42359, 42160, 43600, 111189, 27936, 44448, 84835, 37744, 18936, 18800, 25776, 92326, 59984, 27424, 108228, 43744, 41696, 53987, 51552, 54615, 54432, 55888, 23893, 22176, 42704, 21972, 21200, 43448, 43344, 46240, 46758, 44368, 21920, 43940, 42416, 21168, 45683, 26928, 29495, 27296, 44368, 84821, 19296, 42352, 21732, 53600, 59752, 54560, 55968, 92838, 22224, 19168, 43476, 41680, 53584, 62034, 54560]; | ||
/** | ||
* 1900-2100各年的24节气日期速查表 | ||
* .substring(0, 4)).toString() | ||
*/ | ||
export declare const TERM_INFO: readonly ["9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c3598082c95f8c965cc920f", "97bd0b06bdb0722c965ce1cfcc920f", "b027097bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd0b06bdb0722c965ce1cfcc920f", "b027097bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd0b06bdb0722c965ce1cfcc920f", "b027097bd097c36b0b6fc9274c91aa", "9778397bd19801ec9210c965cc920e", "97b6b97bd19801ec95f8c965cc920f", "97bd09801d98082c95f8e1cfcc920f", "97bd097bd097c36b0b6fc9210c8dc2", "9778397bd197c36c9210c9274c91aa", "97b6b97bd19801ec95f8c965cc920e", "97bd09801d98082c95f8e1cfcc920f", "97bd097bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c91aa", "97b6b97bd19801ec95f8c965cc920e", "97bcf97c3598082c95f8e1cfcc920f", "97bd097bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c3598082c95f8c965cc920f", "97bd097bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c3598082c95f8c965cc920f", "97bd097bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd097bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd097bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf97c359801ec95f8c965cc920f", "97bd097bd07f595b0b6fc920fb0722", "9778397bd097c36b0b6fc9210c8dc2", "9778397bd19801ec9210c9274c920e", "97b6b97bd19801ec95f8c965cc920f", "97bd07f5307f595b0b0bc920fb0722", "7f0e397bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c920e", "97b6b97bd19801ec95f8c965cc920f", "97bd07f5307f595b0b0bc920fb0722", "7f0e397bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bd07f1487f595b0b0bc920fb0722", "7f0e397bd097c36b0b6fc9210c8dc2", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf7f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf7f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf7f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c965cc920e", "97bcf7f1487f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b97bd19801ec9210c9274c920e", "97bcf7f0e47f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9210c91aa", "97b6b97bd197c36c9210c9274c920e", "97bcf7f0e47f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9210c8dc2", "9778397bd097c36c9210c9274c920e", "97b6b7f0e47f531b0723b0b6fb0722", "7f0e37f5307f595b0b0bc920fb0722", "7f0e397bd097c36b0b6fc9210c8dc2", "9778397bd097c36b0b70c9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e37f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc9210c8dc2", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e27f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9274c91aa", "97b6b7f0e47f531b0723b0787b0721", "7f0e27f0e47f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9210c91aa", "97b6b7f0e47f149b0723b0787b0721", "7f0e27f0e47f531b0723b0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "9778397bd097c36b0b6fc9210c8dc2", "977837f0e37f149b0723b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e37f5307f595b0b0bc920fb0722", "7f0e397bd097c35b0b6fc9210c8dc2", "977837f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e37f1487f595b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc9210c8dc2", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd097c35b0b6fc920fb0722", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "977837f0e37f14998082b0787b06bd", "7f07e7f0e47f149b0723b0787b0721", "7f0e27f0e47f531b0b0bb0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "977837f0e37f14998082b0723b06bd", "7f07e7f0e37f149b0723b0787b0721", "7f0e27f0e47f531b0723b0b6fb0722", "7f0e397bd07f595b0b0bc920fb0722", "977837f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e37f1487f595b0b0bb0b6fb0722", "7f0e37f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e37f1487f531b0b0bb0b6fb0722", "7f0e37f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e37f1487f531b0b0bb0b6fb0722", "7f0e37f0e37f14898082b072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e37f0e37f14898082b072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e37f0e366aa89801eb072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f149b0723b0787b0721", "7f0e27f1487f531b0b0bb0b6fb0722", "7f0e37f0e366aa89801eb072297c35", "7ec967f0e37f14998082b0723b06bd", "7f07e7f0e47f149b0723b0787b0721", "7f0e27f0e47f531b0723b0b6fb0722", "7f0e37f0e366aa89801eb072297c35", "7ec967f0e37f14998082b0723b06bd", "7f07e7f0e37f14998083b0787b0721", "7f0e27f0e47f531b0723b0b6fb0722", "7f0e37f0e366aa89801eb072297c35", "7ec967f0e37f14898082b0723b02d5", "7f07e7f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e36665b66aa89801e9808297c35", "665f67f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b0721", "7f07e7f0e47f531b0723b0b6fb0722", "7f0e36665b66a449801e9808297c35", "665f67f0e37f14898082b0723b02d5", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e36665b66a449801e9808297c35", "665f67f0e37f14898082b072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e26665b66a449801e9808297c35", "665f67f0e37f1489801eb072297c35", "7ec967f0e37f14998082b0787b06bd", "7f07e7f0e47f531b0723b0b6fb0721", "7f0e27f1487f531b0b0bb0b6fb0722"]; | ||
/** 十二生肖(按地支顺序) */ | ||
export declare const ZODIAC: readonly ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ZODIAC = exports.TERM_INFO = exports.LUNAR_INFO = exports.LUNAR_MONTH_NAME = exports.LUNAR_DAY_NAME = exports.NUM_TO_CHAR = exports.SOLAR_STEM = exports.RAT_RULE = exports.EARTHLY_BRANCHES = exports.HEAVENLY_STEMS = exports.SOLAR_MONTH = void 0; | ||
exports.ZODIAC = exports.EARTHLY_BRANCHES = exports.HEAVENLY_STEMS = void 0; | ||
/** | ||
* 公历每个月份的天数普通表 | ||
* 1,3,5,7,8,10,12月为 31 天 | ||
* 2月为28天,若闰年会在获取天数时+1天 | ||
* 其余月份为30天 | ||
*/ | ||
exports.SOLAR_MONTH = [ | ||
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, | ||
]; | ||
/** | ||
* 天干速查表 | ||
@@ -45,510 +36,2 @@ */ | ||
]; | ||
/** | ||
* 五虎遁 | ||
*/ | ||
exports.RAT_RULE = { | ||
甲: "甲", | ||
乙: "丙", | ||
丙: "戊", | ||
丁: "庚", | ||
戊: "壬", | ||
己: "甲", | ||
庚: "丙", | ||
辛: "戊", | ||
壬: "庚", | ||
癸: "壬", | ||
}; | ||
/** | ||
* 24节气速查表 | ||
*/ | ||
exports.SOLAR_STEM = [ | ||
"小寒", | ||
"大寒", | ||
"立春", | ||
"雨水", | ||
"惊蛰", | ||
"春分", | ||
"清明", | ||
"谷雨", | ||
"立夏", | ||
"小满", | ||
"芒种", | ||
"夏至", | ||
"小暑", | ||
"大暑", | ||
"立秋", | ||
"处暑", | ||
"白露", | ||
"秋分", | ||
"寒露", | ||
"霜降", | ||
"立冬", | ||
"小雪", | ||
"大雪", | ||
"冬至", | ||
]; | ||
/** | ||
* 数字转中文速查表 | ||
* 1. 星期取值范围从0~6,表示星期日到星期六 | ||
* 2. 日期取值范围从1~10 | ||
*/ | ||
exports.NUM_TO_CHAR = [ | ||
"日", | ||
"一", | ||
"二", | ||
"三", | ||
"四", | ||
"五", | ||
"六", | ||
"七", | ||
"八", | ||
"九", | ||
"十", | ||
]; | ||
/** | ||
* 日期转农历称呼速查表 | ||
* 1. 将7日显示为 初七 | ||
* 2. 将13日显示为 十三 | ||
* 3. 将24日显示为 廿四 | ||
* 4. 将31日显示为 卅一 | ||
*/ | ||
exports.LUNAR_DAY_NAME = ["初", "十", "廿", "卅"]; | ||
/** | ||
* 月份转农历称呼速查表 | ||
* 1. 1月显示为正月 | ||
* 2. 11月显示为冬月 | ||
* 3. 12月显示为腊月 | ||
* 4. 其他情况显示大写数字+月份 | ||
*/ | ||
exports.LUNAR_MONTH_NAME = [ | ||
"", | ||
"正", | ||
"二", | ||
"三", | ||
"四", | ||
"五", | ||
"六", | ||
"七", | ||
"八", | ||
"九", | ||
"十", | ||
"冬", | ||
"腊", | ||
]; | ||
/** | ||
* 农历1900-2100的润大小信息表,为二进制表示,最后5位以下3条会有共享情况 | ||
* 1. 前12位表示大小月,0表示小月(有29天),1表示大月(有30天) | ||
* 2. 最后4位表示闰月的月份(需将其转化成10进制),若当年没有闰月则为0000 | ||
* 3. 倒数第5位为闰月的大小,0表示小月(有29天),1表示大月(有30天) | ||
*/ | ||
exports.LUNAR_INFO = [ | ||
19416, | ||
19168, | ||
42352, | ||
21717, | ||
53856, | ||
55632, | ||
91476, | ||
22176, | ||
39632, | ||
21970, | ||
19168, | ||
42422, | ||
42192, | ||
53840, | ||
119381, | ||
46400, | ||
54944, | ||
44450, | ||
38320, | ||
84343, | ||
18800, | ||
42160, | ||
46261, | ||
27216, | ||
27968, | ||
109396, | ||
11104, | ||
38256, | ||
21234, | ||
18800, | ||
25958, | ||
54432, | ||
59984, | ||
28309, | ||
23248, | ||
11104, | ||
100067, | ||
37600, | ||
116951, | ||
51536, | ||
54432, | ||
120998, | ||
46416, | ||
22176, | ||
107956, | ||
9680, | ||
37584, | ||
53938, | ||
43344, | ||
46423, | ||
27808, | ||
46416, | ||
86869, | ||
19872, | ||
42416, | ||
83315, | ||
21168, | ||
43432, | ||
59728, | ||
27296, | ||
44710, | ||
43856, | ||
19296, | ||
43748, | ||
42352, | ||
21088, | ||
62051, | ||
55632, | ||
23383, | ||
22176, | ||
38608, | ||
19925, | ||
19152, | ||
42192, | ||
54484, | ||
53840, | ||
54616, | ||
46400, | ||
46752, | ||
103846, | ||
38320, | ||
18864, | ||
43380, | ||
42160, | ||
45690, | ||
27216, | ||
27968, | ||
44870, | ||
43872, | ||
38256, | ||
19189, | ||
18800, | ||
25776, | ||
29859, | ||
59984, | ||
27480, | ||
23232, | ||
43872, | ||
38613, | ||
37600, | ||
51552, | ||
55636, | ||
54432, | ||
55888, | ||
30034, | ||
22176, | ||
43959, | ||
9680, | ||
37584, | ||
51893, | ||
43344, | ||
46240, | ||
47780, | ||
44368, | ||
21977, | ||
19360, | ||
42416, | ||
86390, | ||
21168, | ||
43312, | ||
31060, | ||
27296, | ||
44368, | ||
23378, | ||
19296, | ||
42726, | ||
42208, | ||
53856, | ||
60005, | ||
54576, | ||
23200, | ||
30371, | ||
38608, | ||
19195, | ||
19152, | ||
42192, | ||
118966, | ||
53840, | ||
54560, | ||
56645, | ||
46496, | ||
22224, | ||
21938, | ||
18864, | ||
42359, | ||
42160, | ||
43600, | ||
111189, | ||
27936, | ||
44448, | ||
84835, | ||
37744, | ||
18936, | ||
18800, | ||
25776, | ||
92326, | ||
59984, | ||
27424, | ||
108228, | ||
43744, | ||
41696, | ||
53987, | ||
51552, | ||
54615, | ||
54432, | ||
55888, | ||
23893, | ||
22176, | ||
42704, | ||
21972, | ||
21200, | ||
43448, | ||
43344, | ||
46240, | ||
46758, | ||
44368, | ||
21920, | ||
43940, | ||
42416, | ||
21168, | ||
45683, | ||
26928, | ||
29495, | ||
27296, | ||
44368, | ||
84821, | ||
19296, | ||
42352, | ||
21732, | ||
53600, | ||
59752, | ||
54560, | ||
55968, | ||
92838, | ||
22224, | ||
19168, | ||
43476, | ||
41680, | ||
53584, | ||
62034, | ||
54560, | ||
]; | ||
/** | ||
* 1900-2100各年的24节气日期速查表 | ||
* .substring(0, 4)).toString() | ||
*/ | ||
exports.TERM_INFO = [ | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf97c3598082c95f8c965cc920f", | ||
"97bd0b06bdb0722c965ce1cfcc920f", | ||
"b027097bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf97c359801ec95f8c965cc920f", | ||
"97bd0b06bdb0722c965ce1cfcc920f", | ||
"b027097bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf97c359801ec95f8c965cc920f", | ||
"97bd0b06bdb0722c965ce1cfcc920f", | ||
"b027097bd097c36b0b6fc9274c91aa", | ||
"9778397bd19801ec9210c965cc920e", | ||
"97b6b97bd19801ec95f8c965cc920f", | ||
"97bd09801d98082c95f8e1cfcc920f", | ||
"97bd097bd097c36b0b6fc9210c8dc2", | ||
"9778397bd197c36c9210c9274c91aa", | ||
"97b6b97bd19801ec95f8c965cc920e", | ||
"97bd09801d98082c95f8e1cfcc920f", | ||
"97bd097bd097c36b0b6fc9210c8dc2", | ||
"9778397bd097c36c9210c9274c91aa", | ||
"97b6b97bd19801ec95f8c965cc920e", | ||
"97bcf97c3598082c95f8e1cfcc920f", | ||
"97bd097bd097c36b0b6fc9210c8dc2", | ||
"9778397bd097c36c9210c9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf97c3598082c95f8c965cc920f", | ||
"97bd097bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf97c3598082c95f8c965cc920f", | ||
"97bd097bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf97c359801ec95f8c965cc920f", | ||
"97bd097bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf97c359801ec95f8c965cc920f", | ||
"97bd097bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf97c359801ec95f8c965cc920f", | ||
"97bd097bd07f595b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9210c8dc2", | ||
"9778397bd19801ec9210c9274c920e", | ||
"97b6b97bd19801ec95f8c965cc920f", | ||
"97bd07f5307f595b0b0bc920fb0722", | ||
"7f0e397bd097c36b0b6fc9210c8dc2", | ||
"9778397bd097c36c9210c9274c920e", | ||
"97b6b97bd19801ec95f8c965cc920f", | ||
"97bd07f5307f595b0b0bc920fb0722", | ||
"7f0e397bd097c36b0b6fc9210c8dc2", | ||
"9778397bd097c36c9210c9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bd07f1487f595b0b0bc920fb0722", | ||
"7f0e397bd097c36b0b6fc9210c8dc2", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf7f1487f595b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf7f1487f595b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf7f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c965cc920e", | ||
"97bcf7f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd07f595b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b97bd19801ec9210c9274c920e", | ||
"97bcf7f0e47f531b0b0bb0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"9778397bd097c36b0b6fc9210c91aa", | ||
"97b6b97bd197c36c9210c9274c920e", | ||
"97bcf7f0e47f531b0b0bb0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"9778397bd097c36b0b6fc9210c8dc2", | ||
"9778397bd097c36c9210c9274c920e", | ||
"97b6b7f0e47f531b0723b0b6fb0722", | ||
"7f0e37f5307f595b0b0bc920fb0722", | ||
"7f0e397bd097c36b0b6fc9210c8dc2", | ||
"9778397bd097c36b0b70c9274c91aa", | ||
"97b6b7f0e47f531b0723b0b6fb0721", | ||
"7f0e37f1487f595b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc9210c8dc2", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f595b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"9778397bd097c36b0b6fc9274c91aa", | ||
"97b6b7f0e47f531b0723b0787b0721", | ||
"7f0e27f0e47f531b0b0bb0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"9778397bd097c36b0b6fc9210c91aa", | ||
"97b6b7f0e47f149b0723b0787b0721", | ||
"7f0e27f0e47f531b0723b0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"9778397bd097c36b0b6fc9210c8dc2", | ||
"977837f0e37f149b0723b0787b0721", | ||
"7f07e7f0e47f531b0723b0b6fb0722", | ||
"7f0e37f5307f595b0b0bc920fb0722", | ||
"7f0e397bd097c35b0b6fc9210c8dc2", | ||
"977837f0e37f14998082b0787b0721", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e37f1487f595b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc9210c8dc2", | ||
"977837f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc920fb0722", | ||
"977837f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd097c35b0b6fc920fb0722", | ||
"977837f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"977837f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"977837f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f149b0723b0787b0721", | ||
"7f0e27f0e47f531b0b0bb0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"977837f0e37f14998082b0723b06bd", | ||
"7f07e7f0e37f149b0723b0787b0721", | ||
"7f0e27f0e47f531b0723b0b6fb0722", | ||
"7f0e397bd07f595b0b0bc920fb0722", | ||
"977837f0e37f14898082b0723b02d5", | ||
"7ec967f0e37f14998082b0787b0721", | ||
"7f07e7f0e47f531b0723b0b6fb0722", | ||
"7f0e37f1487f595b0b0bb0b6fb0722", | ||
"7f0e37f0e37f14898082b0723b02d5", | ||
"7ec967f0e37f14998082b0787b0721", | ||
"7f07e7f0e47f531b0723b0b6fb0722", | ||
"7f0e37f1487f531b0b0bb0b6fb0722", | ||
"7f0e37f0e37f14898082b0723b02d5", | ||
"7ec967f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e37f1487f531b0b0bb0b6fb0722", | ||
"7f0e37f0e37f14898082b072297c35", | ||
"7ec967f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e37f0e37f14898082b072297c35", | ||
"7ec967f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e37f0e366aa89801eb072297c35", | ||
"7ec967f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f149b0723b0787b0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
"7f0e37f0e366aa89801eb072297c35", | ||
"7ec967f0e37f14998082b0723b06bd", | ||
"7f07e7f0e47f149b0723b0787b0721", | ||
"7f0e27f0e47f531b0723b0b6fb0722", | ||
"7f0e37f0e366aa89801eb072297c35", | ||
"7ec967f0e37f14998082b0723b06bd", | ||
"7f07e7f0e37f14998083b0787b0721", | ||
"7f0e27f0e47f531b0723b0b6fb0722", | ||
"7f0e37f0e366aa89801eb072297c35", | ||
"7ec967f0e37f14898082b0723b02d5", | ||
"7f07e7f0e37f14998082b0787b0721", | ||
"7f07e7f0e47f531b0723b0b6fb0722", | ||
"7f0e36665b66aa89801e9808297c35", | ||
"665f67f0e37f14898082b0723b02d5", | ||
"7ec967f0e37f14998082b0787b0721", | ||
"7f07e7f0e47f531b0723b0b6fb0722", | ||
"7f0e36665b66a449801e9808297c35", | ||
"665f67f0e37f14898082b0723b02d5", | ||
"7ec967f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e36665b66a449801e9808297c35", | ||
"665f67f0e37f14898082b072297c35", | ||
"7ec967f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e26665b66a449801e9808297c35", | ||
"665f67f0e37f1489801eb072297c35", | ||
"7ec967f0e37f14998082b0787b06bd", | ||
"7f07e7f0e47f531b0723b0b6fb0721", | ||
"7f0e27f1487f531b0b0bb0b6fb0722", | ||
]; | ||
/** 十二生肖(按地支顺序) */ | ||
@@ -555,0 +38,0 @@ exports.ZODIAC = [ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lunar2solar = exports.solar2lunar = exports.normalizeDateStr = void 0; | ||
var days_1 = require("./days"); | ||
var leap_1 = require("./leap"); | ||
var misc_1 = require("./misc"); | ||
var lunar_typescript_1 = require("lunar-typescript"); | ||
/** | ||
@@ -42,63 +40,8 @@ * 将日期字符串 YYYY-MM-DD 或者一个 Date 对象分割为 [YYYY, M, D, H, m, s] | ||
var _a = (0, exports.normalizeDateStr)(dateStr), year = _a[0], month = _a[1], day = _a[2]; | ||
// 参数区间1900.1.31~2100.12.31 | ||
// 年份限定、上限 | ||
if (year < 1900 || year > 2100) { | ||
throw new Error("year should be between 1900 and 2100."); | ||
} | ||
// 公历传参最下限 1900-01-31 | ||
if (year === 1900 && month === 1 && day < 31) { | ||
throw new Error("date must be after 1900-1-31."); | ||
} | ||
var utcDate = Date.UTC(year, month - 1, day); // 获取当前日期UTC值 | ||
var utcFloor = Date.UTC(1900, 0, 31); // 获取1900-1-31日的UTC值 | ||
var lunarYear; // 农历年份 | ||
var totalDayOfYear = 0; | ||
var offset = (utcDate - utcFloor) / 86400000; // 将差值转化为天 | ||
for (lunarYear = 1900; lunarYear < 2101 && offset > 0; lunarYear++) { | ||
// 从1900年往2100年循环,将offset减去每一年的天数,当offset小于等于0的时候 | ||
// 结束循环,当前的索引即是农历年份 | ||
totalDayOfYear = (0, days_1.getTotalDaysOfLunarYear)(lunarYear); | ||
offset -= totalDayOfYear; | ||
} | ||
if (offset < 0) { | ||
// 当offset小于0了,需要将农历年份减去1 | ||
offset += totalDayOfYear; | ||
lunarYear--; | ||
} | ||
var leapMonth = (0, leap_1.getLeapMonth)(lunarYear); // 获取农历年闰月,如果该年没有闰月返回0 | ||
var totalDayOfMonth = 0; | ||
var lunarMonth; // 农历月份 | ||
var leapFixed = false; | ||
for (lunarMonth = 1; lunarMonth < 13 && offset > 0; lunarMonth++) { | ||
if (leapMonth > 0 && lunarMonth === leapMonth + 1 && leapFixed === false) { | ||
// 闰月 | ||
--lunarMonth; | ||
leapFixed = true; | ||
totalDayOfMonth = (0, leap_1.getLeapDays)(lunarYear); // 计算农历闰月天数 | ||
} | ||
else { | ||
// 非闰月 | ||
totalDayOfMonth = (0, days_1.getTotalDaysOfLunarMonth)(lunarYear, lunarMonth); // 计算农历普通月天数 | ||
} | ||
// 解除闰月; | ||
if (leapFixed && lunarMonth === leapMonth + 1) { | ||
leapFixed = false; | ||
} | ||
offset -= totalDayOfMonth; | ||
} | ||
// 修复闰月导致数组下标重叠 | ||
if (offset === 0 && leapMonth > 0 && lunarMonth === leapMonth + 1) { | ||
if (leapFixed) { | ||
leapFixed = false; | ||
} | ||
else { | ||
leapFixed = true; | ||
--lunarMonth; | ||
} | ||
} | ||
if (offset < 0) { | ||
offset += totalDayOfMonth; | ||
--lunarMonth; | ||
} | ||
var lunarDay = offset + 1; | ||
var solar = lunar_typescript_1.Solar.fromYmd(year, month, day); | ||
var lunar = solar.getLunar(); | ||
var lunarYear = lunar.getYear(); | ||
var lunarMonth = Math.abs(lunar.getMonth()); | ||
var lunarDay = lunar.getDay(); | ||
var isLeap = lunar.getMonth() < 0; | ||
return { | ||
@@ -108,6 +51,6 @@ lunarYear: lunarYear, | ||
lunarDay: lunarDay, | ||
isLeap: leapFixed, | ||
isLeap: isLeap, | ||
toString: function (toCnStr) { | ||
if (toCnStr) { | ||
return (0, misc_1.lunarDateToStr)("".concat(lunarYear, "-").concat(lunarMonth, "-").concat(lunarDay), leapFixed); | ||
return lunar.toString(); | ||
} | ||
@@ -128,39 +71,12 @@ return "".concat(lunarYear, "-").concat(lunarMonth, "-").concat(lunarDay); | ||
var _a = (0, exports.normalizeDateStr)(dateStr), year = _a[0], month = _a[1], day = _a[2]; | ||
var leapMonth = (0, leap_1.getLeapMonth)(year); | ||
if (isLeapMonth && leapMonth !== month) { | ||
// 该月不是闰月但传入了闰月标志,则讲标志设为false | ||
isLeapMonth = false; | ||
var lunar = lunar_typescript_1.Lunar.fromYmd(year, month, day); | ||
var lunarYear = lunar_typescript_1.LunarYear.fromYear(lunar.getYear()); | ||
var leapMonth = lunarYear.getLeapMonth(); | ||
if (leapMonth > 0 && isLeapMonth) { | ||
lunar = lunar_typescript_1.Lunar.fromYmd(year, 0 - month, day); | ||
} | ||
var totalLeapDays = (0, leap_1.getLeapDays)(year); | ||
var totalDaysOfTheMonth = (0, days_1.getTotalDaysOfLunarMonth)(year, month); | ||
// 获取当月总天数 | ||
var totalDays = isLeapMonth ? totalLeapDays : totalDaysOfTheMonth; | ||
if (year < 1900 || year > 2100 || day > totalDays) { | ||
// 日期不合法 | ||
throw new Error("invalid date."); | ||
} | ||
// 农历日期时间偏移量 | ||
var offset = 0; | ||
// 将今年以前的年份时间偏移量加入offset | ||
for (var i = 1900; i < year; i++) { | ||
offset += (0, days_1.getTotalDaysOfLunarYear)(i); | ||
} | ||
if (leapMonth < month && leapMonth > 0) { | ||
// 若该月前面有闰月,则需要将闰月天数加入偏移量 | ||
offset += totalLeapDays; | ||
} | ||
// 将今年的当月以前的时间偏移量加入offset | ||
for (var i = 1; i < month; i++) { | ||
offset += (0, days_1.getTotalDaysOfLunarMonth)(year, i); | ||
} | ||
// 转换闰月农历 需补充该年闰月的前一个月的时差 | ||
if (isLeapMonth) { | ||
offset += totalDaysOfTheMonth; | ||
} | ||
// 1900年农历正月一日的公历时间为1900年1月30日0时0分0秒(该时间也是本农历的最开始起始点) | ||
var stmap = Date.UTC(1900, 1, 30, 0, 0, 0); | ||
var solarDate = new Date((offset + day - 31) * 86400000 + stmap); | ||
var solarYear = solarDate.getUTCFullYear(); | ||
var solarMonth = solarDate.getUTCMonth() + 1; | ||
var solarDay = solarDate.getUTCDate(); | ||
var solar = lunar.getSolar(); | ||
var solarYear = solar.getYear(); | ||
var solarMonth = solar.getMonth(); | ||
var solarDay = solar.getDay(); | ||
return { | ||
@@ -167,0 +83,0 @@ solarYear: solarYear, |
@@ -1,33 +0,3 @@ | ||
import { HeavenlyStem, HeavenlyStemAndEarthlyBranch, HeavenlyStemAndEarthlyBranchDate } from "./types"; | ||
import { HeavenlyStemAndEarthlyBranchDate } from "./types"; | ||
/** | ||
* 农历年份计算年干支 | ||
* | ||
* @param year 农历年的年份数 | ||
* @return [干, 支] | ||
*/ | ||
export declare const heavenlyStemAndEarthlyBranchOfYear: (year: number) => HeavenlyStemAndEarthlyBranch; | ||
/** | ||
* 通过公历日期计算月干支 | ||
* | ||
* @param date 公历日期 | ||
* @returns [干, 支] | ||
*/ | ||
export declare const heavenlyStemAndEarthlyBranchOfMonth: (date: Date) => HeavenlyStemAndEarthlyBranch; | ||
/** | ||
* 获取公历日期计算日干支 | ||
* | ||
* @param date 公历日期 | ||
* @param timeIndex 时辰索引,主要是为了修复晚子时需要加一天的问题 | ||
* @returns [干, 支] | ||
*/ | ||
export declare const heavenlyStemAndEarthlyBranchOfDay: (date: Date) => HeavenlyStemAndEarthlyBranch; | ||
/** | ||
* 通过当天的日天干获取第 `t` (0~11)个时辰的干支,需要通过五鼠遁来定时辰天干 | ||
* | ||
* @param timeIndex 时辰序号(0~11),子时为0,亥时为11 | ||
* @param heavenlyStemNameOfDay 当日天干 | ||
* @returns [干, 支] | ||
*/ | ||
export declare const heavenlyStemAndEarthlyBranchOfTime: (timeIndex: number, heavenlyStemNameOfDay: HeavenlyStem) => HeavenlyStemAndEarthlyBranch; | ||
/** | ||
* 通过农历获取生辰干支 | ||
@@ -34,0 +4,0 @@ * |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getHeavenlyStemAndEarthlyBranchBySolarDate = exports.getHeavenlyStemAndEarthlyBranchByLunarDate = exports.heavenlyStemAndEarthlyBranchOfTime = exports.heavenlyStemAndEarthlyBranchOfDay = exports.heavenlyStemAndEarthlyBranchOfMonth = exports.heavenlyStemAndEarthlyBranchOfYear = void 0; | ||
var utils_1 = require("./utils"); | ||
exports.getHeavenlyStemAndEarthlyBranchBySolarDate = exports.getHeavenlyStemAndEarthlyBranchByLunarDate = void 0; | ||
var convertor_1 = require("./convertor"); | ||
var misc_1 = require("./misc"); | ||
var constants_1 = require("./constants"); | ||
var lunar_typescript_1 = require("lunar-typescript"); | ||
/** | ||
* 传入offset偏移量返回干支 | ||
* | ||
* @param offset 相对甲子的偏移量,单位为天 | ||
* @return [干, 支] | ||
*/ | ||
var heavenlyStemAndEarthlyBranchFromOffset = function (offset) { | ||
return [constants_1.HEAVENLY_STEMS[offset % 10], constants_1.EARTHLY_BRANCHES[offset % 12]]; | ||
}; | ||
/** | ||
* 农历年份计算年干支 | ||
* | ||
* @param year 农历年的年份数 | ||
* @return [干, 支] | ||
*/ | ||
var heavenlyStemAndEarthlyBranchOfYear = function (year) { | ||
var heavenStemKey = (year - 3) % 10; | ||
var earthlyBranchKey = (year - 3) % 12; | ||
if (heavenStemKey === 0) | ||
heavenStemKey = 10; // 如果余数为0则为最后一个天干 | ||
if (earthlyBranchKey === 0) | ||
earthlyBranchKey = 12; // 如果余数为0则为最后一个地支 | ||
return [ | ||
constants_1.HEAVENLY_STEMS[heavenStemKey - 1], | ||
constants_1.EARTHLY_BRANCHES[earthlyBranchKey - 1], | ||
]; | ||
}; | ||
exports.heavenlyStemAndEarthlyBranchOfYear = heavenlyStemAndEarthlyBranchOfYear; | ||
/** | ||
* 通过公历日期计算月干支 | ||
* | ||
* @param date 公历日期 | ||
* @returns [干, 支] | ||
*/ | ||
var heavenlyStemAndEarthlyBranchOfMonth = function (date) { | ||
var _a = (0, convertor_1.normalizeDateStr)(date), year = _a[0], month = _a[1], day = _a[2]; | ||
// 当月的第一个节气 | ||
// 返回当月「节」为几日开始 | ||
var firstNode = (0, misc_1.getTerm)(year, month * 2 - 1); | ||
var offset = (year - 1900) * 12 + month + 11; | ||
if (day >= firstNode) { | ||
return heavenlyStemAndEarthlyBranchFromOffset(offset + 1); | ||
} | ||
return heavenlyStemAndEarthlyBranchFromOffset(offset); | ||
}; | ||
exports.heavenlyStemAndEarthlyBranchOfMonth = heavenlyStemAndEarthlyBranchOfMonth; | ||
/** | ||
* 获取公历日期计算日干支 | ||
* | ||
* @param date 公历日期 | ||
* @param timeIndex 时辰索引,主要是为了修复晚子时需要加一天的问题 | ||
* @returns [干, 支] | ||
*/ | ||
var heavenlyStemAndEarthlyBranchOfDay = function (date) { | ||
var _a = (0, convertor_1.normalizeDateStr)(date), year = _a[0], month = _a[1], day = _a[2]; | ||
var dayCyclical = Date.UTC(year, month - 1, 1, 0, 0, 0, 0) / 86400000 + 25567 + 10; | ||
return heavenlyStemAndEarthlyBranchFromOffset(dayCyclical + day - 1); | ||
}; | ||
exports.heavenlyStemAndEarthlyBranchOfDay = heavenlyStemAndEarthlyBranchOfDay; | ||
/** | ||
* 通过当天的日天干获取第 `t` (0~11)个时辰的干支,需要通过五鼠遁来定时辰天干 | ||
* | ||
* @param timeIndex 时辰序号(0~11),子时为0,亥时为11 | ||
* @param heavenlyStemNameOfDay 当日天干 | ||
* @returns [干, 支] | ||
*/ | ||
var heavenlyStemAndEarthlyBranchOfTime = function (timeIndex, heavenlyStemNameOfDay) { | ||
var startHeavenlyStem = constants_1.RAT_RULE[heavenlyStemNameOfDay]; | ||
var heavenlyStem = constants_1.HEAVENLY_STEMS[(0, utils_1.fixIndex)(constants_1.HEAVENLY_STEMS.indexOf(startHeavenlyStem) + (0, utils_1.fixIndex)(timeIndex), 10)]; | ||
var earthlyBranch = constants_1.EARTHLY_BRANCHES[(0, utils_1.fixIndex)(timeIndex)]; | ||
return [heavenlyStem, earthlyBranch]; | ||
}; | ||
exports.heavenlyStemAndEarthlyBranchOfTime = heavenlyStemAndEarthlyBranchOfTime; | ||
/** | ||
* 通过农历获取生辰干支 | ||
@@ -103,12 +28,20 @@ * | ||
var _a = (0, convertor_1.normalizeDateStr)(dateStr), year = _a[0], month = _a[1], date = _a[2]; | ||
var solarDate = new Date(year, month - 1, date); | ||
if (timeIndex == 12) { | ||
// 晚子时,需要加1天 | ||
solarDate.setDate(solarDate.getDate() + 1); | ||
} | ||
var lunarYear = (0, convertor_1.solar2lunar)(solarDate).lunarYear; | ||
var yearly = (0, exports.heavenlyStemAndEarthlyBranchOfYear)(lunarYear); | ||
var monthly = (0, exports.heavenlyStemAndEarthlyBranchOfMonth)(solarDate); | ||
var daily = (0, exports.heavenlyStemAndEarthlyBranchOfDay)(solarDate); | ||
var hourly = (0, exports.heavenlyStemAndEarthlyBranchOfTime)(timeIndex, daily[0]); | ||
var solar = lunar_typescript_1.Solar.fromYmdHms(year, month, date, Math.max(timeIndex * 2 - 1, 0), 30, 0); | ||
var lunar = solar.getLunar(); | ||
var yearly = [ | ||
lunar.getYearGanByLiChun(), | ||
lunar.getYearZhiByLiChun(), | ||
]; | ||
var monthly = [ | ||
lunar.getMonthGanExact(), | ||
lunar.getMonthZhiExact(), | ||
]; | ||
var daily = [ | ||
lunar.getDayGanExact(), | ||
lunar.getDayZhiExact(), | ||
]; | ||
var hourly = [ | ||
lunar.getTimeGan(), | ||
lunar.getTimeZhi(), | ||
]; | ||
return { | ||
@@ -115,0 +48,0 @@ yearly: yearly, |
@@ -1,5 +0,3 @@ | ||
export * from "./days"; | ||
export * from "./leap"; | ||
export * from "./misc"; | ||
export * from "./ganzhi"; | ||
export * from "./convertor"; |
@@ -17,6 +17,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./days"), exports); | ||
__exportStar(require("./leap"), exports); | ||
__exportStar(require("./misc"), exports); | ||
__exportStar(require("./ganzhi"), exports); | ||
__exportStar(require("./convertor"), exports); |
import { EarthlyBranch } from "./types"; | ||
/** | ||
* 传入公历年获得该年第termNo个节气的公历节气日 | ||
* | ||
* @param year 公历年(1900-2100);n二十四节气中的第几个节气(1~24);从n=1(小寒)算起 | ||
* @param termNo 节气序号【1~24】 | ||
* @return 节气日期 | ||
* @example | ||
* termDay = getTerm(1987, 3); // termDay=4; 即1987年2月4日立春 | ||
*/ | ||
export declare const getTerm: (year: number, termNo: number) => number; | ||
/** | ||
* 将数字年份转化为中文字符串 | ||
* | ||
* @param lunarYear 农历年份数字 | ||
* @returns 农历年份字符串 | ||
* @example | ||
* str = lunarYearToStr(1986); // str = '一九八六' | ||
*/ | ||
export declare const lunarYearToStr: (lunarYear: number) => string; | ||
/** | ||
* 将数字月份转化为中文字符串 | ||
* | ||
* @param lunarMonth 农历月份数字 | ||
* @returns 农历月份字符串 | ||
* @example | ||
* str = lunarMonthToStr(1); // str = '正月' | ||
*/ | ||
export declare const lunarMonthToStr: (lunarMonth: number) => string; | ||
/** | ||
* 将数字日转化为中文字符串 | ||
* | ||
* @param lunarDay 农历日数字 | ||
* @returns 农历日字符串 | ||
* @example | ||
* str = lunarDayToStr(7); // str = '初七' | ||
*/ | ||
export declare const lunarDayToStr: (lunarDay: number) => string; | ||
/** | ||
* 将 YYYY-MM-DD 格式的农历日期转化为中文字符串 | ||
* | ||
* @param lunarDateStr 农历日期字符串 YYYY-MM-DD | ||
* @param isLeap 是否闰月 | ||
* @returns 农历日期的中文字符串 | ||
*/ | ||
export declare const lunarDateToStr: (lunarDateStr: string, isLeap: boolean) => string; | ||
/** | ||
* 获取星座 | ||
@@ -49,0 +4,0 @@ * |
126
lib/misc.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getZodiac = exports.getSign = exports.lunarDateToStr = exports.lunarDayToStr = exports.lunarMonthToStr = exports.lunarYearToStr = exports.getTerm = void 0; | ||
exports.getZodiac = exports.getSign = void 0; | ||
var lunar_typescript_1 = require("lunar-typescript"); | ||
var constants_1 = require("./constants"); | ||
var convertor_1 = require("./convertor"); | ||
/** | ||
* 传入公历年获得该年第termNo个节气的公历节气日 | ||
* | ||
* @param year 公历年(1900-2100);n二十四节气中的第几个节气(1~24);从n=1(小寒)算起 | ||
* @param termNo 节气序号【1~24】 | ||
* @return 节气日期 | ||
* @example | ||
* termDay = getTerm(1987, 3); // termDay=4; 即1987年2月4日立春 | ||
*/ | ||
var getTerm = function (year, termNo) { | ||
if (year < 1900 || year > 2100) { | ||
throw new Error("Year should be greater or equal then 1900."); | ||
} | ||
if (termNo < 1 || termNo > 24) { | ||
throw new Error("termNo should be between 1 and 24."); | ||
} | ||
var _table = constants_1.TERM_INFO[year - 1900]; | ||
var _info = []; | ||
for (var i = 0; i < 30; i += 5) { | ||
_info.push(parseInt("0x" + _table.substring(i, i + 5), 16).toString()); | ||
} | ||
var _calday = []; | ||
_info.forEach(function (item) { | ||
_calday.push(item.substring(0, 1)); | ||
_calday.push(item.substring(1, 3)); | ||
_calday.push(item.substring(3, 4)); | ||
_calday.push(item.substring(4, 6)); | ||
}); | ||
return parseInt(_calday[termNo - 1], 10); | ||
}; | ||
exports.getTerm = getTerm; | ||
/** | ||
* 将数字年份转化为中文字符串 | ||
* | ||
* @param lunarYear 农历年份数字 | ||
* @returns 农历年份字符串 | ||
* @example | ||
* str = lunarYearToStr(1986); // str = '一九八六' | ||
*/ | ||
var lunarYearToStr = function (lunarYear) { | ||
var y = lunarYear.toString(); | ||
var char = ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"]; | ||
var result = ""; | ||
for (var i = 0; i < y.length; i++) { | ||
result = result + char[+y.charAt(i)]; | ||
} | ||
return result; | ||
}; | ||
exports.lunarYearToStr = lunarYearToStr; | ||
/** | ||
* 将数字月份转化为中文字符串 | ||
* | ||
* @param lunarMonth 农历月份数字 | ||
* @returns 农历月份字符串 | ||
* @example | ||
* str = lunarMonthToStr(1); // str = '正月' | ||
*/ | ||
var lunarMonthToStr = function (lunarMonth) { | ||
if (lunarMonth > 12 || lunarMonth < 1) { | ||
throw new Error("lunarMonth should be between 1 and 12."); | ||
} | ||
return "".concat(constants_1.LUNAR_MONTH_NAME[lunarMonth], "\u6708"); | ||
}; | ||
exports.lunarMonthToStr = lunarMonthToStr; | ||
/** | ||
* 将数字日转化为中文字符串 | ||
* | ||
* @param lunarDay 农历日数字 | ||
* @returns 农历日字符串 | ||
* @example | ||
* str = lunarDayToStr(7); // str = '初七' | ||
*/ | ||
var lunarDayToStr = function (lunarDay) { | ||
var result = ""; | ||
switch (lunarDay) { | ||
case 10: | ||
result = "初十"; | ||
break; | ||
case 20: | ||
result = "二十"; | ||
break; | ||
case 30: | ||
result = "三十"; | ||
break; | ||
default: | ||
result = "".concat(constants_1.LUNAR_DAY_NAME[Math.floor(lunarDay / 10)]).concat(constants_1.NUM_TO_CHAR[lunarDay % 10]); | ||
} | ||
return result; | ||
}; | ||
exports.lunarDayToStr = lunarDayToStr; | ||
/** | ||
* 将 YYYY-MM-DD 格式的农历日期转化为中文字符串 | ||
* | ||
* @param lunarDateStr 农历日期字符串 YYYY-MM-DD | ||
* @param isLeap 是否闰月 | ||
* @returns 农历日期的中文字符串 | ||
*/ | ||
var lunarDateToStr = function (lunarDateStr, isLeap) { | ||
var _a = lunarDateStr.split("-").map(function (item) { return +item; }), year = _a[0], month = _a[1], day = _a[2]; | ||
return "".concat((0, exports.lunarYearToStr)(year), "\u5E74").concat(isLeap ? "(闰)" : "").concat((0, exports.lunarMonthToStr)(month)).concat((0, exports.lunarDayToStr)(day)); | ||
}; | ||
exports.lunarDateToStr = lunarDateToStr; | ||
/** | ||
* 获取星座 | ||
@@ -115,21 +14,4 @@ * | ||
var getSign = function (solarDateStr) { | ||
var _a = (0, convertor_1.normalizeDateStr)(solarDateStr), month = _a[1], day = _a[2]; | ||
var s = [ | ||
"摩羯座", | ||
"水瓶座", | ||
"双鱼座", | ||
"白羊座", | ||
"金牛座", | ||
"双子座", | ||
"巨蟹座", | ||
"狮子座", | ||
"处女座", | ||
"天秤座", | ||
"天蝎座", | ||
"射手座", | ||
"摩羯座", | ||
]; | ||
var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22]; | ||
var idx = Math.floor((month * 2 - (day < arr[month - 1] ? 2 : 0)) / 2); | ||
return s[idx]; | ||
var _a = (0, convertor_1.normalizeDateStr)(solarDateStr), year = _a[0], month = _a[1], day = _a[2]; | ||
return lunar_typescript_1.Solar.fromYmd(year, month, day).getXingZuo() + '座'; | ||
}; | ||
@@ -136,0 +18,0 @@ exports.getSign = getSign; |
@@ -34,3 +34,3 @@ import { EARTHLY_BRANCHES, HEAVENLY_STEMS } from "./constants"; | ||
* toString(); // 2023-6-12 | ||
* toString(true); // 二〇二三年(闰)二月十一 | ||
* toString(true); // 二〇二三年闰二月十一 | ||
*/ | ||
@@ -37,0 +37,0 @@ toString: (toCnStr?: boolean) => string; |
{ | ||
"name": "lunar-lite", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "精简版的农历和阳历日期转换库。", | ||
@@ -54,3 +54,5 @@ "main": "lib/index.js", | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"lunar-typescript": "^1.6.13" | ||
} | ||
} |
@@ -15,3 +15,3 @@ <div align="center"> | ||
![Codecov](https://img.shields.io/codecov/c/github/SylarLong/lunar-lite?logo=codecov&logoColor=%23F01F7A) | ||
[![npm](https://img.shields.io/npm/dw/lunar-lite?logo=npm&logoColor=%23CB3837)](https://www.npmjs.com/package/lunar-lite) | ||
[![npm](https://img.shields.io/npm/dt/lunar-lite?logo=npm&logoColor=%23CB3837)](https://www.npmjs.com/package/lunar-lite) | ||
[![GitHub](https://img.shields.io/github/license/sylarlong/lunar-lite)](https://www.npmjs.com/package/lunar-lite) | ||
@@ -68,3 +68,3 @@ [![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/SylarLong/lunar-lite)](https://www.npmjs.com/package/lunar-lite) | ||
* toString(); // 2023-6-12 | ||
* toString(true); // 二〇二三年(闰)二月十一 | ||
* toString(true); // 二〇二三年闰二月十一 | ||
*/ | ||
@@ -71,0 +71,0 @@ toString: (toCnStr?: boolean) => string; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24409
1
569
1
+ Addedlunar-typescript@^1.6.13
+ Addedlunar-typescript@1.7.5(transitive)