@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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { LunarUtil as e } from "./LunarUtil.js";
|
|
2
|
+
import { LunarYear as _ } from "./LunarYear.js";
|
|
3
|
+
import { Solar as O } from "./Solar.js";
|
|
4
|
+
class m {
|
|
5
|
+
_year;
|
|
6
|
+
_month;
|
|
7
|
+
_dayCount;
|
|
8
|
+
_firstJulianDay;
|
|
9
|
+
_index;
|
|
10
|
+
_zhiIndex;
|
|
11
|
+
static fromYm(t, i) {
|
|
12
|
+
return _.fromYear(t).getMonth(i);
|
|
13
|
+
}
|
|
14
|
+
constructor(t, i, s, h, o) {
|
|
15
|
+
this._year = t, this._month = i, this._dayCount = s, this._firstJulianDay = h, this._index = o, this._zhiIndex = (o - 1 + e.BASE_MONTH_ZHI_INDEX) % 12;
|
|
16
|
+
}
|
|
17
|
+
getYear() {
|
|
18
|
+
return this._year;
|
|
19
|
+
}
|
|
20
|
+
getMonth() {
|
|
21
|
+
return this._month;
|
|
22
|
+
}
|
|
23
|
+
getIndex() {
|
|
24
|
+
return this._index;
|
|
25
|
+
}
|
|
26
|
+
getGanIndex() {
|
|
27
|
+
const t = (_.fromYear(this._year).getGanIndex() + 1) % 5 * 2;
|
|
28
|
+
return (this._index - 1 + t) % 10;
|
|
29
|
+
}
|
|
30
|
+
getZhiIndex() {
|
|
31
|
+
return this._zhiIndex;
|
|
32
|
+
}
|
|
33
|
+
getGan() {
|
|
34
|
+
return e.GAN[this.getGanIndex() + 1];
|
|
35
|
+
}
|
|
36
|
+
getZhi() {
|
|
37
|
+
return e.ZHI[this._zhiIndex + 1];
|
|
38
|
+
}
|
|
39
|
+
getGanZhi() {
|
|
40
|
+
return this.getGan() + this.getZhi();
|
|
41
|
+
}
|
|
42
|
+
isLeap() {
|
|
43
|
+
return this._month < 0;
|
|
44
|
+
}
|
|
45
|
+
getDayCount() {
|
|
46
|
+
return this._dayCount;
|
|
47
|
+
}
|
|
48
|
+
getFirstJulianDay() {
|
|
49
|
+
return this._firstJulianDay;
|
|
50
|
+
}
|
|
51
|
+
getPositionXi() {
|
|
52
|
+
return e.POSITION_XI[this.getGanIndex() + 1];
|
|
53
|
+
}
|
|
54
|
+
getPositionXiDesc() {
|
|
55
|
+
return e.POSITION_DESC[this.getPositionXi()];
|
|
56
|
+
}
|
|
57
|
+
getPositionYangGui() {
|
|
58
|
+
return e.POSITION_YANG_GUI[this.getGanIndex() + 1];
|
|
59
|
+
}
|
|
60
|
+
getPositionYangGuiDesc() {
|
|
61
|
+
return e.POSITION_DESC[this.getPositionYangGui()];
|
|
62
|
+
}
|
|
63
|
+
getPositionYinGui() {
|
|
64
|
+
return e.POSITION_YIN_GUI[this.getGanIndex() + 1];
|
|
65
|
+
}
|
|
66
|
+
getPositionYinGuiDesc() {
|
|
67
|
+
return e.POSITION_DESC[this.getPositionYinGui()];
|
|
68
|
+
}
|
|
69
|
+
getPositionFu(t = 2) {
|
|
70
|
+
return (t == 1 ? e.POSITION_FU : e.POSITION_FU_2)[this.getGanIndex() + 1];
|
|
71
|
+
}
|
|
72
|
+
getPositionFuDesc(t = 2) {
|
|
73
|
+
return e.POSITION_DESC[this.getPositionFu(t)];
|
|
74
|
+
}
|
|
75
|
+
getPositionCai() {
|
|
76
|
+
return e.POSITION_CAI[this.getGanIndex() + 1];
|
|
77
|
+
}
|
|
78
|
+
getPositionCaiDesc() {
|
|
79
|
+
return e.POSITION_DESC[this.getPositionCai()];
|
|
80
|
+
}
|
|
81
|
+
getPositionTaiSui() {
|
|
82
|
+
let t;
|
|
83
|
+
switch (Math.abs(this._month)) {
|
|
84
|
+
case 1:
|
|
85
|
+
case 5:
|
|
86
|
+
case 9:
|
|
87
|
+
t = "艮";
|
|
88
|
+
break;
|
|
89
|
+
case 3:
|
|
90
|
+
case 7:
|
|
91
|
+
case 11:
|
|
92
|
+
t = "坤";
|
|
93
|
+
break;
|
|
94
|
+
case 4:
|
|
95
|
+
case 8:
|
|
96
|
+
case 12:
|
|
97
|
+
t = "巽";
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
t = e.POSITION_GAN[O.fromJulianDay(this.getFirstJulianDay()).getLunar().getMonthGanIndex()];
|
|
101
|
+
}
|
|
102
|
+
return t;
|
|
103
|
+
}
|
|
104
|
+
getPositionTaiSuiDesc() {
|
|
105
|
+
return e.POSITION_DESC[this.getPositionTaiSui()];
|
|
106
|
+
}
|
|
107
|
+
toString() {
|
|
108
|
+
return `${this.getYear()}年${this.isLeap() ? "闰" : ""}${e.MONTH[Math.abs(this.getMonth())]}月(${this.getDayCount()})天`;
|
|
109
|
+
}
|
|
110
|
+
next(t) {
|
|
111
|
+
if (t == 0)
|
|
112
|
+
return m.fromYm(this._year, this._month);
|
|
113
|
+
{
|
|
114
|
+
let i = Math.abs(t), s = this._year, h = s, o = this._month, a = 0, n = _.fromYear(s).getMonths(), r, g, u;
|
|
115
|
+
if (t > 0) {
|
|
116
|
+
for (; ; ) {
|
|
117
|
+
for (u = n.length, r = 0; r < u; r++)
|
|
118
|
+
if (g = n[r], g.getYear() === h && g.getMonth() === o) {
|
|
119
|
+
a = r;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
const I = u - a - 1;
|
|
123
|
+
if (i < I)
|
|
124
|
+
break;
|
|
125
|
+
i -= I;
|
|
126
|
+
const P = n[u - 1];
|
|
127
|
+
h = P.getYear(), o = P.getMonth(), s++, n = _.fromYear(s).getMonths();
|
|
128
|
+
}
|
|
129
|
+
return n[a + i];
|
|
130
|
+
} else {
|
|
131
|
+
for (; ; ) {
|
|
132
|
+
for (u = n.length, r = 0; r < u; r++)
|
|
133
|
+
if (g = n[r], g.getYear() === h && g.getMonth() === o) {
|
|
134
|
+
a = r;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
if (i <= a)
|
|
138
|
+
break;
|
|
139
|
+
i -= a;
|
|
140
|
+
const I = n[0];
|
|
141
|
+
h = I.getYear(), o = I.getMonth(), s--, n = _.fromYear(s).getMonths();
|
|
142
|
+
}
|
|
143
|
+
return n[a - i];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
m as LunarMonth
|
|
150
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Lunar as a } from "./Lunar.js";
|
|
2
|
+
import { LunarUtil as t } from "./LunarUtil.js";
|
|
3
|
+
class s {
|
|
4
|
+
_ganIndex;
|
|
5
|
+
_zhiIndex;
|
|
6
|
+
_lunar;
|
|
7
|
+
static fromYmdHms(n, e, i, r, g, h) {
|
|
8
|
+
return new s(n, e, i, r, g, h);
|
|
9
|
+
}
|
|
10
|
+
constructor(n, e, i, r, g, h) {
|
|
11
|
+
this._lunar = a.fromYmdHms(
|
|
12
|
+
n,
|
|
13
|
+
e,
|
|
14
|
+
i,
|
|
15
|
+
r,
|
|
16
|
+
g,
|
|
17
|
+
h
|
|
18
|
+
), this._zhiIndex = t.getTimeZhiIndex(
|
|
19
|
+
[(r < 10 ? "0" : "") + r, (g < 10 ? "0" : "") + g].join(
|
|
20
|
+
":"
|
|
21
|
+
)
|
|
22
|
+
), this._ganIndex = (this._lunar.getDayGanIndexExact() % 5 * 2 + this._zhiIndex) % 10;
|
|
23
|
+
}
|
|
24
|
+
getGanIndex() {
|
|
25
|
+
return this._ganIndex;
|
|
26
|
+
}
|
|
27
|
+
getZhiIndex() {
|
|
28
|
+
return this._zhiIndex;
|
|
29
|
+
}
|
|
30
|
+
getGan() {
|
|
31
|
+
return t.GAN[this._ganIndex + 1];
|
|
32
|
+
}
|
|
33
|
+
getZhi() {
|
|
34
|
+
return t.ZHI[this._zhiIndex + 1];
|
|
35
|
+
}
|
|
36
|
+
getGanZhi() {
|
|
37
|
+
return this.getGan() + this.getZhi();
|
|
38
|
+
}
|
|
39
|
+
getShengXiao() {
|
|
40
|
+
return t.SHENGXIAO[this._zhiIndex + 1];
|
|
41
|
+
}
|
|
42
|
+
getPositionXi() {
|
|
43
|
+
return t.POSITION_XI[this._ganIndex + 1];
|
|
44
|
+
}
|
|
45
|
+
getPositionXiDesc() {
|
|
46
|
+
return t.POSITION_DESC[this.getPositionXi()];
|
|
47
|
+
}
|
|
48
|
+
getPositionYangGui() {
|
|
49
|
+
return t.POSITION_YANG_GUI[this._ganIndex + 1];
|
|
50
|
+
}
|
|
51
|
+
getPositionYangGuiDesc() {
|
|
52
|
+
return t.POSITION_DESC[this.getPositionYangGui()];
|
|
53
|
+
}
|
|
54
|
+
getPositionYinGui() {
|
|
55
|
+
return t.POSITION_YIN_GUI[this._ganIndex + 1];
|
|
56
|
+
}
|
|
57
|
+
getPositionYinGuiDesc() {
|
|
58
|
+
return t.POSITION_DESC[this.getPositionYinGui()];
|
|
59
|
+
}
|
|
60
|
+
getPositionFu(n = 2) {
|
|
61
|
+
return (n === 1 ? t.POSITION_FU : t.POSITION_FU_2)[this._ganIndex + 1];
|
|
62
|
+
}
|
|
63
|
+
getPositionFuDesc(n = 2) {
|
|
64
|
+
return t.POSITION_DESC[this.getPositionFu(n)];
|
|
65
|
+
}
|
|
66
|
+
getPositionCai() {
|
|
67
|
+
return t.POSITION_CAI[this._ganIndex + 1];
|
|
68
|
+
}
|
|
69
|
+
getPositionCaiDesc() {
|
|
70
|
+
return t.POSITION_DESC[this.getPositionCai()];
|
|
71
|
+
}
|
|
72
|
+
getNaYin() {
|
|
73
|
+
return t.NAYIN[this.getGanZhi()];
|
|
74
|
+
}
|
|
75
|
+
getTianShen() {
|
|
76
|
+
return t.TIAN_SHEN[(this._zhiIndex + t.ZHI_TIAN_SHEN_OFFSET[this._lunar.getDayZhiExact()]) % 12 + 1];
|
|
77
|
+
}
|
|
78
|
+
getTianShenType() {
|
|
79
|
+
return t.TIAN_SHEN_TYPE[this.getTianShen()];
|
|
80
|
+
}
|
|
81
|
+
getTianShenLuck() {
|
|
82
|
+
return t.TIAN_SHEN_TYPE_LUCK[this.getTianShenType()];
|
|
83
|
+
}
|
|
84
|
+
getChong() {
|
|
85
|
+
return t.CHONG[this._zhiIndex];
|
|
86
|
+
}
|
|
87
|
+
getSha() {
|
|
88
|
+
return t.SHA[this.getZhi()];
|
|
89
|
+
}
|
|
90
|
+
getChongShengXiao() {
|
|
91
|
+
const n = this.getChong();
|
|
92
|
+
for (let e = 0, i = t.ZHI.length; e < i; e++)
|
|
93
|
+
if (t.ZHI[e] === n)
|
|
94
|
+
return t.SHENGXIAO[e];
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
getChongDesc() {
|
|
98
|
+
return "(" + this.getChongGan() + this.getChong() + ")" + this.getChongShengXiao();
|
|
99
|
+
}
|
|
100
|
+
getChongGan() {
|
|
101
|
+
return t.CHONG_GAN[this._ganIndex];
|
|
102
|
+
}
|
|
103
|
+
getChongGanTie() {
|
|
104
|
+
return t.CHONG_GAN_TIE[this._ganIndex];
|
|
105
|
+
}
|
|
106
|
+
getYi() {
|
|
107
|
+
return t.getTimeYi(
|
|
108
|
+
this._lunar.getDayInGanZhiExact(),
|
|
109
|
+
this.getGanZhi()
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
getJi() {
|
|
113
|
+
return t.getTimeJi(
|
|
114
|
+
this._lunar.getDayInGanZhiExact(),
|
|
115
|
+
this.getGanZhi()
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
getXun() {
|
|
119
|
+
return t.getXun(this.getGanZhi());
|
|
120
|
+
}
|
|
121
|
+
getXunKong() {
|
|
122
|
+
return t.getXunKong(this.getGanZhi());
|
|
123
|
+
}
|
|
124
|
+
getMinHm() {
|
|
125
|
+
let n = this._lunar.getHour();
|
|
126
|
+
return n < 1 ? "00:00" : n > 22 ? "23:00" : (n % 2 === 0 && (n -= 1), (n < 10 ? "0" : "") + n + ":00");
|
|
127
|
+
}
|
|
128
|
+
getMaxHm() {
|
|
129
|
+
let n = this._lunar.getHour();
|
|
130
|
+
return n < 1 ? "00:59" : n > 22 ? "23:59" : (n % 2 !== 0 && (n += 1), (n < 10 ? "0" : "") + n + ":59");
|
|
131
|
+
}
|
|
132
|
+
toString() {
|
|
133
|
+
return this.getGanZhi();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
s as LunarTime
|
|
138
|
+
};
|