@unicom-cloud/utils 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/date/index.js +22 -0
- package/date.js +9 -0
- package/filesize/src/constants.js +22 -22
- package/filesize/src/filesize.js +32 -33
- package/index.js +56 -54
- package/lunar/index.js +36 -0
- package/lunar/lib/Holiday.js +42 -0
- package/lunar/lib/HolidayUtil.js +128 -0
- package/lunar/lib/I18n.js +1005 -0
- package/lunar/lib/JieQi.js +40 -0
- package/lunar/lib/Lunar.js +1035 -0
- package/lunar/lib/LunarMonth.js +150 -0
- package/lunar/lib/LunarTime.js +138 -0
- package/lunar/lib/LunarUtil.js +1752 -0
- package/lunar/lib/LunarYear.js +616 -0
- package/lunar/lib/ShouXingUtil.js +6915 -0
- package/lunar/lib/Solar.js +311 -0
- package/lunar/lib/SolarHalfYear.js +45 -0
- package/lunar/lib/SolarMonth.js +55 -0
- package/lunar/lib/SolarSeason.js +42 -0
- package/lunar/lib/SolarUtil.js +256 -0
- package/lunar/lib/SolarWeek.js +153 -0
- package/lunar/lib/SolarYear.js +35 -0
- package/lunar/lib/index.js +35 -0
- package/lunar.js +36 -0
- package/package.json +1 -1
- package/snapdom/src/api/preCache.js +27 -37
- package/snapdom/src/api/snapdom.js +75 -58
- package/snapdom/src/core/cache.js +19 -8
- package/snapdom/src/core/capture.js +49 -48
- package/snapdom/src/core/clone.js +96 -31
- package/snapdom/src/core/prepare.js +43 -37
- package/snapdom/src/modules/background.js +29 -20
- package/snapdom/src/modules/fonts.js +94 -104
- package/snapdom/src/modules/iconFonts.js +28 -0
- package/snapdom/src/modules/images.js +6 -6
- package/snapdom/src/modules/pseudo.js +52 -50
- package/snapdom/src/modules/styles.js +26 -6
- package/snapdom/src/modules/svgDefs.js +26 -0
- package/snapdom/src/utils/cssTools.js +41 -41
- package/snapdom/src/utils/helpers.js +128 -84
- package/tinycolor/index.js +46 -0
- package/tinycolor/src/conversion.js +143 -0
- package/tinycolor/src/css-color-names.js +153 -0
- package/tinycolor/src/format-input.js +77 -0
- package/tinycolor/src/from-ratio.js +21 -0
- package/tinycolor/src/index.js +404 -0
- package/tinycolor/src/random.js +221 -0
- package/tinycolor/src/readability.js +37 -0
- package/tinycolor/src/to-ms-filter.js +15 -0
- package/tinycolor/src/util.js +32 -0
- package/tinycolor.js +46 -0
- package/tree/index.js +10 -8
- package/tree/search/index.js +90 -0
- package/tree.js +9 -7
- package/types/date/index.d.ts +4 -0
- package/types/filesize/src/constants.d.ts +12 -12
- package/types/filesize/src/filesize.d.ts +63 -22
- package/types/index.d.ts +4 -3
- package/types/lunar/index.d.ts +3 -0
- package/types/lunar/lib/Holiday.d.ts +17 -0
- package/types/lunar/lib/HolidayUtil.d.ts +23 -0
- package/types/lunar/lib/I18n.d.ts +23 -0
- package/types/lunar/lib/JieQi.d.ts +15 -0
- package/types/lunar/lib/Lunar.d.ts +245 -0
- package/types/lunar/lib/LunarMonth.d.ts +35 -0
- package/types/lunar/lib/LunarTime.d.ts +40 -0
- package/types/lunar/lib/LunarUtil.d.ts +128 -0
- package/types/lunar/lib/LunarYear.d.ts +61 -0
- package/types/lunar/lib/ShouXingUtil.d.ts +38 -0
- package/types/lunar/lib/Solar.d.ts +51 -0
- package/types/lunar/lib/SolarHalfYear.d.ts +15 -0
- package/types/lunar/lib/SolarMonth.d.ts +16 -0
- package/types/lunar/lib/SolarSeason.d.ts +15 -0
- package/types/lunar/lib/SolarUtil.d.ts +20 -0
- package/types/lunar/lib/SolarWeek.d.ts +23 -0
- package/types/lunar/lib/SolarYear.d.ts +12 -0
- package/types/lunar/lib/index.d.ts +17 -0
- package/types/snapdom/src/core/cache.d.ts +17 -11
- package/types/snapdom/src/core/capture.d.ts +4 -0
- package/types/snapdom/src/core/clone.d.ts +4 -5
- package/types/snapdom/src/core/prepare.d.ts +8 -1
- package/types/snapdom/src/modules/background.d.ts +1 -2
- package/types/snapdom/src/modules/fonts.d.ts +1 -3
- package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
- package/types/snapdom/src/modules/pseudo.d.ts +1 -3
- package/types/snapdom/src/modules/styles.d.ts +1 -10
- package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
- package/types/snapdom/src/utils/cssTools.d.ts +1 -2
- package/types/snapdom/src/utils/helpers.d.ts +1 -1
- package/types/tinycolor/index.d.ts +2 -0
- package/types/tinycolor/src/conversion.d.ts +79 -0
- package/types/tinycolor/src/css-color-names.d.ts +4 -0
- package/types/tinycolor/src/format-input.d.ts +38 -0
- package/types/tinycolor/src/from-ratio.d.ts +14 -0
- package/types/tinycolor/src/index.d.ts +214 -0
- package/types/tinycolor/src/interfaces.d.ts +57 -0
- package/types/tinycolor/src/public_api.d.ts +10 -0
- package/types/tinycolor/src/random.d.ts +24 -0
- package/types/tinycolor/src/readability.d.ts +46 -0
- package/types/tinycolor/src/to-ms-filter.d.ts +5 -0
- package/types/tinycolor/src/umd_api.d.ts +22 -0
- package/types/tinycolor/src/util.d.ts +36 -0
- package/types/tree/index.d.ts +1 -0
- package/types/tree/search/index.d.ts +80 -0
- package/types/ui-color/compareColorByRange.d.ts +2 -0
- package/types/ui-color/index.d.ts +208 -0
- package/ui-color/compareColorByRange.js +9 -0
- package/ui-color/index.js +162 -0
- package/uiColor.js +29 -0
- package/convertTime.js +0 -4
- package/dayjs/index.js +0 -15
- package/dayjs.js +0 -5
- package/lunar-converter/index.js +0 -641
- package/lunarConverter.js +0 -4
- package/search-tree/index.js +0 -54
- package/searchTree.js +0 -4
- package/types/dayjs/index.d.ts +0 -1
- package/types/lunar-converter/index.d.ts +0 -113
- package/types/search-tree/index.d.ts +0 -20
- /package/{convert-time/index.js → date/convertTime.js} +0 -0
- /package/types/{convert-time/index.d.ts → date/convertTime.d.ts} +0 -0
package/lunar-converter/index.js
DELETED
|
@@ -1,641 +0,0 @@
|
|
|
1
|
-
class f {
|
|
2
|
-
static MIN = 1900;
|
|
3
|
-
static MAX = 2100;
|
|
4
|
-
// 1900-2100年的完整农历数据表(每个16进制数对应一年的数据)
|
|
5
|
-
static LUNAR_INFO = [
|
|
6
|
-
19416,
|
|
7
|
-
19168,
|
|
8
|
-
42352,
|
|
9
|
-
21717,
|
|
10
|
-
53856,
|
|
11
|
-
55632,
|
|
12
|
-
91476,
|
|
13
|
-
22176,
|
|
14
|
-
39632,
|
|
15
|
-
21970,
|
|
16
|
-
// 1900-1909
|
|
17
|
-
19168,
|
|
18
|
-
42422,
|
|
19
|
-
42192,
|
|
20
|
-
53840,
|
|
21
|
-
119381,
|
|
22
|
-
46400,
|
|
23
|
-
54944,
|
|
24
|
-
44450,
|
|
25
|
-
38320,
|
|
26
|
-
84343,
|
|
27
|
-
// 1910-1919
|
|
28
|
-
18800,
|
|
29
|
-
42160,
|
|
30
|
-
46261,
|
|
31
|
-
27216,
|
|
32
|
-
27968,
|
|
33
|
-
109396,
|
|
34
|
-
11104,
|
|
35
|
-
38256,
|
|
36
|
-
21234,
|
|
37
|
-
18800,
|
|
38
|
-
// 1920-1929
|
|
39
|
-
25958,
|
|
40
|
-
54432,
|
|
41
|
-
59984,
|
|
42
|
-
28309,
|
|
43
|
-
23248,
|
|
44
|
-
11104,
|
|
45
|
-
100067,
|
|
46
|
-
37600,
|
|
47
|
-
116951,
|
|
48
|
-
51536,
|
|
49
|
-
// 1930-1939
|
|
50
|
-
54432,
|
|
51
|
-
120998,
|
|
52
|
-
46416,
|
|
53
|
-
22176,
|
|
54
|
-
107956,
|
|
55
|
-
9680,
|
|
56
|
-
37584,
|
|
57
|
-
53938,
|
|
58
|
-
43344,
|
|
59
|
-
46423,
|
|
60
|
-
// 1940-1949
|
|
61
|
-
27808,
|
|
62
|
-
46416,
|
|
63
|
-
86869,
|
|
64
|
-
19872,
|
|
65
|
-
42416,
|
|
66
|
-
83315,
|
|
67
|
-
21168,
|
|
68
|
-
43432,
|
|
69
|
-
59728,
|
|
70
|
-
27296,
|
|
71
|
-
// 1950-1959
|
|
72
|
-
44710,
|
|
73
|
-
43856,
|
|
74
|
-
19296,
|
|
75
|
-
43748,
|
|
76
|
-
42352,
|
|
77
|
-
21088,
|
|
78
|
-
62051,
|
|
79
|
-
55632,
|
|
80
|
-
23383,
|
|
81
|
-
22176,
|
|
82
|
-
// 1960-1969
|
|
83
|
-
38608,
|
|
84
|
-
19925,
|
|
85
|
-
19152,
|
|
86
|
-
42192,
|
|
87
|
-
54484,
|
|
88
|
-
53840,
|
|
89
|
-
54616,
|
|
90
|
-
46400,
|
|
91
|
-
46752,
|
|
92
|
-
103846,
|
|
93
|
-
// 1970-1979
|
|
94
|
-
38320,
|
|
95
|
-
18864,
|
|
96
|
-
43380,
|
|
97
|
-
42160,
|
|
98
|
-
45690,
|
|
99
|
-
27216,
|
|
100
|
-
27968,
|
|
101
|
-
44870,
|
|
102
|
-
43872,
|
|
103
|
-
38256,
|
|
104
|
-
// 1980-1989
|
|
105
|
-
19189,
|
|
106
|
-
18800,
|
|
107
|
-
25776,
|
|
108
|
-
29859,
|
|
109
|
-
59984,
|
|
110
|
-
27480,
|
|
111
|
-
21952,
|
|
112
|
-
43872,
|
|
113
|
-
38613,
|
|
114
|
-
37600,
|
|
115
|
-
// 1990-1999
|
|
116
|
-
51552,
|
|
117
|
-
55636,
|
|
118
|
-
54432,
|
|
119
|
-
55888,
|
|
120
|
-
30034,
|
|
121
|
-
22176,
|
|
122
|
-
43959,
|
|
123
|
-
9680,
|
|
124
|
-
37584,
|
|
125
|
-
51893,
|
|
126
|
-
// 2000-2009
|
|
127
|
-
43344,
|
|
128
|
-
46240,
|
|
129
|
-
47780,
|
|
130
|
-
44368,
|
|
131
|
-
21977,
|
|
132
|
-
19360,
|
|
133
|
-
42416,
|
|
134
|
-
86390,
|
|
135
|
-
21168,
|
|
136
|
-
43312,
|
|
137
|
-
// 2010-2019
|
|
138
|
-
31060,
|
|
139
|
-
27296,
|
|
140
|
-
44368,
|
|
141
|
-
23378,
|
|
142
|
-
19296,
|
|
143
|
-
42726,
|
|
144
|
-
42208,
|
|
145
|
-
53856,
|
|
146
|
-
60005,
|
|
147
|
-
54576,
|
|
148
|
-
// 2020-2029
|
|
149
|
-
23200,
|
|
150
|
-
30371,
|
|
151
|
-
38608,
|
|
152
|
-
19415,
|
|
153
|
-
19152,
|
|
154
|
-
42192,
|
|
155
|
-
118966,
|
|
156
|
-
53840,
|
|
157
|
-
54560,
|
|
158
|
-
56645,
|
|
159
|
-
// 2030-2039
|
|
160
|
-
46496,
|
|
161
|
-
22224,
|
|
162
|
-
21938,
|
|
163
|
-
18864,
|
|
164
|
-
42359,
|
|
165
|
-
42160,
|
|
166
|
-
43600,
|
|
167
|
-
111189,
|
|
168
|
-
27936,
|
|
169
|
-
44448,
|
|
170
|
-
// 2040-2049
|
|
171
|
-
84835,
|
|
172
|
-
37744,
|
|
173
|
-
18936,
|
|
174
|
-
18800,
|
|
175
|
-
25776,
|
|
176
|
-
92326,
|
|
177
|
-
59984,
|
|
178
|
-
27424,
|
|
179
|
-
108228,
|
|
180
|
-
43744,
|
|
181
|
-
// 2050-2059
|
|
182
|
-
37600,
|
|
183
|
-
53987,
|
|
184
|
-
51552,
|
|
185
|
-
54615,
|
|
186
|
-
54432,
|
|
187
|
-
55888,
|
|
188
|
-
23893,
|
|
189
|
-
22176,
|
|
190
|
-
42704,
|
|
191
|
-
21972,
|
|
192
|
-
// 2060-2069
|
|
193
|
-
21200,
|
|
194
|
-
43448,
|
|
195
|
-
43344,
|
|
196
|
-
46240,
|
|
197
|
-
46758,
|
|
198
|
-
44368,
|
|
199
|
-
21920,
|
|
200
|
-
43940,
|
|
201
|
-
42416,
|
|
202
|
-
21168,
|
|
203
|
-
// 2070-2079
|
|
204
|
-
45683,
|
|
205
|
-
26928,
|
|
206
|
-
29495,
|
|
207
|
-
27296,
|
|
208
|
-
44368,
|
|
209
|
-
84821,
|
|
210
|
-
19296,
|
|
211
|
-
42352,
|
|
212
|
-
21732,
|
|
213
|
-
53600,
|
|
214
|
-
// 2080-2089
|
|
215
|
-
59752,
|
|
216
|
-
54560,
|
|
217
|
-
55968,
|
|
218
|
-
92838,
|
|
219
|
-
22224,
|
|
220
|
-
19168,
|
|
221
|
-
43476,
|
|
222
|
-
41680,
|
|
223
|
-
53584,
|
|
224
|
-
62034,
|
|
225
|
-
// 2090-2099
|
|
226
|
-
54560
|
|
227
|
-
// 2100
|
|
228
|
-
];
|
|
229
|
-
// 24节气名称
|
|
230
|
-
static SOLAR_TERMS = [
|
|
231
|
-
"小寒",
|
|
232
|
-
"大寒",
|
|
233
|
-
"立春",
|
|
234
|
-
"雨水",
|
|
235
|
-
"惊蛰",
|
|
236
|
-
"春分",
|
|
237
|
-
"清明",
|
|
238
|
-
"谷雨",
|
|
239
|
-
"立夏",
|
|
240
|
-
"小满",
|
|
241
|
-
"芒种",
|
|
242
|
-
"夏至",
|
|
243
|
-
"小暑",
|
|
244
|
-
"大暑",
|
|
245
|
-
"立秋",
|
|
246
|
-
"处暑",
|
|
247
|
-
"白露",
|
|
248
|
-
"秋分",
|
|
249
|
-
"寒露",
|
|
250
|
-
"霜降",
|
|
251
|
-
"立冬",
|
|
252
|
-
"小雪",
|
|
253
|
-
"大雪",
|
|
254
|
-
"冬至"
|
|
255
|
-
];
|
|
256
|
-
// 中国传统节日(农历)
|
|
257
|
-
static LUNAR_HOLIDAYS = {
|
|
258
|
-
"1-1": "春节",
|
|
259
|
-
"1-15": "元宵节",
|
|
260
|
-
"5-5": "端午节",
|
|
261
|
-
"7-7": "七夕节",
|
|
262
|
-
"7-15": "中元节",
|
|
263
|
-
"8-15": "中秋节",
|
|
264
|
-
"9-9": "重阳节",
|
|
265
|
-
"12-8": "腊八节",
|
|
266
|
-
"12-23": "小年",
|
|
267
|
-
"12-30": "除夕"
|
|
268
|
-
};
|
|
269
|
-
// 公历节日
|
|
270
|
-
static SOLAR_HOLIDAYS = {
|
|
271
|
-
"1-1": "元旦",
|
|
272
|
-
"2-14": "情人节",
|
|
273
|
-
"3-8": "妇女节",
|
|
274
|
-
"3-12": "植树节",
|
|
275
|
-
"4-5": "清明节",
|
|
276
|
-
"5-1": "劳动节",
|
|
277
|
-
"5-4": "青年节",
|
|
278
|
-
"6-1": "儿童节",
|
|
279
|
-
"7-1": "建党节",
|
|
280
|
-
"8-1": "建军节",
|
|
281
|
-
"9-10": "教师节",
|
|
282
|
-
"10-1": "国庆节",
|
|
283
|
-
"12-25": "圣诞节"
|
|
284
|
-
};
|
|
285
|
-
// 特殊节日(需要计算的)
|
|
286
|
-
static SPECIAL_HOLIDAYS = {
|
|
287
|
-
母亲节: (t) => ({ month: 5, day: this.findNthWeekdayInMonth(t, 5, 0, 2) }),
|
|
288
|
-
父亲节: (t) => ({ month: 6, day: this.findNthWeekdayInMonth(t, 6, 0, 3) }),
|
|
289
|
-
感恩节: (t) => ({ month: 11, day: this.findNthWeekdayInMonth(t, 11, 4, 4) })
|
|
290
|
-
};
|
|
291
|
-
/**
|
|
292
|
-
* 查找某月中第N个星期X的日期
|
|
293
|
-
* @param year 年份
|
|
294
|
-
* @param month 月份(1-12)
|
|
295
|
-
* @param weekday 星期几(0-6,0表示周日)
|
|
296
|
-
* @param nth 第几个(1-5)
|
|
297
|
-
* @returns 日期
|
|
298
|
-
*/
|
|
299
|
-
static findNthWeekdayInMonth(t, s, a, o) {
|
|
300
|
-
const e = new Date(t, s - 1, 1);
|
|
301
|
-
let r = 0;
|
|
302
|
-
for (; e.getDay() !== a; )
|
|
303
|
-
e.setDate(e.getDate() + 1);
|
|
304
|
-
for (; r < o - 1; ) {
|
|
305
|
-
if (e.setDate(e.getDate() + 7), e.getMonth() !== s - 1)
|
|
306
|
-
return -1;
|
|
307
|
-
r++;
|
|
308
|
-
}
|
|
309
|
-
return e.getDate();
|
|
310
|
-
}
|
|
311
|
-
// 天干
|
|
312
|
-
static GAN = [
|
|
313
|
-
"甲",
|
|
314
|
-
"乙",
|
|
315
|
-
"丙",
|
|
316
|
-
"丁",
|
|
317
|
-
"戊",
|
|
318
|
-
"己",
|
|
319
|
-
"庚",
|
|
320
|
-
"辛",
|
|
321
|
-
"壬",
|
|
322
|
-
"癸"
|
|
323
|
-
];
|
|
324
|
-
// 地支
|
|
325
|
-
static ZHI = [
|
|
326
|
-
"子",
|
|
327
|
-
"丑",
|
|
328
|
-
"寅",
|
|
329
|
-
"卯",
|
|
330
|
-
"辰",
|
|
331
|
-
"巳",
|
|
332
|
-
"午",
|
|
333
|
-
"未",
|
|
334
|
-
"申",
|
|
335
|
-
"酉",
|
|
336
|
-
"戌",
|
|
337
|
-
"亥"
|
|
338
|
-
];
|
|
339
|
-
// 生肖
|
|
340
|
-
static ZODIAC = [
|
|
341
|
-
"鼠",
|
|
342
|
-
"牛",
|
|
343
|
-
"虎",
|
|
344
|
-
"兔",
|
|
345
|
-
"龙",
|
|
346
|
-
"蛇",
|
|
347
|
-
"马",
|
|
348
|
-
"羊",
|
|
349
|
-
"猴",
|
|
350
|
-
"鸡",
|
|
351
|
-
"狗",
|
|
352
|
-
"猪"
|
|
353
|
-
];
|
|
354
|
-
// 中文数字
|
|
355
|
-
static CHINESE_NUMBERS = [
|
|
356
|
-
"零",
|
|
357
|
-
"一",
|
|
358
|
-
"二",
|
|
359
|
-
"三",
|
|
360
|
-
"四",
|
|
361
|
-
"五",
|
|
362
|
-
"六",
|
|
363
|
-
"七",
|
|
364
|
-
"八",
|
|
365
|
-
"九",
|
|
366
|
-
"十"
|
|
367
|
-
];
|
|
368
|
-
// 农历日中文表示
|
|
369
|
-
static CHINESE_DAY_NAMES = [
|
|
370
|
-
"初一",
|
|
371
|
-
"初二",
|
|
372
|
-
"初三",
|
|
373
|
-
"初四",
|
|
374
|
-
"初五",
|
|
375
|
-
"初六",
|
|
376
|
-
"初七",
|
|
377
|
-
"初八",
|
|
378
|
-
"初九",
|
|
379
|
-
"初十",
|
|
380
|
-
"十一",
|
|
381
|
-
"十二",
|
|
382
|
-
"十三",
|
|
383
|
-
"十四",
|
|
384
|
-
"十五",
|
|
385
|
-
"十六",
|
|
386
|
-
"十七",
|
|
387
|
-
"十八",
|
|
388
|
-
"十九",
|
|
389
|
-
"二十",
|
|
390
|
-
"廿一",
|
|
391
|
-
"廿二",
|
|
392
|
-
"廿三",
|
|
393
|
-
"廿四",
|
|
394
|
-
"廿五",
|
|
395
|
-
"廿六",
|
|
396
|
-
"廿七",
|
|
397
|
-
"廿八",
|
|
398
|
-
"廿九",
|
|
399
|
-
"三十"
|
|
400
|
-
];
|
|
401
|
-
// 农历月中文表示
|
|
402
|
-
static CHINESE_MONTH_NAMES = [
|
|
403
|
-
"正月",
|
|
404
|
-
"二月",
|
|
405
|
-
"三月",
|
|
406
|
-
"四月",
|
|
407
|
-
"五月",
|
|
408
|
-
"六月",
|
|
409
|
-
"七月",
|
|
410
|
-
"八月",
|
|
411
|
-
"九月",
|
|
412
|
-
"十月",
|
|
413
|
-
"十一月",
|
|
414
|
-
"腊月"
|
|
415
|
-
];
|
|
416
|
-
// 自定义节日存储
|
|
417
|
-
static customSolarHolidays = {};
|
|
418
|
-
static customLunarHolidays = {};
|
|
419
|
-
/**
|
|
420
|
-
* 添加自定义公历节日
|
|
421
|
-
* @param month 月份(1-12)
|
|
422
|
-
* @param day 日期
|
|
423
|
-
* @param name 节日名称
|
|
424
|
-
*/
|
|
425
|
-
static addCustomSolarHoliday(t, s, a) {
|
|
426
|
-
const o = `${t}-${s}`;
|
|
427
|
-
this.customSolarHolidays[o] = a;
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* 添加自定义农历节日
|
|
431
|
-
* @param month 月份(1-12)
|
|
432
|
-
* @param day 日期
|
|
433
|
-
* @param name 节日名称
|
|
434
|
-
*/
|
|
435
|
-
static addCustomLunarHoliday(t, s, a) {
|
|
436
|
-
const o = `${t}-${s}`;
|
|
437
|
-
this.customLunarHolidays[o] = a;
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* 移除自定义公历节日
|
|
441
|
-
* @param month 月份(1-12)
|
|
442
|
-
* @param day 日期
|
|
443
|
-
*/
|
|
444
|
-
static removeCustomSolarHoliday(t, s) {
|
|
445
|
-
const a = `${t}-${s}`;
|
|
446
|
-
delete this.customSolarHolidays[a];
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* 移除自定义农历节日
|
|
450
|
-
* @param month 月份(1-12)
|
|
451
|
-
* @param day 日期
|
|
452
|
-
*/
|
|
453
|
-
static removeCustomLunarHoliday(t, s) {
|
|
454
|
-
const a = `${t}-${s}`;
|
|
455
|
-
delete this.customLunarHolidays[a];
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* 公历转农历(主方法)
|
|
459
|
-
* @param year 公历年份
|
|
460
|
-
* @param month 公历月份(1-12)
|
|
461
|
-
* @param day 公历日期(1-31)
|
|
462
|
-
* @returns 农历日期对象
|
|
463
|
-
*/
|
|
464
|
-
static solarToLunar(t, s, a) {
|
|
465
|
-
if (t < f.MIN || t > f.MAX)
|
|
466
|
-
throw new Error("农历转换仅支持1900-2700年之间的日期");
|
|
467
|
-
const o = new Date(t, s - 1, a), e = new Date(f.MIN, 0, 31), r = Math.floor(
|
|
468
|
-
(o.getTime() - e.getTime()) / 864e5
|
|
469
|
-
);
|
|
470
|
-
let h = f.MIN, I = this.getLunarYearDays(h), l = 0;
|
|
471
|
-
for (; r >= l + I && h < f.MAX; )
|
|
472
|
-
l += I, h++, I = this.getLunarYearDays(h);
|
|
473
|
-
const c = this.getLunarMonthInfo(h);
|
|
474
|
-
let u = r - l, i = 1, n = !1;
|
|
475
|
-
for (const [N, M] of c) {
|
|
476
|
-
if (u < N) {
|
|
477
|
-
M && (n = !0);
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
u -= N, M || i++;
|
|
481
|
-
}
|
|
482
|
-
const d = u + 1, S = this.dayToChinese(d), A = this.monthToChinese(i, n), y = this.getSolarTerm(t, s, a), D = this.getFestivals(
|
|
483
|
-
t,
|
|
484
|
-
s,
|
|
485
|
-
a,
|
|
486
|
-
h,
|
|
487
|
-
i,
|
|
488
|
-
d,
|
|
489
|
-
n,
|
|
490
|
-
y
|
|
491
|
-
);
|
|
492
|
-
return {
|
|
493
|
-
year: h,
|
|
494
|
-
month: i,
|
|
495
|
-
day: d,
|
|
496
|
-
chineseMonth: A,
|
|
497
|
-
chineseDay: S,
|
|
498
|
-
isLeapMonth: n,
|
|
499
|
-
zodiac: this.getZodiac(h),
|
|
500
|
-
ganZhiYear: this.getGanZhi(h),
|
|
501
|
-
solarTerm: y,
|
|
502
|
-
festivals: D
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* 获取所有节日(农历、公历和自定义节日)
|
|
507
|
-
*/
|
|
508
|
-
static getFestivals(t, s, a, o, e, r, h, I) {
|
|
509
|
-
const l = [], c = /* @__PURE__ */ new Set(), u = `${s}-${a}`;
|
|
510
|
-
if (this.SOLAR_HOLIDAYS[u]) {
|
|
511
|
-
const i = this.SOLAR_HOLIDAYS[u];
|
|
512
|
-
c.has(i) || (l.push(i), c.add(i));
|
|
513
|
-
}
|
|
514
|
-
if (this.customSolarHolidays[u]) {
|
|
515
|
-
const i = this.customSolarHolidays[u];
|
|
516
|
-
c.has(i) || (l.push(i), c.add(i));
|
|
517
|
-
}
|
|
518
|
-
if (!h) {
|
|
519
|
-
const i = `${e}-${r}`;
|
|
520
|
-
if (this.LUNAR_HOLIDAYS[i]) {
|
|
521
|
-
const n = this.LUNAR_HOLIDAYS[i];
|
|
522
|
-
c.has(n) || (l.push(n), c.add(n));
|
|
523
|
-
}
|
|
524
|
-
if (this.customLunarHolidays[i]) {
|
|
525
|
-
const n = this.customLunarHolidays[i];
|
|
526
|
-
c.has(n) || (l.push(n), c.add(n));
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
if (I === "清明") {
|
|
530
|
-
const i = "清明节";
|
|
531
|
-
c.has(i) || (l.push(i), c.add(i));
|
|
532
|
-
}
|
|
533
|
-
if (e === 12) {
|
|
534
|
-
const i = this.getLunarMonthDays(o, 12);
|
|
535
|
-
if (r === i) {
|
|
536
|
-
const n = "除夕";
|
|
537
|
-
c.has(n) || (l.push(n), c.add(n));
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
for (const [i, n] of Object.entries(this.SPECIAL_HOLIDAYS)) {
|
|
541
|
-
const d = n(t);
|
|
542
|
-
s === d.month && a === d.day && (c.has(i) || (l.push(i), c.add(i)));
|
|
543
|
-
}
|
|
544
|
-
return l;
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* 获取农历年的总天数
|
|
548
|
-
*/
|
|
549
|
-
static getLunarYearDays(t) {
|
|
550
|
-
const s = this.LUNAR_INFO[t - f.MIN];
|
|
551
|
-
let a = 0;
|
|
552
|
-
for (let e = 32768; e > 8; e >>= 1)
|
|
553
|
-
a += s & e ? 30 : 29;
|
|
554
|
-
return this.getLeapMonth(t) > 0 && (a += s & 65536 ? 30 : 29), a;
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* 获取农历每月的天数信息
|
|
558
|
-
*/
|
|
559
|
-
static getLunarMonthInfo(t) {
|
|
560
|
-
const s = this.LUNAR_INFO[t - f.MIN], a = this.getLeapMonth(t), o = [];
|
|
561
|
-
for (let e = 1; e <= 12; e++) {
|
|
562
|
-
const r = s & 32768 >> e - 1 ? 30 : 29;
|
|
563
|
-
if (o.push([r, !1]), e === a) {
|
|
564
|
-
const h = s & 65536 ? 30 : 29;
|
|
565
|
-
o.push([h, !0]);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
return o;
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* 获取闰月月份(没有闰月返回0)
|
|
572
|
-
*/
|
|
573
|
-
static getLeapMonth(t) {
|
|
574
|
-
return this.LUNAR_INFO[t - f.MIN] & 15;
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* 获取节气
|
|
578
|
-
*/
|
|
579
|
-
static getSolarTerm(t, s, a) {
|
|
580
|
-
const o = [
|
|
581
|
-
[6, "小寒"],
|
|
582
|
-
[20, "大寒"],
|
|
583
|
-
[4, "立春"],
|
|
584
|
-
[19, "雨水"],
|
|
585
|
-
[6, "惊蛰"],
|
|
586
|
-
[21, "春分"],
|
|
587
|
-
[5, "清明"],
|
|
588
|
-
[20, "谷雨"],
|
|
589
|
-
[6, "立夏"],
|
|
590
|
-
[21, "小满"],
|
|
591
|
-
[6, "芒种"],
|
|
592
|
-
[21, "夏至"],
|
|
593
|
-
[7, "小暑"],
|
|
594
|
-
[23, "大暑"],
|
|
595
|
-
[7, "立秋"],
|
|
596
|
-
[23, "处暑"],
|
|
597
|
-
[8, "白露"],
|
|
598
|
-
[23, "秋分"],
|
|
599
|
-
[8, "寒露"],
|
|
600
|
-
[24, "霜降"],
|
|
601
|
-
[7, "立冬"],
|
|
602
|
-
[22, "小雪"],
|
|
603
|
-
[7, "大雪"],
|
|
604
|
-
[22, "冬至"]
|
|
605
|
-
], e = (s - 1) * 2 + (a > 15 ? 1 : 0);
|
|
606
|
-
return e >= 0 && e < o.length && a === o[e][0] ? o[e][1] : null;
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* 获取农历月份的天数
|
|
610
|
-
*/
|
|
611
|
-
static getLunarMonthDays(t, s) {
|
|
612
|
-
return this.LUNAR_INFO[t - f.MIN] & 32768 >> s - 1 ? 30 : 29;
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* 数字日期转中文
|
|
616
|
-
*/
|
|
617
|
-
static dayToChinese(t) {
|
|
618
|
-
return t < 1 || t > 30 ? "未知" : this.CHINESE_DAY_NAMES[t - 1];
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* 数字月份转中文(处理闰月)
|
|
622
|
-
*/
|
|
623
|
-
static monthToChinese(t, s) {
|
|
624
|
-
return t < 1 || t > 12 ? "未知" : (s ? "闰" : "") + this.CHINESE_MONTH_NAMES[t - 1];
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* 获取生肖
|
|
628
|
-
*/
|
|
629
|
-
static getZodiac(t) {
|
|
630
|
-
return this.ZODIAC[(t - 4) % 12];
|
|
631
|
-
}
|
|
632
|
-
/**
|
|
633
|
-
* 获取天干地支
|
|
634
|
-
*/
|
|
635
|
-
static getGanZhi(t) {
|
|
636
|
-
return this.GAN[(t - 4) % 10] + this.ZHI[(t - 4) % 12];
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
export {
|
|
640
|
-
f as default
|
|
641
|
-
};
|
package/lunarConverter.js
DELETED
package/search-tree/index.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
function p(o, i, a = {}) {
|
|
2
|
-
const {
|
|
3
|
-
strategy: f = "BFS",
|
|
4
|
-
childrenKey: c = "children",
|
|
5
|
-
strict: u = !1
|
|
6
|
-
} = a;
|
|
7
|
-
if (!Array.isArray(o))
|
|
8
|
-
throw new TypeError("treeData must be an array");
|
|
9
|
-
if (typeof i != "object" || i === null)
|
|
10
|
-
throw new TypeError("searchCondition must be an object");
|
|
11
|
-
const t = [...o], l = (e) => {
|
|
12
|
-
for (const r in i) {
|
|
13
|
-
if (!Object.prototype.hasOwnProperty.call(e, r))
|
|
14
|
-
return !1;
|
|
15
|
-
const n = i[r], s = e[r];
|
|
16
|
-
if (u) {
|
|
17
|
-
if (s !== n)
|
|
18
|
-
return !1;
|
|
19
|
-
} else if (n instanceof RegExp) {
|
|
20
|
-
if (typeof s != "string" || !n.test(s))
|
|
21
|
-
return !1;
|
|
22
|
-
} else if (typeof n == "function") {
|
|
23
|
-
if (!n(s))
|
|
24
|
-
return !1;
|
|
25
|
-
} else if (s != n)
|
|
26
|
-
return !1;
|
|
27
|
-
}
|
|
28
|
-
return !0;
|
|
29
|
-
};
|
|
30
|
-
if (f === "BFS")
|
|
31
|
-
for (; t.length > 0; ) {
|
|
32
|
-
const e = t.shift();
|
|
33
|
-
if (!e) continue;
|
|
34
|
-
if (l(e))
|
|
35
|
-
return e;
|
|
36
|
-
const r = e[c];
|
|
37
|
-
Array.isArray(r) && t.push(...r);
|
|
38
|
-
}
|
|
39
|
-
else if (f === "DFS")
|
|
40
|
-
for (; t.length > 0; ) {
|
|
41
|
-
const e = t.pop();
|
|
42
|
-
if (!e) continue;
|
|
43
|
-
if (l(e))
|
|
44
|
-
return e;
|
|
45
|
-
const r = e[c];
|
|
46
|
-
Array.isArray(r) && t.push(...r.slice().reverse());
|
|
47
|
-
}
|
|
48
|
-
else
|
|
49
|
-
throw new Error('Invalid strategy. Use "BFS" or "DFS"');
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
p as default
|
|
54
|
-
};
|
package/searchTree.js
DELETED
package/types/dayjs/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function convertToDurationBasedOnTimeUnits(duration: any, unit: any): string;
|