@revolugo/common 7.4.1-rc.2 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolugo/common",
3
- "version": "7.4.1-rc.2",
3
+ "version": "7.4.1-rc.3",
4
4
  "private": false,
5
5
  "description": "Revolugo common",
6
6
  "author": "Revolugo",
@@ -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 = dayjs
184
- .tz(cp.dateFrom, timezone)
185
- .utc(isUTCDate(cp.dateFrom))
186
- .utc()
187
- .format()
188
-
189
- cp.dateTo = dayjs
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
  })