@pisell/utils 3.0.4 → 3.0.6
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 +76 -1
- package/es/arrayUtils.js +103 -24
- package/es/common/stateHelper.d.ts +22 -0
- package/es/common/stateHelper.js +23 -0
- package/es/common/types.d.ts +31 -0
- package/es/componentStorage.d.ts +38 -0
- package/es/componentStorage.js +106 -0
- 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 -112
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +39 -18
- package/es/index.js +40 -29
- package/es/jsBridge/index.d.ts +14 -106
- package/es/jsBridge/index.js +57 -40
- package/es/jsBridge/regDeviceApi.js +87 -126
- package/es/jsBridge/types.d.ts +129 -0
- package/es/locales.d.ts +11 -11
- package/es/locales.js +79 -69
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +20 -13
- package/es/miniRedux.js +42 -71
- package/es/number-input/hooks/useNumberInputState.d.ts +29 -0
- package/es/number-input/hooks/useNumberInputState.js +72 -0
- package/es/number-input/types.d.ts +96 -0
- package/es/number-input/utils/formatter.d.ts +56 -0
- package/es/number-input/utils/formatter.js +56 -0
- package/es/number-input/utils/validation.d.ts +32 -0
- package/es/number-input/utils/validation.js +52 -0
- package/es/otherUtils.d.ts +12 -9
- package/es/otherUtils.js +71 -120
- package/es/platform.d.ts +12 -9
- package/es/platform.js +61 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +23 -0
- package/es/select/hooks/useDebouncedSearch.js +41 -0
- package/es/select/hooks/useSelectState.d.ts +19 -0
- package/es/select/hooks/useSelectState.js +60 -0
- package/es/select/index.d.ts +7 -0
- package/es/select/types.d.ts +256 -0
- package/es/select/utils/filterOptions.d.ts +23 -0
- package/es/select/utils/filterOptions.js +29 -0
- package/es/select/utils/helpers.d.ts +43 -0
- package/es/select/utils/helpers.js +51 -0
- package/es/select/utils/index.d.ts +4 -0
- package/es/select/utils/sortOptions.d.ts +13 -0
- package/es/select/utils/sortOptions.js +20 -0
- package/es/select/utils/tagAggregation.d.ts +25 -0
- package/es/select/utils/tagAggregation.js +35 -0
- package/es/text-input/hooks/useTextInputState.d.ts +28 -0
- package/es/text-input/hooks/useTextInputState.js +70 -0
- package/es/text-input/types.d.ts +56 -0
- package/es/text-input/utils/validation.d.ts +28 -0
- package/es/text-input/utils/validation.js +51 -0
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +57 -0
- package/es/walletValidity.js +404 -460
- package/es/weighing.d.ts +65 -0
- package/es/weighing.js +96 -0
- 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 +76 -1
- package/lib/arrayUtils.js +102 -37
- package/lib/common/stateHelper.d.ts +22 -0
- package/lib/common/stateHelper.js +23 -0
- package/lib/common/types.d.ts +31 -0
- package/lib/componentStorage.d.ts +38 -0
- package/lib/componentStorage.js +114 -0
- 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 -93
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +39 -18
- package/lib/index.js +137 -68
- package/lib/jsBridge/index.d.ts +14 -106
- package/lib/jsBridge/index.js +60 -60
- package/lib/jsBridge/regDeviceApi.js +86 -133
- package/lib/jsBridge/types.d.ts +129 -0
- package/lib/locales.d.ts +11 -11
- package/lib/locales.js +79 -63
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +20 -13
- package/lib/miniRedux.js +43 -91
- package/lib/number-input/hooks/useNumberInputState.d.ts +29 -0
- package/lib/number-input/hooks/useNumberInputState.js +73 -0
- package/lib/number-input/types.d.ts +96 -0
- package/lib/number-input/utils/formatter.d.ts +56 -0
- package/lib/number-input/utils/formatter.js +58 -0
- package/lib/number-input/utils/validation.d.ts +32 -0
- package/lib/number-input/utils/validation.js +52 -0
- package/lib/otherUtils.d.ts +12 -9
- package/lib/otherUtils.js +86 -91
- package/lib/platform.d.ts +12 -9
- package/lib/platform.js +68 -123
- package/lib/select/hooks/useDebouncedSearch.d.ts +23 -0
- package/lib/select/hooks/useDebouncedSearch.js +42 -0
- package/lib/select/hooks/useSelectState.d.ts +19 -0
- package/lib/select/hooks/useSelectState.js +62 -0
- package/lib/select/index.d.ts +7 -0
- package/lib/select/types.d.ts +256 -0
- package/lib/select/utils/filterOptions.d.ts +23 -0
- package/lib/select/utils/filterOptions.js +30 -0
- package/lib/select/utils/helpers.d.ts +43 -0
- package/lib/select/utils/helpers.js +55 -0
- package/lib/select/utils/index.d.ts +4 -0
- package/lib/select/utils/sortOptions.d.ts +13 -0
- package/lib/select/utils/sortOptions.js +20 -0
- package/lib/select/utils/tagAggregation.d.ts +25 -0
- package/lib/select/utils/tagAggregation.js +35 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +28 -0
- package/lib/text-input/hooks/useTextInputState.js +71 -0
- package/lib/text-input/types.d.ts +56 -0
- package/lib/text-input/utils/validation.d.ts +28 -0
- package/lib/text-input/utils/validation.js +51 -0
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +57 -0
- package/lib/walletValidity.js +420 -323
- package/lib/weighing.d.ts +65 -0
- package/lib/weighing.js +114 -0
- package/package.json +1 -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/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/es/walletValidity.js
CHANGED
|
@@ -1,499 +1,443 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ALL_DAY_END: '23:59',
|
|
9
|
-
DEFAULT_FUTURE_YEARS: 10,
|
|
10
|
-
SECONDS_SUFFIX: ':59'
|
|
1
|
+
import { _objectSpread2 } from "./_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
//#region src/walletValidity.ts
|
|
4
|
+
const CONSTANTS = {
|
|
5
|
+
ALL_DAY_START: "00:00",
|
|
6
|
+
ALL_DAY_END: "23:59",
|
|
7
|
+
SECONDS_SUFFIX: ":59"
|
|
11
8
|
};
|
|
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
|
-
|
|
9
|
+
function getValidityDate(value) {
|
|
10
|
+
if (typeof value !== "string") return null;
|
|
11
|
+
const match = value.match(/^(\d{4}-\d{2}-\d{2})(?:$|[ T])/);
|
|
12
|
+
if (!match) return null;
|
|
13
|
+
const date = dayjs(match[1]);
|
|
14
|
+
return date.isValid() && date.format("YYYY-MM-DD") === match[1] ? match[1] : null;
|
|
15
|
+
}
|
|
16
|
+
/** 仅计算展示日期的交集,不修改日程的重复起点或每日使用时段。 */
|
|
17
|
+
function getWalletValidityRange(start, end, validity) {
|
|
18
|
+
const scheduleStart = getValidityDate(start);
|
|
19
|
+
const scheduleEnd = getValidityDate(end);
|
|
20
|
+
const passStart = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.start_date);
|
|
21
|
+
const passEnd = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.expire_date) || getValidityDate(validity === null || validity === void 0 ? void 0 : validity.expire_time);
|
|
22
|
+
const startDate = passStart && (!scheduleStart || passStart > scheduleStart) ? passStart : scheduleStart;
|
|
23
|
+
const endDate = passEnd && (!scheduleEnd || passEnd < scheduleEnd) ? passEnd : scheduleEnd;
|
|
24
|
+
return {
|
|
25
|
+
startDate,
|
|
26
|
+
endDate,
|
|
27
|
+
isEmpty: Boolean(startDate && endDate && startDate > endDate)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const textConfig = {
|
|
31
|
+
"zh-HK": {
|
|
32
|
+
weekdays: [
|
|
33
|
+
"日",
|
|
34
|
+
"一",
|
|
35
|
+
"二",
|
|
36
|
+
"三",
|
|
37
|
+
"四",
|
|
38
|
+
"五",
|
|
39
|
+
"六"
|
|
40
|
+
],
|
|
41
|
+
separator: "、",
|
|
42
|
+
timeSeparator: "–",
|
|
43
|
+
rangeSeparator: " 至 ",
|
|
44
|
+
periodSeparator: ";",
|
|
45
|
+
timeSlotSeparator: ",",
|
|
46
|
+
every: "每",
|
|
47
|
+
day: "天",
|
|
48
|
+
week: "周",
|
|
49
|
+
month: "月",
|
|
50
|
+
year: "年",
|
|
51
|
+
available: "可用",
|
|
52
|
+
unlimited: "无限期",
|
|
53
|
+
noAvailableDates: "無可用日期",
|
|
54
|
+
multipleRules: "多規則,點詳情",
|
|
55
|
+
multipleSlots: ",多時段",
|
|
56
|
+
until: "至",
|
|
57
|
+
daily: "每天",
|
|
58
|
+
days: "天",
|
|
59
|
+
weeks: "周",
|
|
60
|
+
everyPrefix: "每",
|
|
61
|
+
weekPrefix: "周",
|
|
62
|
+
dateFormat: "YYYY-MM-DD",
|
|
63
|
+
dateTimeFormat: "YYYY-MM-DD HH:mm",
|
|
64
|
+
longTermValidFrom: "自",
|
|
65
|
+
noExpiry: "起長期有效",
|
|
66
|
+
on: ""
|
|
67
|
+
},
|
|
68
|
+
"zh-CN": {
|
|
69
|
+
weekdays: [
|
|
70
|
+
"日",
|
|
71
|
+
"一",
|
|
72
|
+
"二",
|
|
73
|
+
"三",
|
|
74
|
+
"四",
|
|
75
|
+
"五",
|
|
76
|
+
"六"
|
|
77
|
+
],
|
|
78
|
+
separator: "、",
|
|
79
|
+
timeSeparator: "–",
|
|
80
|
+
rangeSeparator: " 至 ",
|
|
81
|
+
periodSeparator: ";",
|
|
82
|
+
timeSlotSeparator: ",",
|
|
83
|
+
every: "每",
|
|
84
|
+
day: "天",
|
|
85
|
+
week: "周",
|
|
86
|
+
month: "月",
|
|
87
|
+
year: "年",
|
|
88
|
+
available: "可用",
|
|
89
|
+
unlimited: "无限期",
|
|
90
|
+
noAvailableDates: "无可用日期",
|
|
91
|
+
multipleRules: "多规则,点详情",
|
|
92
|
+
multipleSlots: ",多时段",
|
|
93
|
+
until: "至",
|
|
94
|
+
daily: "每天",
|
|
95
|
+
days: "天",
|
|
96
|
+
weeks: "周",
|
|
97
|
+
everyPrefix: "每",
|
|
98
|
+
weekPrefix: "周",
|
|
99
|
+
dateFormat: "YYYY-MM-DD",
|
|
100
|
+
dateTimeFormat: "YYYY-MM-DD HH:mm",
|
|
101
|
+
longTermValidFrom: "自",
|
|
102
|
+
noExpiry: "起长期有效",
|
|
103
|
+
on: ""
|
|
104
|
+
},
|
|
105
|
+
"en": {
|
|
106
|
+
weekdays: [
|
|
107
|
+
"Sun",
|
|
108
|
+
"Mon",
|
|
109
|
+
"Tue",
|
|
110
|
+
"Wed",
|
|
111
|
+
"Thu",
|
|
112
|
+
"Fri",
|
|
113
|
+
"Sat"
|
|
114
|
+
],
|
|
115
|
+
separator: ", ",
|
|
116
|
+
timeSeparator: "–",
|
|
117
|
+
rangeSeparator: " - ",
|
|
118
|
+
periodSeparator: "; ",
|
|
119
|
+
timeSlotSeparator: ", ",
|
|
120
|
+
every: "every ",
|
|
121
|
+
day: "day",
|
|
122
|
+
week: "week",
|
|
123
|
+
month: "month",
|
|
124
|
+
year: "year",
|
|
125
|
+
available: "available",
|
|
126
|
+
unlimited: "unlimited",
|
|
127
|
+
noAvailableDates: "No available dates",
|
|
128
|
+
multipleRules: "Multiple rules, see details",
|
|
129
|
+
multipleSlots: ", multiple slots",
|
|
130
|
+
until: "Until ",
|
|
131
|
+
daily: "daily",
|
|
132
|
+
days: "days",
|
|
133
|
+
weeks: "weeks",
|
|
134
|
+
everyPrefix: "every ",
|
|
135
|
+
weekPrefix: "",
|
|
136
|
+
dateFormat: "DD MMM YYYY",
|
|
137
|
+
dateTimeFormat: "DD MMM YYYY h:mm A",
|
|
138
|
+
longTermValidFrom: "from ",
|
|
139
|
+
noExpiry: ", no expiry",
|
|
140
|
+
on: "on "
|
|
141
|
+
}
|
|
101
142
|
};
|
|
102
|
-
|
|
103
143
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
144
|
+
* 获取星期几的表示
|
|
145
|
+
* @param dayNumbers 星期几的数字数组 (0-6, 0代表周日)
|
|
146
|
+
* @param locale 语言设置
|
|
147
|
+
* @param separator 分隔符,可选,默认使用locale配置的分隔符
|
|
148
|
+
* @returns 格式化的星期几文案
|
|
149
|
+
*/
|
|
110
150
|
function getWeekdayText(dayNumbers, locale, separator) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return config.weekdays[day];
|
|
114
|
-
}).join(separator || config.separator);
|
|
151
|
+
const config = textConfig[locale];
|
|
152
|
+
return [...new Set(dayNumbers)].sort((a, b) => a - b).map((day) => config.weekdays[day]).join(separator || config.separator);
|
|
115
153
|
}
|
|
116
|
-
|
|
117
154
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
155
|
+
* 获取指定语言的文案配置
|
|
156
|
+
* @param locale 语言设置
|
|
157
|
+
* @param key 配置项key
|
|
158
|
+
* @returns 对应语言的文案
|
|
159
|
+
*/
|
|
123
160
|
function getText(locale, key) {
|
|
124
|
-
|
|
161
|
+
return textConfig[locale][key];
|
|
125
162
|
}
|
|
126
|
-
|
|
127
163
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
164
|
+
* 获取指定语言的配置对象(缓存优化)
|
|
165
|
+
* @param locale 语言设置
|
|
166
|
+
* @returns 对应语言的完整配置对象
|
|
167
|
+
*/
|
|
132
168
|
function getConfig(locale) {
|
|
133
|
-
|
|
169
|
+
return textConfig[locale];
|
|
134
170
|
}
|
|
135
|
-
|
|
136
171
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
172
|
+
* 获取每日频率文案
|
|
173
|
+
* @param frequency 频率数字
|
|
174
|
+
* @param locale 语言设置
|
|
175
|
+
* @returns 格式化的每日频率文案
|
|
176
|
+
*/
|
|
142
177
|
function getDailyFrequencyText(frequency, locale) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (locale === 'en') {
|
|
148
|
-
return "".concat(config.everyPrefix).concat(frequency, " ").concat(config.days);
|
|
149
|
-
} else {
|
|
150
|
-
return "".concat(config.everyPrefix).concat(frequency).concat(config.days);
|
|
151
|
-
}
|
|
178
|
+
if (frequency === 1) return getText(locale, "daily");
|
|
179
|
+
const config = textConfig[locale];
|
|
180
|
+
if (locale === "en") return `${config.everyPrefix}${frequency} ${config.days}`;
|
|
181
|
+
else return `${config.everyPrefix}${frequency}${config.days}`;
|
|
152
182
|
}
|
|
153
|
-
|
|
154
183
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
184
|
+
* 获取每周频率前缀文案
|
|
185
|
+
* @param frequency 频率数字
|
|
186
|
+
* @param locale 语言设置
|
|
187
|
+
* @returns 格式化的每周频率前缀文案
|
|
188
|
+
*/
|
|
160
189
|
function getWeeklyFrequencyPrefix(frequency, locale) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (locale === 'en') {
|
|
166
|
-
return "".concat(config.everyPrefix).concat(frequency, " ").concat(config.weeks, ", ");
|
|
167
|
-
} else {
|
|
168
|
-
return "".concat(config.everyPrefix).concat(frequency).concat(config.weeks, " ");
|
|
169
|
-
}
|
|
190
|
+
if (frequency === 1) return "";
|
|
191
|
+
const config = textConfig[locale];
|
|
192
|
+
if (locale === "en") return `${config.everyPrefix}${frequency} ${config.weeks}, `;
|
|
193
|
+
else return `${config.everyPrefix}${frequency}${config.weeks} `;
|
|
170
194
|
}
|
|
171
|
-
|
|
172
195
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
function formatDateTime(dateTime) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if (isAll) {
|
|
185
|
-
// 全天情况下的日期格式
|
|
186
|
-
return date.format(config.dateFormat);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// 非全天情况下的日期时间格式
|
|
190
|
-
return date.format(config.dateTimeFormat);
|
|
196
|
+
* 格式化日期时间函数
|
|
197
|
+
* @param dateTime 日期时间字符串
|
|
198
|
+
* @param isAll 是否为全天
|
|
199
|
+
* @param locale 语言设置
|
|
200
|
+
* @returns 格式化后的日期时间字符串
|
|
201
|
+
*/
|
|
202
|
+
function formatDateTime(dateTime, isAll = false, locale = "zh-CN") {
|
|
203
|
+
const date = dayjs(dateTime);
|
|
204
|
+
const config = getConfig(locale);
|
|
205
|
+
if (isAll) return date.format(config.dateFormat);
|
|
206
|
+
return date.format(config.dateTimeFormat);
|
|
191
207
|
}
|
|
192
|
-
|
|
193
208
|
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
209
|
+
* 判断是否为全天日程
|
|
210
|
+
* @param startTime 开始时间 (HH:mm格式)
|
|
211
|
+
* @param endTime 结束时间 (HH:mm格式)
|
|
212
|
+
* @returns 是否为全天日程
|
|
213
|
+
*/
|
|
199
214
|
function isAllDaySchedule(startTime, endTime) {
|
|
200
|
-
|
|
215
|
+
return startTime === CONSTANTS.ALL_DAY_START && endTime === CONSTANTS.ALL_DAY_END;
|
|
201
216
|
}
|
|
202
|
-
|
|
203
217
|
/**
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
function formatDateRange(startDate, endDate, isStarted, locale) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
* 生成日期范围文案
|
|
219
|
+
* @param startDate 开始日期
|
|
220
|
+
* @param endDate 结束日期
|
|
221
|
+
* @param isStarted 是否已开始
|
|
222
|
+
* @param locale 语言设置
|
|
223
|
+
* @param isAllDay 是否为全天
|
|
224
|
+
* @returns 格式化的日期范围文案
|
|
225
|
+
*/
|
|
226
|
+
function formatDateRange(startDate, endDate, isStarted, locale, isAllDay = false, validity) {
|
|
227
|
+
const config = getConfig(locale);
|
|
228
|
+
const range = getWalletValidityRange(startDate, endDate, validity);
|
|
229
|
+
if (range.isEmpty) return config.noAvailableDates;
|
|
230
|
+
const effectiveStart = range.startDate === getValidityDate(startDate) ? startDate : `${range.startDate} 00:00:00`;
|
|
231
|
+
const effectiveEnd = range.endDate === getValidityDate(endDate) ? endDate : `${range.endDate} 23:59:59`;
|
|
232
|
+
if (!range.endDate) return config.unlimited;
|
|
233
|
+
if ((range.startDate ? dayjs(effectiveStart).isBefore(dayjs()) : isStarted) || !range.startDate) {
|
|
234
|
+
const endDateStr = formatDateTime(effectiveEnd, isAllDay, locale);
|
|
235
|
+
return `${config.until}${endDateStr}`;
|
|
236
|
+
} else {
|
|
237
|
+
const startDateStr = formatDateTime(effectiveStart, isAllDay, locale);
|
|
238
|
+
const endDateStr = formatDateTime(effectiveEnd, isAllDay, locale);
|
|
239
|
+
return `${startDateStr}${config.rangeSeparator}${endDateStr}`;
|
|
240
|
+
}
|
|
223
241
|
}
|
|
224
|
-
|
|
225
242
|
/**
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
243
|
+
* 获取schedule摘要信息
|
|
244
|
+
* @param scheduleList 日程列表
|
|
245
|
+
* @param locale 语言设置
|
|
246
|
+
* @returns 摘要文本
|
|
247
|
+
*/
|
|
248
|
+
function getScheduleSummary(scheduleList, locale = "zh-CN", validity) {
|
|
249
|
+
try {
|
|
250
|
+
locale = textConfig[locale] ? locale : "en";
|
|
251
|
+
if (!scheduleList || !Array.isArray(scheduleList)) return "";
|
|
252
|
+
if (scheduleList.length > 1) {
|
|
253
|
+
const range = getWalletValidityRange(null, null, validity);
|
|
254
|
+
if (!range.startDate && !range.endDate) return getText(locale, "multipleRules");
|
|
255
|
+
const summaries = scheduleList.map((schedule) => getScheduleSummary([schedule], locale, validity)).filter((summary) => summary !== getText(locale, "noAvailableDates"));
|
|
256
|
+
if (summaries.length === 0) return getText(locale, "noAvailableDates");
|
|
257
|
+
if (summaries.length === 1 && summaries[0]) return summaries[0];
|
|
258
|
+
return `${range.endDate ? `${formatDateRange(range.startDate || "", range.endDate, false, locale, true)}${getText(locale, "periodSeparator")}` : ""}${getText(locale, "multipleRules")}`;
|
|
259
|
+
}
|
|
260
|
+
if (scheduleList.length === 0) return "";
|
|
261
|
+
const schedule = scheduleList[0];
|
|
262
|
+
if (!schedule) return "";
|
|
263
|
+
const now = dayjs();
|
|
264
|
+
let startTime = null;
|
|
265
|
+
if (schedule.start_time) startTime = dayjs(schedule.start_time);
|
|
266
|
+
else if (schedule.designation && schedule.designation.length > 0) {
|
|
267
|
+
const firstDesignation = schedule.designation[0];
|
|
268
|
+
if (firstDesignation && firstDesignation.start_date && firstDesignation.start_time) startTime = dayjs(`${firstDesignation.start_date} ${firstDesignation.start_time}`);
|
|
269
|
+
}
|
|
270
|
+
const passStart = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.start_date);
|
|
271
|
+
if (passStart && (!startTime || dayjs(passStart).isAfter(startTime))) startTime = dayjs(passStart);
|
|
272
|
+
const summary = generateSummaryText(schedule, startTime ? isTimeStarted(now, startTime) : false, locale, validity);
|
|
273
|
+
if (summary === getText(locale, "noAvailableDates")) {
|
|
274
|
+
var _schedule$repeat_rule;
|
|
275
|
+
const included = (_schedule$repeat_rule = schedule.repeat_rule) === null || _schedule$repeat_rule === void 0 || (_schedule$repeat_rule = _schedule$repeat_rule.included_date) === null || _schedule$repeat_rule === void 0 ? void 0 : _schedule$repeat_rule.filter((item) => !getWalletValidityRange(item.start, item.end, validity).isEmpty);
|
|
276
|
+
if (included === null || included === void 0 ? void 0 : included.length) return getScheduleSummary([_objectSpread2(_objectSpread2({}, schedule), {}, {
|
|
277
|
+
start_time: null,
|
|
278
|
+
end_time: null,
|
|
279
|
+
type: "designation",
|
|
280
|
+
repeat_type: "none",
|
|
281
|
+
repeat_rule: null,
|
|
282
|
+
is_all: 1,
|
|
283
|
+
designation: included.map((item) => ({
|
|
284
|
+
start_date: item.start,
|
|
285
|
+
end_date: item.end,
|
|
286
|
+
start_time: "00:00",
|
|
287
|
+
end_time: "23:59"
|
|
288
|
+
}))
|
|
289
|
+
})], locale, validity);
|
|
290
|
+
}
|
|
291
|
+
return summary;
|
|
292
|
+
} catch (error) {
|
|
293
|
+
console.warn("Error in getScheduleSummary:", error);
|
|
294
|
+
return "";
|
|
295
|
+
}
|
|
275
296
|
}
|
|
276
|
-
|
|
277
297
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
298
|
+
* 判断开始时间是否在当前时间之后
|
|
299
|
+
* @param now 当前时间
|
|
300
|
+
* @param startTime 开始时间
|
|
301
|
+
* @returns 是否已开始
|
|
302
|
+
*/
|
|
283
303
|
function isTimeStarted(now, startTime) {
|
|
284
|
-
|
|
304
|
+
return startTime.isBefore(now);
|
|
285
305
|
}
|
|
286
|
-
|
|
287
306
|
/**
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
function generateSummaryText(schedule, isStarted, locale) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (schedule.repeat_type !== 'none' && schedule.repeat_rule) {
|
|
312
|
-
return generateRecurringSummary(schedule, isStarted, locale);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// 4. 单个日程(包括designation类型的单个日期段)
|
|
316
|
-
return generateSingleScheduleSummary(schedule, isStarted, locale);
|
|
307
|
+
* 生成摘要文本
|
|
308
|
+
* @param schedule 日程对象
|
|
309
|
+
* @param isStarted 是否已开始
|
|
310
|
+
* @param locale 语言设置
|
|
311
|
+
* @returns 生成的摘要文本
|
|
312
|
+
*/
|
|
313
|
+
function generateSummaryText(schedule, isStarted, locale, validity) {
|
|
314
|
+
if (schedule.type === "designation" && schedule.designation && schedule.designation.length > 1) {
|
|
315
|
+
const passRange = getWalletValidityRange(null, null, validity);
|
|
316
|
+
if (!passRange.startDate && !passRange.endDate) return getText(locale, "multipleRules");
|
|
317
|
+
const designation = schedule.designation.filter((item) => !getWalletValidityRange(item.start_date, item.end_date, validity).isEmpty);
|
|
318
|
+
if (!designation.length) return getText(locale, "noAvailableDates");
|
|
319
|
+
if (designation.length === 1) return generateSingleScheduleSummary(_objectSpread2(_objectSpread2({}, schedule), {}, { designation }), isStarted, locale, validity);
|
|
320
|
+
const range = getWalletValidityRange(designation.map((item) => item.start_date).sort()[0], designation.map((item) => item.end_date).sort().pop(), validity);
|
|
321
|
+
return `${range.endDate ? `${formatDateRange(range.startDate || "", range.endDate, isStarted, locale, true)}${getText(locale, "periodSeparator")}` : ""}${getText(locale, "multipleRules")}`;
|
|
322
|
+
}
|
|
323
|
+
if (schedule.type === "time-slots") {
|
|
324
|
+
const range = getWalletValidityRange(schedule.start_time, getScheduleEndDate(schedule), validity);
|
|
325
|
+
if (range.isEmpty) return getText(locale, "noAvailableDates");
|
|
326
|
+
return `${range.endDate ? formatDateTime(range.endDate, true, locale) : getText(locale, "unlimited")}${getText(locale, "multipleSlots")}`;
|
|
327
|
+
}
|
|
328
|
+
if (schedule.repeat_type !== "none" && schedule.repeat_rule) return generateRecurringSummary(schedule, isStarted, locale, validity);
|
|
329
|
+
return generateSingleScheduleSummary(schedule, isStarted, locale, validity);
|
|
317
330
|
}
|
|
318
|
-
|
|
319
331
|
/**
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
function generateRecurringSummary(schedule, isStarted, locale) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
var frequencyText = getDailyFrequencyText(frequency, locale);
|
|
347
|
-
var dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true);
|
|
348
|
-
return "".concat(dateRange, "\uFF0C").concat(frequencyText);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// 按周循环
|
|
352
|
-
if (repeat_type === 'weekly') {
|
|
353
|
-
var weekdaysText = getWeekdayText(frequency_date, locale, '/');
|
|
354
|
-
var frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
355
|
-
var config = getConfig(locale);
|
|
356
|
-
var _dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true);
|
|
357
|
-
return "".concat(_dateRange, "\uFF0C").concat(frequencyPrefix).concat(config.weekPrefix).concat(weekdaysText);
|
|
358
|
-
}
|
|
359
|
-
return '';
|
|
332
|
+
* 生成循环日程摘要
|
|
333
|
+
* @param schedule 日程对象
|
|
334
|
+
* @param isStarted 是否已开始
|
|
335
|
+
* @param locale 语言设置
|
|
336
|
+
* @returns 循环日程摘要文本
|
|
337
|
+
*/
|
|
338
|
+
function generateRecurringSummary(schedule, isStarted, locale, validity) {
|
|
339
|
+
const { repeat_type, repeat_rule } = schedule;
|
|
340
|
+
if (!repeat_rule) return "";
|
|
341
|
+
const { frequency, frequency_date, end } = repeat_rule;
|
|
342
|
+
const range = getWalletValidityRange(schedule.start_time, getScheduleEndDate(schedule), validity);
|
|
343
|
+
if (range.isEmpty) return getText(locale, "noAvailableDates");
|
|
344
|
+
if (end.type === "never" && !range.endDate) return generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeat_type, frequency, frequency_date, validity);
|
|
345
|
+
const endDate = range.endDate;
|
|
346
|
+
if (!endDate) return "";
|
|
347
|
+
if (repeat_type === "daily") {
|
|
348
|
+
const frequencyText = getDailyFrequencyText(frequency, locale);
|
|
349
|
+
return `${formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity)}${getText(locale, "timeSlotSeparator")}${frequencyText}`;
|
|
350
|
+
}
|
|
351
|
+
if (repeat_type === "weekly") {
|
|
352
|
+
const weekdaysText = getWeekdayText(frequency_date, locale, "/");
|
|
353
|
+
const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
354
|
+
const config = getConfig(locale);
|
|
355
|
+
return `${formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity)}${config.timeSlotSeparator}${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
|
|
356
|
+
}
|
|
357
|
+
return "";
|
|
360
358
|
}
|
|
361
|
-
|
|
362
359
|
/**
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
function generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeatType, frequency, frequencyDate) {
|
|
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
|
-
var weekdaysText = getWeekdayText(frequencyDate, locale, locale === 'en' ? ' & ' : '/');
|
|
398
|
-
if (frequency === 1) {
|
|
399
|
-
// 频率=1:中文"每周三/五可用",英文"on Wed & Fri"
|
|
400
|
-
if (locale === 'en') {
|
|
401
|
-
return "".concat(config.on).concat(weekdaysText);
|
|
402
|
-
} else {
|
|
403
|
-
return "".concat(config.everyPrefix).concat(config.weekPrefix).concat(weekdaysText).concat(config.available);
|
|
404
|
-
}
|
|
405
|
-
} else {
|
|
406
|
-
// 频率>1:中文"每2周 周三/五",英文"Every 2 weeks, on Wed & Fri"
|
|
407
|
-
var frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
408
|
-
if (locale === 'en') {
|
|
409
|
-
return "".concat(frequencyPrefix).concat(config.on).concat(weekdaysText);
|
|
410
|
-
} else {
|
|
411
|
-
return "".concat(frequencyPrefix).concat(config.weekPrefix).concat(weekdaysText);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
return '';
|
|
360
|
+
* 生成永不结束的循环日程摘要
|
|
361
|
+
* @param schedule 日程对象
|
|
362
|
+
* @param isStarted 是否已开始
|
|
363
|
+
* @param locale 语言设置
|
|
364
|
+
* @param repeatType 循环类型
|
|
365
|
+
* @param frequency 频率
|
|
366
|
+
* @param frequencyDate 频率日期数组(用于周循环)
|
|
367
|
+
* @returns 永不结束的循环日程摘要文本
|
|
368
|
+
*/
|
|
369
|
+
function generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeatType, frequency, frequencyDate, validity) {
|
|
370
|
+
const config = getConfig(locale);
|
|
371
|
+
if (repeatType === "daily") if (frequency === 1) {
|
|
372
|
+
const range = getWalletValidityRange(schedule.start_time, null, validity);
|
|
373
|
+
if (range.startDate) {
|
|
374
|
+
const startDateStr = formatDateTime(range.startDate, true, locale);
|
|
375
|
+
return `${config.longTermValidFrom}${startDateStr}${config.noExpiry}`;
|
|
376
|
+
}
|
|
377
|
+
return "";
|
|
378
|
+
} else {
|
|
379
|
+
const frequencyText = getDailyFrequencyText(frequency, locale);
|
|
380
|
+
if (locale === "en") return `${frequencyText}`;
|
|
381
|
+
else return `${frequencyText}${config.available}`;
|
|
382
|
+
}
|
|
383
|
+
if (repeatType === "weekly") {
|
|
384
|
+
const weekdaysText = getWeekdayText(frequencyDate, locale, locale === "en" ? " & " : "/");
|
|
385
|
+
if (frequency === 1) if (locale === "en") return `${config.on}${weekdaysText}`;
|
|
386
|
+
else return `${config.everyPrefix}${config.weekPrefix}${weekdaysText}${config.available}`;
|
|
387
|
+
else {
|
|
388
|
+
const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
|
|
389
|
+
if (locale === "en") return `${frequencyPrefix}${config.on}${weekdaysText}`;
|
|
390
|
+
else return `${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return "";
|
|
416
394
|
}
|
|
417
|
-
|
|
418
395
|
/**
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
function generateSingleScheduleSummary(schedule, isStarted, locale) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
} else {
|
|
442
|
-
// 非全天日程
|
|
443
|
-
var startDateTime = "".concat(startDate, " ").concat(startTime).concat(CONSTANTS.SECONDS_SUFFIX);
|
|
444
|
-
var endDateTime = "".concat(endDate, " ").concat(endTime).concat(CONSTANTS.SECONDS_SUFFIX);
|
|
445
|
-
return formatDateRange(startDateTime, endDateTime, isStarted, locale, false);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// 标准日程处理
|
|
450
|
-
if (isAllDay) {
|
|
451
|
-
// 全天日程
|
|
452
|
-
var _endDate = getScheduleEndDate(schedule);
|
|
453
|
-
if (!_endDate) return '';
|
|
454
|
-
return formatDateRange(schedule.start_time, _endDate, isStarted, locale, true);
|
|
455
|
-
} else {
|
|
456
|
-
// 非全天日程
|
|
457
|
-
return formatDateRange(schedule.start_time, schedule.end_time, isStarted, locale, false);
|
|
458
|
-
}
|
|
396
|
+
* 生成单个日程摘要
|
|
397
|
+
* @param schedule 日程对象
|
|
398
|
+
* @param isStarted 是否已开始
|
|
399
|
+
* @param locale 语言设置
|
|
400
|
+
* @returns 单个日程摘要文本
|
|
401
|
+
*/
|
|
402
|
+
function generateSingleScheduleSummary(schedule, isStarted, locale, validity) {
|
|
403
|
+
const isAllDay = schedule.is_all === 1;
|
|
404
|
+
if (schedule.type === "designation" && schedule.designation && schedule.designation.length === 1) {
|
|
405
|
+
const designation = schedule.designation[0];
|
|
406
|
+
const startDate = designation.start_date;
|
|
407
|
+
const endDate = designation.end_date;
|
|
408
|
+
const startTime = designation.start_time;
|
|
409
|
+
const endTime = designation.end_time;
|
|
410
|
+
if (isAllDaySchedule(startTime, endTime) || isAllDay) return formatDateRange(startDate, endDate, isStarted, locale, true, validity);
|
|
411
|
+
else return formatDateRange(`${startDate} ${startTime}${CONSTANTS.SECONDS_SUFFIX}`, `${endDate} ${endTime}${CONSTANTS.SECONDS_SUFFIX}`, isStarted, locale, false, validity);
|
|
412
|
+
}
|
|
413
|
+
if (isAllDay) {
|
|
414
|
+
const endDate = getScheduleEndDate(schedule);
|
|
415
|
+
if (!endDate) return "";
|
|
416
|
+
return formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity);
|
|
417
|
+
} else return formatDateRange(schedule.start_time, schedule.end_time, isStarted, locale, false, validity);
|
|
459
418
|
}
|
|
460
|
-
|
|
461
419
|
/**
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
420
|
+
* 获取日程结束日期
|
|
421
|
+
* @param schedule 日程对象
|
|
422
|
+
* @returns 结束日期字符串,如果无法确定则返回null
|
|
423
|
+
*/
|
|
466
424
|
function getScheduleEndDate(schedule) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if (schedule.end_time) {
|
|
487
|
-
return schedule.end_time;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// time-slots类型
|
|
491
|
-
if (schedule.start_time) {
|
|
492
|
-
return schedule.start_time;
|
|
493
|
-
}
|
|
494
|
-
return null;
|
|
495
|
-
} catch (error) {
|
|
496
|
-
console.warn('Error in getScheduleEndDate:', error);
|
|
497
|
-
return null;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
425
|
+
try {
|
|
426
|
+
if (schedule.repeat_rule) {
|
|
427
|
+
if (schedule.repeat_rule.end.type === "never") return null;
|
|
428
|
+
else if (schedule.repeat_rule.end.end_date) return `${schedule.repeat_rule.end.end_date} ${CONSTANTS.ALL_DAY_END}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
429
|
+
}
|
|
430
|
+
if (schedule.designation && schedule.designation.length > 0) {
|
|
431
|
+
const lastDesignation = schedule.designation[schedule.designation.length - 1];
|
|
432
|
+
return `${lastDesignation.end_date} ${lastDesignation.end_time}${CONSTANTS.SECONDS_SUFFIX}`;
|
|
433
|
+
}
|
|
434
|
+
if (schedule.end_time) return schedule.end_time;
|
|
435
|
+
if (schedule.start_time) return schedule.start_time;
|
|
436
|
+
return null;
|
|
437
|
+
} catch (error) {
|
|
438
|
+
console.warn("Error in getScheduleEndDate:", error);
|
|
439
|
+
return null;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
//#endregion
|
|
443
|
+
export { getScheduleSummary, getWalletValidityRange };
|