@revolugo/common 7.4.1-rc.1 → 7.4.1-rc.3
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/package.json +1 -1
- package/src/cancellation-policies.ts +11 -15
package/package.json
CHANGED
|
@@ -4,16 +4,16 @@ import { isEmpty } from './utils/is-empty.ts'
|
|
|
4
4
|
|
|
5
5
|
import type { ICancellationPolicy } from './types/cancellation-policy.ts'
|
|
6
6
|
|
|
7
|
-
function nextDay(date: string) {
|
|
8
|
-
return dayjs(date).add(1, 'day').utc().format()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
7
|
function isUTCDate(date: string) {
|
|
12
8
|
return /\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3])(?::[0-5]\d){2}(?:\.\d+|)(?:Z|[+-]\d{2}:?\d{2})/u.test(
|
|
13
9
|
date,
|
|
14
10
|
)
|
|
15
11
|
}
|
|
16
12
|
|
|
13
|
+
function nextDay(date: string) {
|
|
14
|
+
return dayjs(date).add(1, 'day').utc().format()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
function filterMatchingCancellationPolicies({
|
|
18
18
|
cancellationPolicies,
|
|
19
19
|
date,
|
|
@@ -180,17 +180,13 @@ export function sanitizeCancellationPolicies({
|
|
|
180
180
|
.filter(cp => dayjs(cp.dateTo).diff(dayjs(cp.dateFrom), 'minutes') >= 20)
|
|
181
181
|
.sort((a, b) => (dayjs(a.dateFrom).isAfter(dayjs(b.dateFrom)) ? 1 : -1))
|
|
182
182
|
.map(cp => {
|
|
183
|
-
cp.dateFrom =
|
|
184
|
-
|
|
185
|
-
.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
.tz(cp.dateTo, timezone)
|
|
191
|
-
.utc(isUTCDate(cp.dateTo))
|
|
192
|
-
.utc()
|
|
193
|
-
.format()
|
|
183
|
+
cp.dateFrom = isUTCDate(cp.dateFrom)
|
|
184
|
+
? dayjs(cp.dateFrom).utc().format()
|
|
185
|
+
: dayjs.tz(cp.dateFrom, timezone).utc().format()
|
|
186
|
+
|
|
187
|
+
cp.dateTo = isUTCDate(cp.dateTo)
|
|
188
|
+
? dayjs(cp.dateTo).utc().format()
|
|
189
|
+
: dayjs.tz(cp.dateTo, timezone).utc().format()
|
|
194
190
|
|
|
195
191
|
return cp
|
|
196
192
|
})
|