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