@pisell/utils 1.0.72 → 1.0.73
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/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
- package/es/arrayUtils.d.ts +4 -1
- package/es/arrayUtils.js +15 -24
- package/es/common/stateHelper.d.ts +6 -2
- package/es/common/stateHelper.js +22 -24
- package/es/common/types.d.ts +13 -10
- package/es/componentStorage.d.ts +27 -25
- package/es/componentStorage.js +94 -130
- package/es/constants/index.js +7 -9
- package/es/date.d.ts +6 -3
- package/es/date.js +36 -53
- package/es/document.d.ts +6 -3
- package/es/document.js +43 -67
- package/es/escPosPrinter/EscPosPrinter.js +353 -490
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +37 -52
- package/es/format.d.ts +29 -0
- package/es/format.js +90 -116
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +38 -23
- package/es/index.js +39 -34
- package/es/jsBridge/index.d.ts +26 -0
- package/es/jsBridge/index.js +57 -56
- package/es/jsBridge/regDeviceApi.js +107 -149
- package/es/jsBridge/types.d.ts +129 -0
- package/es/locales.d.ts +12 -0
- package/es/locales.js +77 -96
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +23 -0
- package/es/miniRedux.js +42 -78
- package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/es/number-input/hooks/useNumberInputState.js +71 -128
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/utils/formatter.d.ts +13 -10
- package/es/number-input/utils/formatter.js +51 -77
- package/es/number-input/utils/validation.d.ts +7 -2
- package/es/number-input/utils/validation.js +51 -66
- package/es/otherUtils.d.ts +12 -9
- package/es/otherUtils.js +71 -129
- package/es/platform.d.ts +17 -9
- package/es/platform.js +78 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/es/select/hooks/useDebouncedSearch.js +39 -53
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +56 -113
- package/es/select/index.d.ts +7 -8
- package/es/select/types.d.ts +211 -211
- package/es/select/utils/filterOptions.d.ts +7 -6
- package/es/select/utils/filterOptions.js +26 -31
- package/es/select/utils/helpers.d.ts +10 -9
- package/es/select/utils/helpers.js +42 -52
- package/es/select/utils/index.d.ts +4 -7
- package/es/select/utils/sortOptions.d.ts +6 -5
- package/es/select/utils/sortOptions.js +19 -31
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +34 -47
- package/es/text-input/hooks/useTextInputState.d.ts +6 -2
- package/es/text-input/hooks/useTextInputState.js +69 -126
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/utils/validation.d.ts +7 -2
- package/es/text-input/utils/validation.js +50 -70
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +36 -34
- package/es/walletValidity.js +332 -456
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/arrayUtils.d.ts +4 -1
- package/lib/arrayUtils.js +14 -39
- package/lib/common/stateHelper.d.ts +6 -2
- package/lib/common/stateHelper.js +21 -32
- package/lib/common/types.d.ts +13 -10
- package/lib/componentStorage.d.ts +27 -25
- package/lib/componentStorage.js +96 -126
- package/lib/constants/index.js +7 -36
- package/lib/date.d.ts +6 -3
- package/lib/date.js +43 -65
- package/lib/document.d.ts +6 -3
- package/lib/document.js +46 -62
- package/lib/escPosPrinter/EscPosPrinter.js +327 -403
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +38 -84
- package/lib/format.d.ts +29 -0
- package/lib/format.js +91 -99
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +38 -23
- package/lib/index.js +115 -78
- package/lib/jsBridge/index.d.ts +26 -0
- package/lib/jsBridge/index.js +58 -77
- package/lib/jsBridge/regDeviceApi.js +106 -153
- package/lib/jsBridge/types.d.ts +129 -0
- package/lib/locales.d.ts +12 -0
- package/lib/locales.js +79 -90
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +23 -0
- package/lib/miniRedux.js +43 -92
- package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/lib/number-input/hooks/useNumberInputState.js +71 -81
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/utils/formatter.d.ts +13 -10
- package/lib/number-input/utils/formatter.js +52 -49
- package/lib/number-input/utils/validation.d.ts +7 -2
- package/lib/number-input/utils/validation.js +50 -52
- package/lib/otherUtils.d.ts +12 -9
- package/lib/otherUtils.js +86 -98
- package/lib/platform.d.ts +17 -9
- package/lib/platform.js +85 -122
- package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/lib/select/hooks/useDebouncedSearch.js +40 -41
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +58 -93
- package/lib/select/index.d.ts +7 -8
- package/lib/select/types.d.ts +211 -211
- package/lib/select/utils/filterOptions.d.ts +7 -6
- package/lib/select/utils/filterOptions.js +26 -37
- package/lib/select/utils/helpers.d.ts +10 -9
- package/lib/select/utils/helpers.js +45 -41
- package/lib/select/utils/index.d.ts +4 -7
- package/lib/select/utils/sortOptions.d.ts +6 -5
- package/lib/select/utils/sortOptions.js +18 -39
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +33 -41
- package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
- package/lib/text-input/hooks/useTextInputState.js +69 -79
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/utils/validation.d.ts +7 -2
- package/lib/text-input/utils/validation.js +49 -58
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +36 -34
- package/lib/walletValidity.js +345 -317
- package/package.json +1 -2
- package/es/common/index.d.ts +0 -5
- package/es/common/index.js +0 -5
- package/es/common/types.js +0 -1
- package/es/constants/index.d.ts +0 -7
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/config/index.js +0 -54
- package/es/firebase/index.d.ts +0 -28
- package/es/firebase/index.js +0 -232
- package/es/jsBridge/types.js +0 -1
- package/es/number-input/hooks/index.d.ts +0 -4
- package/es/number-input/hooks/index.js +0 -5
- package/es/number-input/index.d.ts +0 -14
- package/es/number-input/index.js +0 -21
- package/es/number-input/types.js +0 -1
- package/es/number-input/utils/index.d.ts +0 -7
- package/es/number-input/utils/index.js +0 -8
- package/es/select/hooks/index.d.ts +0 -5
- package/es/select/hooks/index.js +0 -6
- package/es/select/index.js +0 -13
- package/es/select/types.js +0 -1
- package/es/select/utils/index.js +0 -8
- package/es/text-input/hooks/index.d.ts +0 -4
- package/es/text-input/hooks/index.js +0 -5
- package/es/text-input/index.d.ts +0 -14
- package/es/text-input/index.js +0 -20
- package/es/text-input/types.js +0 -1
- package/es/text-input/utils/index.d.ts +0 -5
- package/es/text-input/utils/index.js +0 -7
- package/lib/common/index.d.ts +0 -5
- package/lib/common/index.js +0 -29
- package/lib/common/types.js +0 -17
- package/lib/constants/index.d.ts +0 -7
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/config/index.js +0 -79
- package/lib/firebase/index.d.ts +0 -28
- package/lib/firebase/index.js +0 -180
- package/lib/jsBridge/types.js +0 -17
- package/lib/number-input/hooks/index.d.ts +0 -4
- package/lib/number-input/hooks/index.js +0 -29
- package/lib/number-input/index.d.ts +0 -14
- package/lib/number-input/index.js +0 -41
- package/lib/number-input/types.js +0 -17
- package/lib/number-input/utils/index.d.ts +0 -7
- package/lib/number-input/utils/index.js +0 -39
- package/lib/select/hooks/index.d.ts +0 -5
- package/lib/select/hooks/index.js +0 -34
- package/lib/select/index.js +0 -53
- package/lib/select/types.js +0 -17
- package/lib/select/utils/index.js +0 -48
- package/lib/text-input/hooks/index.d.ts +0 -4
- package/lib/text-input/hooks/index.js +0 -29
- package/lib/text-input/index.d.ts +0 -14
- package/lib/text-input/index.js +0 -35
- package/lib/text-input/types.js +0 -17
- package/lib/text-input/utils/index.d.ts +0 -5
- package/lib/text-input/utils/index.js +0 -32
package/lib/walletValidity.js
CHANGED
|
@@ -1,349 +1,377 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let dayjs = require("dayjs");
|
|
3
|
+
dayjs = require_runtime.__toESM(dayjs);
|
|
4
|
+
//#region src/walletValidity.ts
|
|
5
|
+
const CONSTANTS = {
|
|
6
|
+
ALL_DAY_START: "00:00",
|
|
7
|
+
ALL_DAY_END: "23:59",
|
|
8
|
+
DEFAULT_FUTURE_YEARS: 10,
|
|
9
|
+
SECONDS_SUFFIX: ":59"
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
weekPrefix: "",
|
|
121
|
-
dateFormat: "DD MMM YYYY",
|
|
122
|
-
dateTimeFormat: "DD MMM YYYY h:mm A",
|
|
123
|
-
longTermValidFrom: "from ",
|
|
124
|
-
noExpiry: ", no expiry",
|
|
125
|
-
on: "on "
|
|
126
|
-
}
|
|
11
|
+
const textConfig = {
|
|
12
|
+
"zh-HK": {
|
|
13
|
+
weekdays: [
|
|
14
|
+
"日",
|
|
15
|
+
"一",
|
|
16
|
+
"二",
|
|
17
|
+
"三",
|
|
18
|
+
"四",
|
|
19
|
+
"五",
|
|
20
|
+
"六"
|
|
21
|
+
],
|
|
22
|
+
separator: "、",
|
|
23
|
+
timeSeparator: "–",
|
|
24
|
+
rangeSeparator: " 至 ",
|
|
25
|
+
periodSeparator: ";",
|
|
26
|
+
timeSlotSeparator: ",",
|
|
27
|
+
every: "每",
|
|
28
|
+
day: "天",
|
|
29
|
+
week: "周",
|
|
30
|
+
month: "月",
|
|
31
|
+
year: "年",
|
|
32
|
+
available: "可用",
|
|
33
|
+
unlimited: "无限期",
|
|
34
|
+
multipleRules: "多規則,點詳情",
|
|
35
|
+
multipleSlots: ",多時段",
|
|
36
|
+
until: "至",
|
|
37
|
+
daily: "每天",
|
|
38
|
+
days: "天",
|
|
39
|
+
weeks: "周",
|
|
40
|
+
everyPrefix: "每",
|
|
41
|
+
weekPrefix: "周",
|
|
42
|
+
dateFormat: "YYYY-MM-DD",
|
|
43
|
+
dateTimeFormat: "YYYY-MM-DD HH:mm",
|
|
44
|
+
longTermValidFrom: "自",
|
|
45
|
+
noExpiry: "起長期有效",
|
|
46
|
+
on: ""
|
|
47
|
+
},
|
|
48
|
+
"zh-CN": {
|
|
49
|
+
weekdays: [
|
|
50
|
+
"日",
|
|
51
|
+
"一",
|
|
52
|
+
"二",
|
|
53
|
+
"三",
|
|
54
|
+
"四",
|
|
55
|
+
"五",
|
|
56
|
+
"六"
|
|
57
|
+
],
|
|
58
|
+
separator: "、",
|
|
59
|
+
timeSeparator: "–",
|
|
60
|
+
rangeSeparator: " 至 ",
|
|
61
|
+
periodSeparator: ";",
|
|
62
|
+
timeSlotSeparator: ",",
|
|
63
|
+
every: "每",
|
|
64
|
+
day: "天",
|
|
65
|
+
week: "周",
|
|
66
|
+
month: "月",
|
|
67
|
+
year: "年",
|
|
68
|
+
available: "可用",
|
|
69
|
+
unlimited: "无限期",
|
|
70
|
+
multipleRules: "多规则,点详情",
|
|
71
|
+
multipleSlots: ",多时段",
|
|
72
|
+
until: "至",
|
|
73
|
+
daily: "每天",
|
|
74
|
+
days: "天",
|
|
75
|
+
weeks: "周",
|
|
76
|
+
everyPrefix: "每",
|
|
77
|
+
weekPrefix: "周",
|
|
78
|
+
dateFormat: "YYYY-MM-DD",
|
|
79
|
+
dateTimeFormat: "YYYY-MM-DD HH:mm",
|
|
80
|
+
longTermValidFrom: "自",
|
|
81
|
+
noExpiry: "起长期有效",
|
|
82
|
+
on: ""
|
|
83
|
+
},
|
|
84
|
+
"en": {
|
|
85
|
+
weekdays: [
|
|
86
|
+
"Sun",
|
|
87
|
+
"Mon",
|
|
88
|
+
"Tue",
|
|
89
|
+
"Wed",
|
|
90
|
+
"Thu",
|
|
91
|
+
"Fri",
|
|
92
|
+
"Sat"
|
|
93
|
+
],
|
|
94
|
+
separator: ", ",
|
|
95
|
+
timeSeparator: "–",
|
|
96
|
+
rangeSeparator: " - ",
|
|
97
|
+
periodSeparator: "; ",
|
|
98
|
+
timeSlotSeparator: ", ",
|
|
99
|
+
every: "every ",
|
|
100
|
+
day: "day",
|
|
101
|
+
week: "week",
|
|
102
|
+
month: "month",
|
|
103
|
+
year: "year",
|
|
104
|
+
available: "available",
|
|
105
|
+
unlimited: "unlimited",
|
|
106
|
+
multipleRules: "Multiple rules, see details",
|
|
107
|
+
multipleSlots: ", multiple slots",
|
|
108
|
+
until: "Until ",
|
|
109
|
+
daily: "daily",
|
|
110
|
+
days: "days",
|
|
111
|
+
weeks: "weeks",
|
|
112
|
+
everyPrefix: "every ",
|
|
113
|
+
weekPrefix: "",
|
|
114
|
+
dateFormat: "DD MMM YYYY",
|
|
115
|
+
dateTimeFormat: "DD MMM YYYY h:mm A",
|
|
116
|
+
longTermValidFrom: "from ",
|
|
117
|
+
noExpiry: ", no expiry",
|
|
118
|
+
on: "on "
|
|
119
|
+
}
|
|
127
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* 获取星期几的表示
|
|
123
|
+
* @param dayNumbers 星期几的数字数组 (0-6, 0代表周日)
|
|
124
|
+
* @param locale 语言设置
|
|
125
|
+
* @param separator 分隔符,可选,默认使用locale配置的分隔符
|
|
126
|
+
* @returns 格式化的星期几文案
|
|
127
|
+
*/
|
|
128
128
|
function getWeekdayText(dayNumbers, locale, separator) {
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
const config = textConfig[locale];
|
|
130
|
+
return dayNumbers.map((day) => config.weekdays[day]).join(separator || config.separator);
|
|
131
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* 获取指定语言的文案配置
|
|
134
|
+
* @param locale 语言设置
|
|
135
|
+
* @param key 配置项key
|
|
136
|
+
* @returns 对应语言的文案
|
|
137
|
+
*/
|
|
132
138
|
function getText(locale, key) {
|
|
133
|
-
|
|
139
|
+
return textConfig[locale][key];
|
|
134
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* 获取指定语言的配置对象(缓存优化)
|
|
143
|
+
* @param locale 语言设置
|
|
144
|
+
* @returns 对应语言的完整配置对象
|
|
145
|
+
*/
|
|
135
146
|
function getConfig(locale) {
|
|
136
|
-
|
|
147
|
+
return textConfig[locale];
|
|
137
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* 获取每日频率文案
|
|
151
|
+
* @param frequency 频率数字
|
|
152
|
+
* @param locale 语言设置
|
|
153
|
+
* @returns 格式化的每日频率文案
|
|
154
|
+
*/
|
|
138
155
|
function getDailyFrequencyText(frequency, locale) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (locale === "en") {
|
|
144
|
-
return `${config.everyPrefix}${frequency} ${config.days}`;
|
|
145
|
-
} else {
|
|
146
|
-
return `${config.everyPrefix}${frequency}${config.days}`;
|
|
147
|
-
}
|
|
156
|
+
if (frequency === 1) return getText(locale, "daily");
|
|
157
|
+
const config = textConfig[locale];
|
|
158
|
+
if (locale === "en") return `${config.everyPrefix}${frequency} ${config.days}`;
|
|
159
|
+
else return `${config.everyPrefix}${frequency}${config.days}`;
|
|
148
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* 获取每周频率前缀文案
|
|
163
|
+
* @param frequency 频率数字
|
|
164
|
+
* @param locale 语言设置
|
|
165
|
+
* @returns 格式化的每周频率前缀文案
|
|
166
|
+
*/
|
|
149
167
|
function getWeeklyFrequencyPrefix(frequency, locale) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (locale === "en") {
|
|
155
|
-
return `${config.everyPrefix}${frequency} ${config.weeks}, `;
|
|
156
|
-
} else {
|
|
157
|
-
return `${config.everyPrefix}${frequency}${config.weeks} `;
|
|
158
|
-
}
|
|
168
|
+
if (frequency === 1) return "";
|
|
169
|
+
const config = textConfig[locale];
|
|
170
|
+
if (locale === "en") return `${config.everyPrefix}${frequency} ${config.weeks}, `;
|
|
171
|
+
else return `${config.everyPrefix}${frequency}${config.weeks} `;
|
|
159
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* 格式化日期时间函数
|
|
175
|
+
* @param dateTime 日期时间字符串
|
|
176
|
+
* @param isAll 是否为全天
|
|
177
|
+
* @param locale 语言设置
|
|
178
|
+
* @returns 格式化后的日期时间字符串
|
|
179
|
+
*/
|
|
160
180
|
function formatDateTime(dateTime, isAll = false, locale = "zh-CN") {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
return date.format(config.dateTimeFormat);
|
|
181
|
+
const date = (0, dayjs.default)(dateTime);
|
|
182
|
+
const config = getConfig(locale);
|
|
183
|
+
if (isAll) return date.format(config.dateFormat);
|
|
184
|
+
return date.format(config.dateTimeFormat);
|
|
167
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* 判断是否为全天日程
|
|
188
|
+
* @param startTime 开始时间 (HH:mm格式)
|
|
189
|
+
* @param endTime 结束时间 (HH:mm格式)
|
|
190
|
+
* @returns 是否为全天日程
|
|
191
|
+
*/
|
|
168
192
|
function isAllDaySchedule(startTime, endTime) {
|
|
169
|
-
|
|
193
|
+
return startTime === CONSTANTS.ALL_DAY_START && endTime === CONSTANTS.ALL_DAY_END;
|
|
170
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* 生成日期范围文案
|
|
197
|
+
* @param startDate 开始日期
|
|
198
|
+
* @param endDate 结束日期
|
|
199
|
+
* @param isStarted 是否已开始
|
|
200
|
+
* @param locale 语言设置
|
|
201
|
+
* @param isAllDay 是否为全天
|
|
202
|
+
* @returns 格式化的日期范围文案
|
|
203
|
+
*/
|
|
171
204
|
function formatDateRange(startDate, endDate, isStarted, locale, isAllDay = false) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
205
|
+
const config = getConfig(locale);
|
|
206
|
+
if (isStarted) {
|
|
207
|
+
const endDateStr = formatDateTime(endDate, isAllDay, locale);
|
|
208
|
+
return `${config.until}${endDateStr}`;
|
|
209
|
+
} else {
|
|
210
|
+
const startDateStr = formatDateTime(startDate, isAllDay, locale);
|
|
211
|
+
const endDateStr = formatDateTime(endDate, isAllDay, locale);
|
|
212
|
+
return `${startDateStr}${config.rangeSeparator}${endDateStr}`;
|
|
213
|
+
}
|
|
181
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* 获取schedule摘要信息
|
|
217
|
+
* @param scheduleList 日程列表
|
|
218
|
+
* @param locale 语言设置
|
|
219
|
+
* @returns 摘要文本
|
|
220
|
+
*/
|
|
182
221
|
function getScheduleSummary(scheduleList, locale = "zh-CN") {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
} else if (schedule.designation && schedule.designation.length > 0) {
|
|
202
|
-
const firstDesignation = schedule.designation[0];
|
|
203
|
-
if (firstDesignation && firstDesignation.start_date && firstDesignation.start_time) {
|
|
204
|
-
startTime = (0, import_dayjs.default)(`${firstDesignation.start_date} ${firstDesignation.start_time}`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const isStarted = startTime ? isTimeStarted(now, startTime) : false;
|
|
208
|
-
return generateSummaryText(schedule, isStarted, locale);
|
|
209
|
-
} catch (error) {
|
|
210
|
-
console.warn("Error in getScheduleSummary:", error);
|
|
211
|
-
return "";
|
|
212
|
-
}
|
|
222
|
+
try {
|
|
223
|
+
if (!scheduleList || !Array.isArray(scheduleList)) return "";
|
|
224
|
+
if (scheduleList.length > 1) return getText(locale, "multipleRules");
|
|
225
|
+
if (scheduleList.length === 0) return "";
|
|
226
|
+
const schedule = scheduleList[0];
|
|
227
|
+
if (!schedule) return "";
|
|
228
|
+
const now = (0, dayjs.default)();
|
|
229
|
+
let startTime = null;
|
|
230
|
+
if (schedule.start_time) startTime = (0, dayjs.default)(schedule.start_time);
|
|
231
|
+
else if (schedule.designation && schedule.designation.length > 0) {
|
|
232
|
+
const firstDesignation = schedule.designation[0];
|
|
233
|
+
if (firstDesignation && firstDesignation.start_date && firstDesignation.start_time) startTime = (0, dayjs.default)(`${firstDesignation.start_date} ${firstDesignation.start_time}`);
|
|
234
|
+
}
|
|
235
|
+
return generateSummaryText(schedule, startTime ? isTimeStarted(now, startTime) : false, locale);
|
|
236
|
+
} catch (error) {
|
|
237
|
+
console.warn("Error in getScheduleSummary:", error);
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
213
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* 判断开始时间是否在当前时间之后
|
|
243
|
+
* @param now 当前时间
|
|
244
|
+
* @param startTime 开始时间
|
|
245
|
+
* @returns 是否已开始
|
|
246
|
+
*/
|
|
214
247
|
function isTimeStarted(now, startTime) {
|
|
215
|
-
|
|
248
|
+
return startTime.isBefore(now);
|
|
216
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* 生成摘要文本
|
|
252
|
+
* @param schedule 日程对象
|
|
253
|
+
* @param isStarted 是否已开始
|
|
254
|
+
* @param locale 语言设置
|
|
255
|
+
* @returns 生成的摘要文本
|
|
256
|
+
*/
|
|
217
257
|
function generateSummaryText(schedule, isStarted, locale) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const suffix = getText(locale, "multipleSlots");
|
|
227
|
-
return `${prefix}${endDateStr}${suffix}`;
|
|
228
|
-
}
|
|
229
|
-
if (schedule.repeat_type !== "none" && schedule.repeat_rule) {
|
|
230
|
-
return generateRecurringSummary(schedule, isStarted, locale);
|
|
231
|
-
}
|
|
232
|
-
return generateSingleScheduleSummary(schedule, isStarted, locale);
|
|
258
|
+
if (schedule.type === "designation" && schedule.designation && schedule.designation.length > 1) return getText(locale, "multipleRules");
|
|
259
|
+
if (schedule.type === "time-slots") {
|
|
260
|
+
const endDate = getScheduleEndDate(schedule);
|
|
261
|
+
if (!endDate) return "";
|
|
262
|
+
return `${formatDateTime(endDate, true, locale)}${getText(locale, "multipleSlots")}`;
|
|
263
|
+
}
|
|
264
|
+
if (schedule.repeat_type !== "none" && schedule.repeat_rule) return generateRecurringSummary(schedule, isStarted, locale);
|
|
265
|
+
return generateSingleScheduleSummary(schedule, isStarted, locale);
|
|
233
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* 生成循环日程摘要
|
|
269
|
+
* @param schedule 日程对象
|
|
270
|
+
* @param isStarted 是否已开始
|
|
271
|
+
* @param locale 语言设置
|
|
272
|
+
* @returns 循环日程摘要文本
|
|
273
|
+
*/
|
|
234
274
|
function generateRecurringSummary(schedule, isStarted, locale) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true);
|
|
254
|
-
return `${dateRange},${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
|
|
255
|
-
}
|
|
256
|
-
return "";
|
|
275
|
+
const { repeat_type, repeat_rule } = schedule;
|
|
276
|
+
if (!repeat_rule) return "";
|
|
277
|
+
const { frequency, frequency_date, end } = repeat_rule;
|
|
278
|
+
if (end.type === "never") return generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeat_type, frequency, frequency_date);
|
|
279
|
+
const endDate = getScheduleEndDate(schedule);
|
|
280
|
+
if (!endDate) return "";
|
|
281
|
+
formatDateTime(endDate, true, locale);
|
|
282
|
+
if (repeat_type === "daily") {
|
|
283
|
+
const frequencyText = getDailyFrequencyText(frequency, locale);
|
|
284
|
+
return `${formatDateRange(schedule.start_time, endDate, isStarted, locale, true)},${frequencyText}`;
|
|
285
|
+
}
|
|
286
|
+
if (repeat_type === "weekly") {
|
|
287
|
+
const weekdaysText = getWeekdayText(frequency_date, locale, "/");
|
|
288
|
+
const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
289
|
+
const config = getConfig(locale);
|
|
290
|
+
return `${formatDateRange(schedule.start_time, endDate, isStarted, locale, true)},${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
|
|
291
|
+
}
|
|
292
|
+
return "";
|
|
257
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* 生成永不结束的循环日程摘要
|
|
296
|
+
* @param schedule 日程对象
|
|
297
|
+
* @param isStarted 是否已开始
|
|
298
|
+
* @param locale 语言设置
|
|
299
|
+
* @param repeatType 循环类型
|
|
300
|
+
* @param frequency 频率
|
|
301
|
+
* @param frequencyDate 频率日期数组(用于周循环)
|
|
302
|
+
* @returns 永不结束的循环日程摘要文本
|
|
303
|
+
*/
|
|
258
304
|
function generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeatType, frequency, frequencyDate) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return `${config.everyPrefix}${config.weekPrefix}${weekdaysText}${config.available}`;
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
286
|
-
if (locale === "en") {
|
|
287
|
-
return `${frequencyPrefix}${config.on}${weekdaysText}`;
|
|
288
|
-
} else {
|
|
289
|
-
return `${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return "";
|
|
305
|
+
const config = getConfig(locale);
|
|
306
|
+
if (repeatType === "daily") if (frequency === 1) {
|
|
307
|
+
if (schedule.start_time) {
|
|
308
|
+
const startDateStr = formatDateTime(schedule.start_time, true, locale);
|
|
309
|
+
return `${config.longTermValidFrom}${startDateStr}${config.noExpiry}`;
|
|
310
|
+
}
|
|
311
|
+
return "";
|
|
312
|
+
} else {
|
|
313
|
+
const frequencyText = getDailyFrequencyText(frequency, locale);
|
|
314
|
+
if (locale === "en") return `${frequencyText}`;
|
|
315
|
+
else return `${frequencyText}${config.available}`;
|
|
316
|
+
}
|
|
317
|
+
if (repeatType === "weekly") {
|
|
318
|
+
const weekdaysText = getWeekdayText(frequencyDate, locale, locale === "en" ? " & " : "/");
|
|
319
|
+
if (frequency === 1) if (locale === "en") return `${config.on}${weekdaysText}`;
|
|
320
|
+
else return `${config.everyPrefix}${config.weekPrefix}${weekdaysText}${config.available}`;
|
|
321
|
+
else {
|
|
322
|
+
const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
323
|
+
if (locale === "en") return `${frequencyPrefix}${config.on}${weekdaysText}`;
|
|
324
|
+
else return `${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return "";
|
|
294
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* 生成单个日程摘要
|
|
331
|
+
* @param schedule 日程对象
|
|
332
|
+
* @param isStarted 是否已开始
|
|
333
|
+
* @param locale 语言设置
|
|
334
|
+
* @returns 单个日程摘要文本
|
|
335
|
+
*/
|
|
295
336
|
function generateSingleScheduleSummary(schedule, isStarted, locale) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
if (isAllDay) {
|
|
313
|
-
const endDate = getScheduleEndDate(schedule);
|
|
314
|
-
if (!endDate) return "";
|
|
315
|
-
return formatDateRange(schedule.start_time, endDate, isStarted, locale, true);
|
|
316
|
-
} else {
|
|
317
|
-
return formatDateRange(schedule.start_time, schedule.end_time, isStarted, locale, false);
|
|
318
|
-
}
|
|
337
|
+
const isAllDay = schedule.is_all === 1;
|
|
338
|
+
if (schedule.type === "designation" && schedule.designation && schedule.designation.length === 1) {
|
|
339
|
+
const designation = schedule.designation[0];
|
|
340
|
+
const startDate = designation.start_date;
|
|
341
|
+
const endDate = designation.end_date;
|
|
342
|
+
const startTime = designation.start_time;
|
|
343
|
+
const endTime = designation.end_time;
|
|
344
|
+
if (isAllDaySchedule(startTime, endTime) || isAllDay) return formatDateRange(startDate, endDate, isStarted, locale, true);
|
|
345
|
+
else return formatDateRange(`${startDate} ${startTime}${CONSTANTS.SECONDS_SUFFIX}`, `${endDate} ${endTime}${CONSTANTS.SECONDS_SUFFIX}`, isStarted, locale, false);
|
|
346
|
+
}
|
|
347
|
+
if (isAllDay) {
|
|
348
|
+
const endDate = getScheduleEndDate(schedule);
|
|
349
|
+
if (!endDate) return "";
|
|
350
|
+
return formatDateRange(schedule.start_time, endDate, isStarted, locale, true);
|
|
351
|
+
} else return formatDateRange(schedule.start_time, schedule.end_time, isStarted, locale, false);
|
|
319
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* 获取日程结束日期
|
|
355
|
+
* @param schedule 日程对象
|
|
356
|
+
* @returns 结束日期字符串,如果无法确定则返回null
|
|
357
|
+
*/
|
|
320
358
|
function getScheduleEndDate(schedule) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (schedule.start_time) {
|
|
338
|
-
return schedule.start_time;
|
|
339
|
-
}
|
|
340
|
-
return null;
|
|
341
|
-
} catch (error) {
|
|
342
|
-
console.warn("Error in getScheduleEndDate:", error);
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
359
|
+
try {
|
|
360
|
+
if (schedule.repeat_rule) {
|
|
361
|
+
if (schedule.repeat_rule.end.type === "never") return `${(0, dayjs.default)().add(CONSTANTS.DEFAULT_FUTURE_YEARS, "year").format("YYYY-MM-DD")} ${CONSTANTS.ALL_DAY_END}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
362
|
+
else if (schedule.repeat_rule.end.end_date) return `${schedule.repeat_rule.end.end_date} ${CONSTANTS.ALL_DAY_END}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
363
|
+
}
|
|
364
|
+
if (schedule.designation && schedule.designation.length > 0) {
|
|
365
|
+
const lastDesignation = schedule.designation[schedule.designation.length - 1];
|
|
366
|
+
return `${lastDesignation.end_date} ${lastDesignation.end_time}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
367
|
+
}
|
|
368
|
+
if (schedule.end_time) return schedule.end_time;
|
|
369
|
+
if (schedule.start_time) return schedule.start_time;
|
|
370
|
+
return null;
|
|
371
|
+
} catch (error) {
|
|
372
|
+
console.warn("Error in getScheduleEndDate:", error);
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
345
375
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
getScheduleSummary
|
|
349
|
-
});
|
|
376
|
+
//#endregion
|
|
377
|
+
exports.getScheduleSummary = getScheduleSummary;
|