@unicom-cloud/utils 0.1.10 → 0.1.12
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/caseName.js +11 -0
- package/className.js +5 -0
- package/clipboardCopy.js +6 -0
- package/constant.js +4 -0
- package/contentDisposition.js +7 -0
- package/cookie.js +7 -0
- package/date/convertTime.js +61 -0
- package/date/index.js +22 -0
- package/date.js +9 -0
- package/decimal.js +5 -0
- package/eventEmitter.js +4 -0
- package/file.js +6 -0
- package/filesize.js +8 -0
- package/index.js +56 -46
- package/invariant.js +4 -0
- package/is.js +92 -0
- 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/math.js +9 -0
- package/md5.js +4 -0
- package/mock.js +8 -0
- package/normalizeWheel.js +6 -0
- package/number-to-chinese/index.js +72 -0
- package/numberToChinese.js +4 -0
- package/nzh.js +4 -0
- package/object-keys-sort/index.js +7 -0
- package/objectKeysSort.js +2 -5
- package/package.json +1 -1
- package/random.js +15 -0
- package/screenfull.js +4 -0
- package/snapdom/src/api/preCache.js +26 -36
- package/snapdom/src/api/snapdom.js +78 -61
- package/snapdom/src/core/capture.js +54 -54
- package/snapdom/src/core/prepare.js +46 -37
- package/snapdom/src/modules/fonts.js +90 -92
- package/snapdom/src/modules/iconFonts.js +28 -0
- package/snapdom/src/modules/images.js +6 -6
- package/snapdom/src/modules/pseudo.js +51 -49
- package/snapdom/src/modules/styles.js +27 -7
- package/snapdom/src/modules/svgDefs.js +26 -0
- package/snapdom/src/utils/helpers.js +150 -103
- package/snapdom.js +6 -0
- 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/searchTree.js +54 -0
- package/tree.js +13 -0
- package/turboStream.js +6 -0
- package/types/case-name/index.d.ts +11 -0
- package/types/class-name/index.d.ts +2 -0
- package/types/clipboard-copy/index.d.ts +2 -0
- package/types/constant/address.d.ts +14 -0
- package/types/constant/chineseCharacters.d.ts +2 -0
- package/types/constant/constellations.d.ts +2 -0
- package/types/constant/domain.d.ts +2 -0
- package/types/constant/identity.d.ts +2 -0
- package/types/constant/index.d.ts +1 -0
- package/types/constant/keyboardCode.d.ts +158 -0
- package/types/constant/licensePlate.d.ts +2 -0
- package/types/constant/name.d.ts +4 -0
- package/types/constant/platform.d.ts +11 -0
- package/types/constant/protocol.d.ts +2 -0
- package/types/constant/ui.d.ts +14 -0
- package/types/content-disposition/index.d.ts +10 -0
- package/types/cookie/index.d.ts +4 -0
- package/types/cookie/src/index.d.ts +114 -0
- package/types/date/convertTime.d.ts +32 -0
- package/types/date/index.d.ts +4 -0
- package/types/decimal/decimal.d.ts +4 -0
- package/types/decimal/index.d.ts +1 -0
- package/types/event-emitter/index.d.ts +17 -0
- package/types/file/fileToURL.d.ts +2 -0
- package/types/file/index.d.ts +3 -0
- package/types/file/saveAs.d.ts +2 -0
- package/types/filesize/index.d.ts +2 -0
- package/types/filesize/src/constants.d.ts +42 -0
- package/types/filesize/src/filesize.d.ts +47 -0
- package/types/index.d.ts +25 -0
- package/types/invariant/index.d.ts +2 -0
- package/types/is/index.d.ts +53 -0
- 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/math/index.d.ts +11 -0
- package/types/md5/index.d.ts +2 -0
- package/types/mock/MockWebSocket.d.ts +17 -0
- package/types/mock/MockXMLHttpRequest.d.ts +17 -0
- package/types/mock/index.d.ts +2 -0
- package/types/normalize-wheel/ExecutionEnvironment.d.ts +9 -0
- package/types/normalize-wheel/UserAgent_DEPRECATED.d.ts +86 -0
- package/types/normalize-wheel/index.d.ts +115 -0
- package/types/normalize-wheel/isEventSupported.d.ts +16 -0
- package/types/number-to-chinese/index.d.ts +11 -0
- package/types/nzh/cn.d.ts +8 -0
- package/types/nzh/hk.d.ts +8 -0
- package/types/nzh/index.d.ts +1 -0
- package/types/nzh/nzh.d.ts +36 -0
- package/types/nzh/src/autoGet.d.ts +8 -0
- package/types/nzh/src/index.d.ts +34 -0
- package/types/nzh/src/langs/cn_b.d.ts +10 -0
- package/types/nzh/src/langs/cn_s.d.ts +7 -0
- package/types/nzh/src/langs/hk_b.d.ts +10 -0
- package/types/nzh/src/langs/hk_s.d.ts +7 -0
- package/types/nzh/src/utils.d.ts +65 -0
- package/types/object-keys-sort/index.d.ts +4 -0
- package/types/random/address.d.ts +8 -0
- package/types/random/constellation.d.ts +2 -0
- package/types/random/image.d.ts +5 -0
- package/types/random/index.d.ts +40 -0
- package/types/random/licensePlate.d.ts +2 -0
- package/types/random/name.d.ts +9 -0
- package/types/random/number.d.ts +6 -0
- package/types/random/text.d.ts +13 -0
- package/types/random/time.d.ts +2 -0
- package/types/random/web.d.ts +11 -0
- package/types/screenfull/index.d.ts +10 -0
- package/types/snapdom/index.d.ts +1 -0
- package/types/snapdom/src/api/preCache.d.ts +8 -0
- package/types/snapdom/src/api/snapdom.d.ts +26 -0
- package/types/snapdom/src/core/cache.d.ts +11 -0
- package/types/snapdom/src/core/capture.d.ts +17 -0
- package/types/snapdom/src/core/clone.d.ts +11 -0
- package/types/snapdom/src/core/prepare.d.ts +8 -0
- package/types/snapdom/src/index.browser.d.ts +1 -0
- package/types/snapdom/src/index.d.ts +2 -0
- package/types/snapdom/src/modules/background.d.ts +10 -0
- package/types/snapdom/src/modules/fonts.d.ts +23 -0
- package/types/snapdom/src/modules/iconFonts.d.ts +2 -0
- package/types/snapdom/src/modules/images.d.ts +8 -0
- package/types/snapdom/src/modules/pseudo.d.ts +12 -0
- package/types/snapdom/src/modules/styles.d.ts +1 -0
- package/types/snapdom/src/modules/svgDefs.d.ts +19 -0
- package/types/snapdom/src/utils/cssTools.d.ts +38 -0
- package/types/snapdom/src/utils/helpers.d.ts +71 -0
- 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 +9 -0
- package/types/tree/searchTree.d.ts +20 -0
- package/types/turbo-stream/index.d.ts +1 -0
- package/types/turbo-stream/src/decode.d.ts +7 -0
- package/types/turbo-stream/src/encode.d.ts +27 -0
- package/types/turbo-stream/src/shared.d.ts +107 -0
- package/types/turbo-stream/src/turbo-stream.d.ts +4 -0
- package/types/ui-color/compareColorByRange.d.ts +2 -0
- package/types/ui-color/index.d.ts +183 -0
- package/types/url-toolkit/index.d.ts +2 -0
- package/types/url-toolkit/src/url-toolkit.d.ts +18 -0
- package/ui-color/compareColorByRange.js +9 -0
- package/ui-color/index.js +155 -0
- package/uiColor.js +28 -0
- package/urlToolkit.js +8 -0
- package/dayjs/index.js +0 -15
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { HolidayUtil as H } from "./HolidayUtil.js";
|
|
2
|
+
import { Lunar as x } from "./Lunar.js";
|
|
3
|
+
import { LunarUtil as u } from "./LunarUtil.js";
|
|
4
|
+
import { SolarMonth as p } from "./SolarMonth.js";
|
|
5
|
+
import { SolarUtil as o } from "./SolarUtil.js";
|
|
6
|
+
import { SolarWeek as W } from "./SolarWeek.js";
|
|
7
|
+
class a {
|
|
8
|
+
static J2000 = 2451545;
|
|
9
|
+
_year;
|
|
10
|
+
_month;
|
|
11
|
+
_day;
|
|
12
|
+
_hour;
|
|
13
|
+
_minute;
|
|
14
|
+
_second;
|
|
15
|
+
static fromYmd(t, e, i) {
|
|
16
|
+
return a.fromYmdHms(t, e, i, 0, 0, 0);
|
|
17
|
+
}
|
|
18
|
+
static fromYmdHms(t, e, i, r, n, s) {
|
|
19
|
+
return new a(t, e, i, r, n, s);
|
|
20
|
+
}
|
|
21
|
+
static fromDate(t) {
|
|
22
|
+
return a.fromYmdHms(
|
|
23
|
+
t.getFullYear(),
|
|
24
|
+
t.getMonth() + 1,
|
|
25
|
+
t.getDate(),
|
|
26
|
+
t.getHours(),
|
|
27
|
+
t.getMinutes(),
|
|
28
|
+
t.getSeconds()
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
static fromJulianDay(t) {
|
|
32
|
+
let e = Math.floor(t + 0.5), i = t + 0.5 - e, r;
|
|
33
|
+
e >= 2299161 && (r = Math.floor((e - 186721625e-2) / 36524.25), e += 1 + r - Math.floor(r / 4)), e += 1524;
|
|
34
|
+
let n = Math.floor((e - 122.1) / 365.25);
|
|
35
|
+
e -= Math.floor(365.25 * n);
|
|
36
|
+
let s = Math.floor(e / 30.601);
|
|
37
|
+
e -= Math.floor(30.601 * s);
|
|
38
|
+
let m = e;
|
|
39
|
+
s > 13 ? (s -= 13, n -= 4715) : (s -= 1, n -= 4716), i *= 24;
|
|
40
|
+
let h = Math.floor(i);
|
|
41
|
+
i -= h, i *= 60;
|
|
42
|
+
let f = Math.floor(i);
|
|
43
|
+
i -= f, i *= 60;
|
|
44
|
+
let _ = Math.round(i);
|
|
45
|
+
return _ > 59 && (_ -= 60, f++), f > 59 && (f -= 60, h++), h > 23 && (h -= 24, m += 1), a.fromYmdHms(n, s, m, h, f, _);
|
|
46
|
+
}
|
|
47
|
+
static fromBaZi(t, e, i, r, n = 2, s = 1900) {
|
|
48
|
+
n = n == 1 ? 1 : 2;
|
|
49
|
+
const m = [];
|
|
50
|
+
let h = u.index(e.substring(1), u.ZHI, -1) - 2;
|
|
51
|
+
if (h < 0 && (h += 12), ((u.index(t.substring(0, 1), u.GAN, -1) + 1) * 2 + h) % 10 !== u.index(e.substring(0, 1), u.GAN, -1))
|
|
52
|
+
return m;
|
|
53
|
+
let f = u.getJiaZiIndex(t) - 57;
|
|
54
|
+
f < 0 && (f += 60), f++, h *= 2;
|
|
55
|
+
const _ = u.index(r.substring(1), u.ZHI, -1) * 2;
|
|
56
|
+
let c = [_];
|
|
57
|
+
_ == 0 && n == 2 && (c = [0, 23]);
|
|
58
|
+
const E = s - 1, I = (/* @__PURE__ */ new Date()).getFullYear();
|
|
59
|
+
for (; f <= I; ) {
|
|
60
|
+
if (f >= E) {
|
|
61
|
+
const d = x.fromYmd(f, 1, 1), L = d.getJieQiList();
|
|
62
|
+
let g = d.getJieQiTable()[L[4 + h]];
|
|
63
|
+
if (g.getYear() >= s) {
|
|
64
|
+
let l = u.getJiaZiIndex(i) - u.getJiaZiIndex(
|
|
65
|
+
g.getLunar().getDayInGanZhiExact2()
|
|
66
|
+
);
|
|
67
|
+
l < 0 && (l += 60), l > 0 && (g = g.next(l)), c.forEach((M) => {
|
|
68
|
+
let Y = 0, w = 0;
|
|
69
|
+
l == 0 && M === g.getHour() && (Y = g.getMinute(), w = g.getSecond());
|
|
70
|
+
const D = a.fromYmdHms(
|
|
71
|
+
g.getYear(),
|
|
72
|
+
g.getMonth(),
|
|
73
|
+
g.getDay(),
|
|
74
|
+
M,
|
|
75
|
+
Y,
|
|
76
|
+
w
|
|
77
|
+
), y = D.getLunar(), k = n === 2 ? y.getDayInGanZhiExact2() : y.getDayInGanZhiExact();
|
|
78
|
+
y.getYearInGanZhiExact() === t && y.getMonthInGanZhiExact() === e && k === i && y.getTimeInGanZhi() === r && m.push(D);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
f += 60;
|
|
83
|
+
}
|
|
84
|
+
return m;
|
|
85
|
+
}
|
|
86
|
+
constructor(t, e, i, r, n, s) {
|
|
87
|
+
if (t === 1582 && e === 10 && i > 4 && i < 15)
|
|
88
|
+
throw new Error(`wrong solar year ${t} month ${e} day ${i}`);
|
|
89
|
+
if (e < 1 || e > 12)
|
|
90
|
+
throw new Error(`wrong month ${e}`);
|
|
91
|
+
if (i < 1 || i > 31)
|
|
92
|
+
throw new Error(`wrong day ${i}`);
|
|
93
|
+
if (r < 0 || r > 23)
|
|
94
|
+
throw new Error(`wrong hour ${r}`);
|
|
95
|
+
if (n < 0 || n > 59)
|
|
96
|
+
throw new Error(`wrong minute ${n}`);
|
|
97
|
+
if (s < 0 || s > 59)
|
|
98
|
+
throw new Error(`wrong second ${s}`);
|
|
99
|
+
this._year = t, this._month = e, this._day = i, this._hour = r, this._minute = n, this._second = s;
|
|
100
|
+
}
|
|
101
|
+
getYear() {
|
|
102
|
+
return this._year;
|
|
103
|
+
}
|
|
104
|
+
getMonth() {
|
|
105
|
+
return this._month;
|
|
106
|
+
}
|
|
107
|
+
getDay() {
|
|
108
|
+
return this._day;
|
|
109
|
+
}
|
|
110
|
+
getHour() {
|
|
111
|
+
return this._hour;
|
|
112
|
+
}
|
|
113
|
+
getMinute() {
|
|
114
|
+
return this._minute;
|
|
115
|
+
}
|
|
116
|
+
getSecond() {
|
|
117
|
+
return this._second;
|
|
118
|
+
}
|
|
119
|
+
getWeek() {
|
|
120
|
+
return (Math.floor(this.getJulianDay() + 0.5) + 7000001) % 7;
|
|
121
|
+
}
|
|
122
|
+
getWeekInChinese() {
|
|
123
|
+
return o.WEEK[this.getWeek()];
|
|
124
|
+
}
|
|
125
|
+
getSolarWeek(t) {
|
|
126
|
+
return W.fromYmd(this._year, this._month, this._day, t);
|
|
127
|
+
}
|
|
128
|
+
isLeapYear() {
|
|
129
|
+
return o.isLeapYear(this._year);
|
|
130
|
+
}
|
|
131
|
+
getFestivals() {
|
|
132
|
+
const t = [];
|
|
133
|
+
let e = o.FESTIVAL[this._month + "-" + this._day];
|
|
134
|
+
e && t.push(e);
|
|
135
|
+
const i = Math.ceil(this._day / 7), r = this.getWeek();
|
|
136
|
+
return e = o.WEEK_FESTIVAL[this._month + "-" + i + "-" + r], e && t.push(e), this._day + 7 > o.getDaysOfMonth(this._year, this._month) && (e = o.WEEK_FESTIVAL[this._month + "-0-" + r], e && t.push(e)), t;
|
|
137
|
+
}
|
|
138
|
+
getOtherFestivals() {
|
|
139
|
+
const t = [], e = o.OTHER_FESTIVAL[this._month + "-" + this._day];
|
|
140
|
+
return e && e.forEach((i) => {
|
|
141
|
+
t.push(i);
|
|
142
|
+
}), t;
|
|
143
|
+
}
|
|
144
|
+
getXingzuo() {
|
|
145
|
+
return this.getXingZuo();
|
|
146
|
+
}
|
|
147
|
+
getXingZuo() {
|
|
148
|
+
let t = 11;
|
|
149
|
+
const e = this._month * 100 + this._day;
|
|
150
|
+
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
|
+
}
|
|
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
|
+
toYmd() {
|
|
174
|
+
let t = this._year + "";
|
|
175
|
+
for (; t.length < 4; )
|
|
176
|
+
t = "0" + t;
|
|
177
|
+
return [
|
|
178
|
+
t,
|
|
179
|
+
(this._month < 10 ? "0" : "") + this._month,
|
|
180
|
+
(this._day < 10 ? "0" : "") + this._day
|
|
181
|
+
].join("-");
|
|
182
|
+
}
|
|
183
|
+
toYmdHms() {
|
|
184
|
+
return this.toYmd() + " " + [
|
|
185
|
+
(this._hour < 10 ? "0" : "") + this._hour,
|
|
186
|
+
(this._minute < 10 ? "0" : "") + this._minute,
|
|
187
|
+
(this._second < 10 ? "0" : "") + this._second
|
|
188
|
+
].join(":");
|
|
189
|
+
}
|
|
190
|
+
toString() {
|
|
191
|
+
return this.toYmd();
|
|
192
|
+
}
|
|
193
|
+
toFullString() {
|
|
194
|
+
let t = this.toYmdHms();
|
|
195
|
+
return this.isLeapYear() && (t += " 闰年"), t += " 星期" + this.getWeekInChinese(), this.getFestivals().forEach((i) => {
|
|
196
|
+
t += " (" + i + ")";
|
|
197
|
+
}), t += " " + this.getXingZuo() + "座", t;
|
|
198
|
+
}
|
|
199
|
+
nextYear(t) {
|
|
200
|
+
const e = this._year + t, i = this._month;
|
|
201
|
+
let r = this._day;
|
|
202
|
+
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
|
+
}
|
|
204
|
+
nextMonth(t) {
|
|
205
|
+
const e = p.fromYm(this._year, this._month).next(t), i = e.getYear(), r = e.getMonth();
|
|
206
|
+
let n = this._day;
|
|
207
|
+
if (i === 1582 && r === 10)
|
|
208
|
+
n > 4 && n < 15 && (n += 10);
|
|
209
|
+
else {
|
|
210
|
+
const s = o.getDaysOfMonth(i, r);
|
|
211
|
+
n > s && (n = s);
|
|
212
|
+
}
|
|
213
|
+
return a.fromYmdHms(i, r, n, this._hour, this._minute, this._second);
|
|
214
|
+
}
|
|
215
|
+
nextDay(t) {
|
|
216
|
+
let e = this._year, i = this._month, r = this._day;
|
|
217
|
+
if (e === 1582 && i === 10 && r > 4 && (r -= 10), t > 0) {
|
|
218
|
+
r += t;
|
|
219
|
+
let n = o.getDaysOfMonth(e, i);
|
|
220
|
+
for (; r > n; )
|
|
221
|
+
r -= n, i++, i > 12 && (i = 1, e++), n = o.getDaysOfMonth(e, i);
|
|
222
|
+
} else if (t < 0) {
|
|
223
|
+
for (; r + t <= 0; )
|
|
224
|
+
i--, i < 1 && (i = 12, e--), r += o.getDaysOfMonth(e, i);
|
|
225
|
+
r += t;
|
|
226
|
+
}
|
|
227
|
+
return e === 1582 && i === 10 && r > 4 && (r += 10), a.fromYmdHms(e, i, r, this._hour, this._minute, this._second);
|
|
228
|
+
}
|
|
229
|
+
next(t, e = !1) {
|
|
230
|
+
if (e) {
|
|
231
|
+
let i = a.fromYmdHms(
|
|
232
|
+
this._year,
|
|
233
|
+
this._month,
|
|
234
|
+
this._day,
|
|
235
|
+
this._hour,
|
|
236
|
+
this._minute,
|
|
237
|
+
this._second
|
|
238
|
+
);
|
|
239
|
+
if (t !== 0) {
|
|
240
|
+
let r = Math.abs(t);
|
|
241
|
+
const n = t < 1 ? -1 : 1;
|
|
242
|
+
for (; r > 0; ) {
|
|
243
|
+
i = i.next(n);
|
|
244
|
+
let s = !0;
|
|
245
|
+
const m = H.getHoliday(
|
|
246
|
+
i.getYear(),
|
|
247
|
+
i.getMonth(),
|
|
248
|
+
i.getDay()
|
|
249
|
+
);
|
|
250
|
+
if (m)
|
|
251
|
+
s = m.isWork();
|
|
252
|
+
else {
|
|
253
|
+
const h = i.getWeek();
|
|
254
|
+
(h === 0 || h === 6) && (s = !1);
|
|
255
|
+
}
|
|
256
|
+
s && (r -= 1);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return i;
|
|
260
|
+
} else
|
|
261
|
+
return this.nextDay(t);
|
|
262
|
+
}
|
|
263
|
+
nextHour(t) {
|
|
264
|
+
const e = this._hour + t, i = e < 0 ? -1 : 1;
|
|
265
|
+
let r = Math.abs(e), n = Math.floor(r / 24) * i;
|
|
266
|
+
r = r % 24 * i, r < 0 && (r += 24, n--);
|
|
267
|
+
const s = this.next(n);
|
|
268
|
+
return a.fromYmdHms(
|
|
269
|
+
s.getYear(),
|
|
270
|
+
s.getMonth(),
|
|
271
|
+
s.getDay(),
|
|
272
|
+
r,
|
|
273
|
+
s.getMinute(),
|
|
274
|
+
s.getSecond()
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
getLunar() {
|
|
278
|
+
return x.fromSolar(this);
|
|
279
|
+
}
|
|
280
|
+
getJulianDay() {
|
|
281
|
+
let t = this._year, e = this._month;
|
|
282
|
+
const i = this._day + ((this._second / 60 + this._minute) / 60 + this._hour) / 24;
|
|
283
|
+
let r = 0, n = !1;
|
|
284
|
+
return t * 372 + e * 31 + Math.floor(i) >= 588829 && (n = !0), e <= 2 && (e += 12, t--), n && (r = Math.floor(t / 100), r = 2 - r + Math.floor(r / 4)), Math.floor(365.25 * (t + 4716)) + Math.floor(30.6001 * (e + 1)) + i + r - 1524.5;
|
|
285
|
+
}
|
|
286
|
+
isBefore(t) {
|
|
287
|
+
return this._year > t.getYear() ? !1 : this._year < t.getYear() ? !0 : this._month > t.getMonth() ? !1 : this._month < t.getMonth() ? !0 : this._day > t.getDay() ? !1 : this._day < t.getDay() ? !0 : this._hour > t.getHour() ? !1 : this._hour < t.getHour() ? !0 : this._minute > t.getMinute() ? !1 : this._minute < t.getMinute() ? !0 : this._second < t.getSecond();
|
|
288
|
+
}
|
|
289
|
+
isAfter(t) {
|
|
290
|
+
return this._year > t.getYear() ? !0 : this._year < t.getYear() ? !1 : this._month > t.getMonth() ? !0 : this._month < t.getMonth() ? !1 : this._day > t.getDay() ? !0 : this._day < t.getDay() ? !1 : this._hour > t.getHour() ? !0 : this._hour < t.getHour() ? !1 : this._minute > t.getMinute() ? !0 : this._minute < t.getMinute() ? !1 : this._second > t.getSecond();
|
|
291
|
+
}
|
|
292
|
+
subtract(t) {
|
|
293
|
+
return o.getDaysBetween(
|
|
294
|
+
t.getYear(),
|
|
295
|
+
t.getMonth(),
|
|
296
|
+
t.getDay(),
|
|
297
|
+
this._year,
|
|
298
|
+
this._month,
|
|
299
|
+
this._day
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
subtractMinute(t) {
|
|
303
|
+
let e = this.subtract(t);
|
|
304
|
+
const i = this._hour * 60 + this._minute, r = t.getHour() * 60 + t.getMinute();
|
|
305
|
+
let n = i - r;
|
|
306
|
+
return n < 0 && (n += 1440, e--), n += e * 1440, n;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
export {
|
|
310
|
+
a as Solar
|
|
311
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SolarMonth as o } from "./SolarMonth.js";
|
|
2
|
+
class r {
|
|
3
|
+
_year;
|
|
4
|
+
_month;
|
|
5
|
+
static fromYm(t, e) {
|
|
6
|
+
return new r(t, e);
|
|
7
|
+
}
|
|
8
|
+
static fromDate(t) {
|
|
9
|
+
return r.fromYm(t.getFullYear(), t.getMonth() + 1);
|
|
10
|
+
}
|
|
11
|
+
constructor(t, e) {
|
|
12
|
+
this._year = t, this._month = e;
|
|
13
|
+
}
|
|
14
|
+
getYear() {
|
|
15
|
+
return this._year;
|
|
16
|
+
}
|
|
17
|
+
getMonth() {
|
|
18
|
+
return this._month;
|
|
19
|
+
}
|
|
20
|
+
getIndex() {
|
|
21
|
+
return Math.ceil(this._month / 6);
|
|
22
|
+
}
|
|
23
|
+
next(t) {
|
|
24
|
+
const e = o.fromYm(this._year, this._month).next(
|
|
25
|
+
6 * t
|
|
26
|
+
);
|
|
27
|
+
return r.fromYm(e.getYear(), e.getMonth());
|
|
28
|
+
}
|
|
29
|
+
getMonths() {
|
|
30
|
+
const t = [], e = this.getIndex() - 1;
|
|
31
|
+
for (let n = 0; n < 6; n++)
|
|
32
|
+
t.push(o.fromYm(this._year, 6 * e + n + 1));
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
toString() {
|
|
36
|
+
return `${this.getYear()}.${this.getIndex()}`;
|
|
37
|
+
}
|
|
38
|
+
toFullString() {
|
|
39
|
+
const t = ["上", "下"][this.getIndex() - 1];
|
|
40
|
+
return `${this.getYear()}年${t}半年`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
r as SolarHalfYear
|
|
45
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Solar as h } from "./Solar.js";
|
|
2
|
+
import { SolarUtil as n } from "./SolarUtil.js";
|
|
3
|
+
import { SolarWeek as i } from "./SolarWeek.js";
|
|
4
|
+
class o {
|
|
5
|
+
_year;
|
|
6
|
+
_month;
|
|
7
|
+
static fromYm(t, r) {
|
|
8
|
+
return new o(t, r);
|
|
9
|
+
}
|
|
10
|
+
static fromDate(t) {
|
|
11
|
+
return o.fromYm(t.getFullYear(), t.getMonth() + 1);
|
|
12
|
+
}
|
|
13
|
+
constructor(t, r) {
|
|
14
|
+
this._year = t, this._month = r;
|
|
15
|
+
}
|
|
16
|
+
getYear() {
|
|
17
|
+
return this._year;
|
|
18
|
+
}
|
|
19
|
+
getMonth() {
|
|
20
|
+
return this._month;
|
|
21
|
+
}
|
|
22
|
+
next(t) {
|
|
23
|
+
const r = t < 0 ? -1 : 1;
|
|
24
|
+
let e = Math.abs(t), s = this._year + Math.floor(e / 12) * r;
|
|
25
|
+
return e = this._month + e % 12 * r, e > 12 ? (e -= 12, s++) : e < 1 && (e += 12, s--), o.fromYm(s, e);
|
|
26
|
+
}
|
|
27
|
+
getDays() {
|
|
28
|
+
const t = [], r = h.fromYmd(this._year, this._month, 1);
|
|
29
|
+
t.push(r);
|
|
30
|
+
const e = n.getDaysOfMonth(this._year, this._month);
|
|
31
|
+
for (let s = 1; s < e; s++)
|
|
32
|
+
t.push(r.next(s));
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
getWeeks(t) {
|
|
36
|
+
const r = [];
|
|
37
|
+
let e = i.fromYmd(this._year, this._month, 1, t);
|
|
38
|
+
for (; ; ) {
|
|
39
|
+
r.push(e), e = e.next(1, !1);
|
|
40
|
+
const s = e.getFirstDay();
|
|
41
|
+
if (s.getYear() > this._year || s.getMonth() > this._month)
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
return r;
|
|
45
|
+
}
|
|
46
|
+
toString() {
|
|
47
|
+
return `${this.getYear()}-${this.getMonth()}`;
|
|
48
|
+
}
|
|
49
|
+
toFullString() {
|
|
50
|
+
return `${this.getYear()}年${this.getMonth()}月`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
o as SolarMonth
|
|
55
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SolarMonth as h } from "./SolarMonth.js";
|
|
2
|
+
class r {
|
|
3
|
+
_year;
|
|
4
|
+
_month;
|
|
5
|
+
static fromYm(t, e) {
|
|
6
|
+
return new r(t, e);
|
|
7
|
+
}
|
|
8
|
+
static fromDate(t) {
|
|
9
|
+
return r.fromYm(t.getFullYear(), t.getMonth() + 1);
|
|
10
|
+
}
|
|
11
|
+
constructor(t, e) {
|
|
12
|
+
this._year = t, this._month = e;
|
|
13
|
+
}
|
|
14
|
+
getYear() {
|
|
15
|
+
return this._year;
|
|
16
|
+
}
|
|
17
|
+
getMonth() {
|
|
18
|
+
return this._month;
|
|
19
|
+
}
|
|
20
|
+
getIndex() {
|
|
21
|
+
return Math.ceil(this._month / 3);
|
|
22
|
+
}
|
|
23
|
+
next(t) {
|
|
24
|
+
const e = h.fromYm(this._year, this._month).next(3 * t);
|
|
25
|
+
return r.fromYm(e.getYear(), e.getMonth());
|
|
26
|
+
}
|
|
27
|
+
getMonths() {
|
|
28
|
+
const t = [], e = this.getIndex() - 1;
|
|
29
|
+
for (let n = 0; n < 3; n++)
|
|
30
|
+
t.push(h.fromYm(this._year, 3 * e + n + 1));
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
|
+
toString() {
|
|
34
|
+
return `${this.getYear()}.${this.getIndex()}`;
|
|
35
|
+
}
|
|
36
|
+
toFullString() {
|
|
37
|
+
return `${this.getYear()}年${this.getIndex()}季度`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
r as SolarSeason
|
|
42
|
+
};
|