@unicom-cloud/utils 0.1.15 → 0.1.17
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/class-name/index.js +5 -5
- package/constant/index.js +24 -2
- package/constant/platform.js +13 -12
- package/constant.js +24 -2
- package/content-disposition/index.js +3 -3
- package/date/convertTime.js +4 -4
- package/event-emitter/index.js +2 -4
- package/filesize/types/constants.d.ts +81 -0
- package/filesize/types/filesize.d.ts +97 -0
- package/index.js +66 -60
- package/js-cookie/index.d.ts +116 -0
- package/js-cookie/index.js +4 -0
- package/js-cookie/src/api.js +56 -0
- package/js-cookie/src/assign.js +11 -0
- package/js-cookie/src/converter.js +14 -0
- package/jsCookie.js +4 -0
- package/lunar/lib/Holiday.js +2 -6
- package/lunar/lib/HolidayUtil.js +113 -100
- package/lunar/lib/I18n.js +395 -975
- package/lunar/lib/JieQi.js +12 -16
- package/lunar/lib/Lunar.js +224 -672
- package/lunar/lib/LunarMonth.js +35 -98
- package/lunar/lib/LunarTime.js +24 -103
- package/lunar/lib/LunarUtil.js +426 -1728
- package/lunar/lib/LunarYear.js +473 -566
- package/lunar/lib/ShouXingUtil.js +6714 -6690
- package/lunar/lib/Solar.js +24 -49
- package/lunar/lib/SolarHalfYear.js +0 -2
- package/lunar/lib/SolarMonth.js +4 -6
- package/lunar/lib/SolarSeason.js +0 -2
- package/lunar/lib/SolarUtil.js +238 -226
- package/lunar/lib/SolarWeek.js +7 -11
- package/lunar/lib/SolarYear.js +0 -1
- package/nzh/nzh.d.ts +74 -0
- package/package.json +1 -1
- package/query-string/base.d.ts +717 -0
- package/query-string/base.js +268 -0
- package/query-string/index.d.ts +16 -0
- package/query-string/index.js +4 -0
- package/query-string/splitOnFirst.js +14 -0
- package/queryString.js +4 -0
- package/random/index.js +56 -35
- package/snapdom/src/api/preCache.js +51 -28
- package/snapdom/src/core/cache.js +1 -4
- package/snapdom/src/core/capture.js +45 -44
- package/snapdom/src/core/clone.js +82 -66
- package/snapdom/src/core/prepare.js +168 -46
- package/snapdom/src/modules/background.js +29 -19
- package/snapdom/src/modules/fonts.js +146 -91
- package/snapdom/src/modules/images.js +14 -9
- package/snapdom/src/modules/pseudo.js +55 -58
- package/snapdom/src/modules/styles.js +22 -22
- package/snapdom/src/modules/svgDefs.js +39 -20
- package/snapdom/src/utils/cssTools.js +58 -51
- package/snapdom/src/utils/helpers.js +197 -140
- package/snapdom/types/snapdom.d.ts +101 -0
- package/tinycolor/src/conversion.js +1 -1
- package/tinycolor/src/index.js +2 -19
- package/turbo-stream/src/encode.js +5 -8
- package/turbo-stream/src/shared.js +117 -119
- package/types/constant/index.d.ts +11 -0
- package/types/constant/platform.d.ts +1 -0
- package/types/index.d.ts +3 -0
- package/types/js-cookie/index.d.ts +1 -0
- package/types/js-cookie/src/api.d.mts +2 -0
- package/types/js-cookie/src/assign.d.mts +1 -0
- package/types/js-cookie/src/converter.d.mts +5 -0
- package/types/lunar/lib/Lunar.d.ts +0 -98
- package/types/lunar/lib/LunarMonth.d.ts +0 -12
- package/types/lunar/lib/LunarTime.d.ts +0 -22
- package/types/lunar/lib/LunarUtil.d.ts +0 -90
- package/types/lunar/lib/LunarYear.d.ts +0 -30
- package/types/lunar/lib/Solar.d.ts +0 -5
- package/types/query-string/base.d.ts +11 -0
- package/types/query-string/index.d.ts +2 -0
- package/types/query-string/splitOnFirst.d.ts +1 -0
- package/types/random/index.d.ts +14 -23
- package/types/snapdom/src/api/preCache.d.ts +2 -5
- package/types/snapdom/src/core/cache.d.ts +0 -3
- package/types/snapdom/src/core/clone.d.ts +1 -1
- package/types/snapdom/src/modules/background.d.ts +16 -6
- package/types/snapdom/src/modules/fonts.d.ts +5 -1
- package/types/snapdom/src/modules/pseudo.d.ts +1 -1
- package/types/snapdom/src/modules/styles.d.ts +1 -1
- package/types/snapdom/src/modules/svgDefs.d.ts +13 -13
- package/types/snapdom/src/utils/cssTools.d.ts +2 -10
- package/types/snapdom/src/utils/helpers.d.ts +13 -7
- package/types/tinycolor/src/conversion.d.ts +1 -1
- package/types/turbo-stream/src/shared.d.ts +3 -3
- package/url-toolkit/src/url-toolkit.d.ts +22 -0
package/lunar/lib/Solar.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { HolidayUtil as
|
|
2
|
-
import { Lunar as
|
|
1
|
+
import { HolidayUtil as L } from "./HolidayUtil.js";
|
|
2
|
+
import { Lunar as H } from "./Lunar.js";
|
|
3
3
|
import { LunarUtil as u } from "./LunarUtil.js";
|
|
4
|
-
import { SolarMonth as
|
|
4
|
+
import { SolarMonth as k } from "./SolarMonth.js";
|
|
5
5
|
import { SolarUtil as o } from "./SolarUtil.js";
|
|
6
6
|
import { SolarWeek as W } from "./SolarWeek.js";
|
|
7
7
|
class a {
|
|
8
|
-
static
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
_day;
|
|
12
|
-
_hour;
|
|
13
|
-
_minute;
|
|
14
|
-
_second;
|
|
8
|
+
static {
|
|
9
|
+
this.J2000 = 2451545;
|
|
10
|
+
}
|
|
15
11
|
static fromYmd(t, e, i) {
|
|
16
12
|
return a.fromYmdHms(t, e, i, 0, 0, 0);
|
|
17
13
|
}
|
|
@@ -41,8 +37,8 @@ class a {
|
|
|
41
37
|
i -= h, i *= 60;
|
|
42
38
|
let f = Math.floor(i);
|
|
43
39
|
i -= f, i *= 60;
|
|
44
|
-
let
|
|
45
|
-
return
|
|
40
|
+
let l = Math.round(i);
|
|
41
|
+
return l > 59 && (l -= 60, f++), f > 59 && (f -= 60, h++), h > 23 && (h -= 24, m += 1), a.fromYmdHms(n, s, m, h, f, l);
|
|
46
42
|
}
|
|
47
43
|
static fromBaZi(t, e, i, r, n = 2, s = 1900) {
|
|
48
44
|
n = n == 1 ? 1 : 2;
|
|
@@ -52,21 +48,21 @@ class a {
|
|
|
52
48
|
return m;
|
|
53
49
|
let f = u.getJiaZiIndex(t) - 57;
|
|
54
50
|
f < 0 && (f += 60), f++, h *= 2;
|
|
55
|
-
const
|
|
56
|
-
let
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
for (; f <=
|
|
60
|
-
if (f >=
|
|
61
|
-
const
|
|
62
|
-
let g =
|
|
51
|
+
const l = u.index(r.substring(1), u.ZHI, -1) * 2;
|
|
52
|
+
let d = [l];
|
|
53
|
+
l == 0 && n == 2 && (d = [0, 23]);
|
|
54
|
+
const x = s - 1, E = (/* @__PURE__ */ new Date()).getFullYear();
|
|
55
|
+
for (; f <= E; ) {
|
|
56
|
+
if (f >= x) {
|
|
57
|
+
const y = H.fromYmd(f, 1, 1), I = y.getJieQiList();
|
|
58
|
+
let g = y.getJieQiTable()[I[4 + h]];
|
|
63
59
|
if (g.getYear() >= s) {
|
|
64
|
-
let
|
|
60
|
+
let _ = u.getJiaZiIndex(i) - u.getJiaZiIndex(
|
|
65
61
|
g.getLunar().getDayInGanZhiExact2()
|
|
66
62
|
);
|
|
67
|
-
|
|
63
|
+
_ < 0 && (_ += 60), _ > 0 && (g = g.next(_)), d.forEach((M) => {
|
|
68
64
|
let Y = 0, w = 0;
|
|
69
|
-
|
|
65
|
+
_ == 0 && M === g.getHour() && (Y = g.getMinute(), w = g.getSecond());
|
|
70
66
|
const D = a.fromYmdHms(
|
|
71
67
|
g.getYear(),
|
|
72
68
|
g.getMonth(),
|
|
@@ -74,8 +70,8 @@ class a {
|
|
|
74
70
|
M,
|
|
75
71
|
Y,
|
|
76
72
|
w
|
|
77
|
-
),
|
|
78
|
-
|
|
73
|
+
), c = D.getLunar(), p = n === 2 ? c.getDayInGanZhiExact2() : c.getDayInGanZhiExact();
|
|
74
|
+
c.getYearInGanZhiExact() === t && c.getMonthInGanZhiExact() === e && p === i && c.getTimeInGanZhi() === r && m.push(D);
|
|
79
75
|
});
|
|
80
76
|
}
|
|
81
77
|
}
|
|
@@ -149,27 +145,6 @@ class a {
|
|
|
149
145
|
const e = this._month * 100 + this._day;
|
|
150
146
|
return e >= 321 && e <= 419 ? t = 0 : e >= 420 && e <= 520 ? t = 1 : e >= 521 && e <= 621 ? t = 2 : e >= 622 && e <= 722 ? t = 3 : e >= 723 && e <= 822 ? t = 4 : e >= 823 && e <= 922 ? t = 5 : e >= 923 && e <= 1023 ? t = 6 : e >= 1024 && e <= 1122 ? t = 7 : e >= 1123 && e <= 1221 ? t = 8 : e >= 1222 || e <= 119 ? t = 9 : e <= 218 && (t = 10), o.XINGZUO[t];
|
|
151
147
|
}
|
|
152
|
-
/**
|
|
153
|
-
* 获取薪资比例(感谢 https://gitee.com/smr1987)
|
|
154
|
-
* @returns 1 | 2 | 3 薪资比例
|
|
155
|
-
*/
|
|
156
|
-
getSalaryRate() {
|
|
157
|
-
if (this._month === 1 && this._day === 1 || this._month === 5 && this._day === 1 || this._month === 10 && this._day >= 1 && this._day <= 3)
|
|
158
|
-
return 3;
|
|
159
|
-
const t = this.getLunar();
|
|
160
|
-
if (t.getMonth() === 1 && t.getDay() >= 1 && t.getDay() <= 3 || t.getMonth() === 5 && t.getDay() === 5 || t.getMonth() === 8 && t.getDay() === 15 || t.getJieQi() === "清明")
|
|
161
|
-
return 3;
|
|
162
|
-
const e = H.getHoliday(this._year, this._month, this._day);
|
|
163
|
-
if (e) {
|
|
164
|
-
if (!e.isWork())
|
|
165
|
-
return 2;
|
|
166
|
-
} else {
|
|
167
|
-
const i = this.getWeek();
|
|
168
|
-
if (i === 6 || i === 0)
|
|
169
|
-
return 2;
|
|
170
|
-
}
|
|
171
|
-
return 1;
|
|
172
|
-
}
|
|
173
148
|
toYmd() {
|
|
174
149
|
let t = this._year + "";
|
|
175
150
|
for (; t.length < 4; )
|
|
@@ -202,7 +177,7 @@ class a {
|
|
|
202
177
|
return e === 1582 && i === 10 ? r > 4 && r < 15 && (r += 10) : i === 2 && r > 28 && (o.isLeapYear(e) || (r = 28)), a.fromYmdHms(e, i, r, this._hour, this._minute, this._second);
|
|
203
178
|
}
|
|
204
179
|
nextMonth(t) {
|
|
205
|
-
const e =
|
|
180
|
+
const e = k.fromYm(this._year, this._month).next(t), i = e.getYear(), r = e.getMonth();
|
|
206
181
|
let n = this._day;
|
|
207
182
|
if (i === 1582 && r === 10)
|
|
208
183
|
n > 4 && n < 15 && (n += 10);
|
|
@@ -242,7 +217,7 @@ class a {
|
|
|
242
217
|
for (; r > 0; ) {
|
|
243
218
|
i = i.next(n);
|
|
244
219
|
let s = !0;
|
|
245
|
-
const m =
|
|
220
|
+
const m = L.getHoliday(
|
|
246
221
|
i.getYear(),
|
|
247
222
|
i.getMonth(),
|
|
248
223
|
i.getDay()
|
|
@@ -275,7 +250,7 @@ class a {
|
|
|
275
250
|
);
|
|
276
251
|
}
|
|
277
252
|
getLunar() {
|
|
278
|
-
return
|
|
253
|
+
return H.fromSolar(this);
|
|
279
254
|
}
|
|
280
255
|
getJulianDay() {
|
|
281
256
|
let t = this._year, e = this._month;
|
package/lunar/lib/SolarMonth.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Solar as h } from "./Solar.js";
|
|
2
|
-
import { SolarUtil as
|
|
3
|
-
import { SolarWeek as
|
|
2
|
+
import { SolarUtil as i } from "./SolarUtil.js";
|
|
3
|
+
import { SolarWeek as n } from "./SolarWeek.js";
|
|
4
4
|
class o {
|
|
5
|
-
_year;
|
|
6
|
-
_month;
|
|
7
5
|
static fromYm(t, r) {
|
|
8
6
|
return new o(t, r);
|
|
9
7
|
}
|
|
@@ -27,14 +25,14 @@ class o {
|
|
|
27
25
|
getDays() {
|
|
28
26
|
const t = [], r = h.fromYmd(this._year, this._month, 1);
|
|
29
27
|
t.push(r);
|
|
30
|
-
const e =
|
|
28
|
+
const e = i.getDaysOfMonth(this._year, this._month);
|
|
31
29
|
for (let s = 1; s < e; s++)
|
|
32
30
|
t.push(r.next(s));
|
|
33
31
|
return t;
|
|
34
32
|
}
|
|
35
33
|
getWeeks(t) {
|
|
36
34
|
const r = [];
|
|
37
|
-
let e =
|
|
35
|
+
let e = n.fromYmd(this._year, this._month, 1, t);
|
|
38
36
|
for (; ; ) {
|
|
39
37
|
r.push(e), e = e.next(1, !1);
|
|
40
38
|
const s = e.getFirstDay();
|