@ancon/wildcat-utils 1.44.0-r13-2-tz.85 → 1.44.0-r13-2-tz.87
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/date/convertToLocalTimezone.d.ts +0 -1
- package/date/convertToSpecificTimezone.d.ts +1 -2
- package/date/convertToSpecificTimezone.js +1 -1
- package/date/convertToSpecificTimezone.mjs +3 -4
- package/date/getTimezoneUtcOffsetDifference.d.ts +0 -1
- package/date/isDSTShiftPresentInRange.d.ts +0 -1
- package/outlet/getOutletNextReadyToOrderTime.d.ts +1 -1
- package/outlet/getOutletNextReadyToOrderTime.js +1 -1
- package/outlet/getOutletNextReadyToOrderTime.mjs +30 -36
- package/outlet/getOutletPickerTimesForDay.js +1 -1
- package/outlet/getOutletPickerTimesForDay.mjs +62 -79
- package/outlet/getOutletPickerTimesForWeek.js +1 -1
- package/outlet/getOutletPickerTimesForWeek.mjs +11 -12
- package/outlet/getOutletTagInformation.js +1 -1
- package/outlet/getOutletTagInformation.mjs +10 -15
- package/outlet/getTimezoneAdjustedServiceInterval.d.ts +0 -1
- package/outlet/searchNextOpeningMoment.js +1 -1
- package/outlet/searchNextOpeningMoment.mjs +15 -15
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import moment, { Moment } from 'moment';
|
|
2
2
|
/**
|
|
3
3
|
* This function converts a given moment object to the local timezone by adjusting the UTC offset.
|
|
4
|
-
*
|
|
5
4
|
* @param dateTimeMoment The moment object to convert to the local timezone.
|
|
6
5
|
* @param keepLocalTime Optional flag that specifies whether the offset would be changed without modifying the actual time itself.
|
|
7
6
|
* @returns The moment object converted to the local timezone.
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Moment } from 'moment';
|
|
2
2
|
/**
|
|
3
3
|
* This function converts a given date time moment to a specific timezone.
|
|
4
|
-
*
|
|
5
4
|
* @param dateTimeMoment The date time moment to convert
|
|
6
5
|
* @param timezoneOffset The specific timezone offset
|
|
7
6
|
* @param keepLocalTime An optional flag that specifies whether the offset would be changed without modifying the actual time itself.
|
|
8
7
|
* @returns The converted date time moment
|
|
9
8
|
*/
|
|
10
|
-
export default function convertToSpecificTimezone(dateTimeMoment: Moment, timezoneOffset: number, keepLocalTime?: boolean
|
|
9
|
+
export default function convertToSpecificTimezone(dateTimeMoment: Moment, timezoneOffset: number, keepLocalTime?: boolean): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function
|
|
1
|
+
"use strict";function u(f,c,t){return f.utcOffset()-c?f.clone().utcOffset(c,t):f}module.exports=u;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
return u && (console.log("dateTimeMoment", f.format()), console.log("timezoneOffset, utcOffsetDiff", c, o)), o ? f.clone().utcOffset(c, t) : f;
|
|
1
|
+
function r(f, c, t) {
|
|
2
|
+
return f.utcOffset() - c ? f.clone().utcOffset(c, t) : f;
|
|
4
3
|
}
|
|
5
4
|
export {
|
|
6
|
-
|
|
5
|
+
r as default
|
|
7
6
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MomentInput } from 'moment';
|
|
2
2
|
/**
|
|
3
3
|
* This function gets the difference between the UTC offsets of two moment inputs.
|
|
4
|
-
*
|
|
5
4
|
* @param momentInputA The first moment input
|
|
6
5
|
* @param momentInputB The second moment input
|
|
7
6
|
* @returns The difference between the UTC offsets of the two moment inputs
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MomentInput } from 'moment';
|
|
2
2
|
/**
|
|
3
3
|
* This function checks if a DST shift is present in the given date time range.
|
|
4
|
-
*
|
|
5
4
|
* @param start The start date time of the range
|
|
6
5
|
* @param start The end date time of the range
|
|
7
6
|
* @returns A boolean indicating if a DST shift is present in the given date time range
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OrderFormat, OutletListItem } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
|
-
export default function getOutletNextReadyToOrderTime(outlet: OutletListItem, orderFormat: OrderFormat
|
|
3
|
+
export default function getOutletNextReadyToOrderTime(outlet: OutletListItem, orderFormat: OrderFormat): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const p=require("@ancon/wildcat-types"),i=require("moment"),x=require("../date/getTimezoneUtcOffsetDifference.js"),v=require("../time/getNextTenthMinute.js"),_=require("./getSettingsForOrderFormat.js"),I=require("./isOutletAcceptingPreOrders.js"),S=require("./getOutletTagInformation.js"),M=require("./getServiceIntervalsForOrderFormat.js"),h=require("./getOutletNextServiceTimeOffset.js");require("../date/createLocalTimezoneMoment.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getTimezoneAdjustedServiceInterval.js");require("../time/getTimeSpanParts.js");require("../date/convertToSpecificTimezone.js");require("./getServiceIntervalTimeSpanMoment.js");require("./searchNextOpeningMoment.js");function y(e,r){const c=(e==null?void 0:e.state)===p.OutletState.Opened,t=_(r,e==null?void 0:e.orderFormatSettings),d=(t==null?void 0:t.preparationTime)??"00:00:00",u=I((e==null?void 0:e.orderFormatSettings)||[]),g=M(r,(e==null?void 0:e.serviceDateTimes)||[]),o=S.default(g,c,i(),i()),T=!c&&u&&o.openingTime?o.openingTime:void 0,f=i(),s=i(T),n=(f>s?f:s).clone(),q=n.utcOffset();n.seconds(0).milliseconds(0).utcOffset(q,!0);const O=h(r,d,e==null?void 0:e.deliveryIntegrationEnabled);O>0&&n.add(O,"minutes");const m=v(n)-n.minutes();m&&n.add(m,"minutes");const a=x(s,n);return a&&n.add(a,"minutes"),n}module.exports=y;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { OutletState as
|
|
2
|
-
import
|
|
1
|
+
import { OutletState as v } from "@ancon/wildcat-types";
|
|
2
|
+
import n from "moment";
|
|
3
3
|
import I from "../date/getTimezoneUtcOffsetDifference.mjs";
|
|
4
4
|
import S from "../time/getNextTenthMinute.mjs";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
5
|
+
import M from "./getSettingsForOrderFormat.mjs";
|
|
6
|
+
import h from "./isOutletAcceptingPreOrders.mjs";
|
|
7
|
+
import D from "./getOutletTagInformation.mjs";
|
|
8
|
+
import F from "./getServiceIntervalsForOrderFormat.mjs";
|
|
9
|
+
import N from "./getOutletNextServiceTimeOffset.mjs";
|
|
10
10
|
import "../date/createLocalTimezoneMoment.mjs";
|
|
11
11
|
import "./constants.mjs";
|
|
12
12
|
import "./getOutletCurrentActiveOperatingHour.mjs";
|
|
@@ -15,42 +15,36 @@ import "../time/getTimeSpanParts.mjs";
|
|
|
15
15
|
import "../date/convertToSpecificTimezone.mjs";
|
|
16
16
|
import "./getServiceIntervalTimeSpanMoment.mjs";
|
|
17
17
|
import "./searchNextOpeningMoment.mjs";
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
f,
|
|
18
|
+
function J(e, t) {
|
|
19
|
+
const s = (e == null ? void 0 : e.state) === v.Opened, r = M(
|
|
20
|
+
t,
|
|
22
21
|
e == null ? void 0 : e.orderFormatSettings
|
|
23
|
-
),
|
|
22
|
+
), a = (r == null ? void 0 : r.preparationTime) ?? "00:00:00", d = h(
|
|
24
23
|
(e == null ? void 0 : e.orderFormatSettings) || []
|
|
25
|
-
),
|
|
26
|
-
|
|
24
|
+
), g = F(
|
|
25
|
+
t,
|
|
27
26
|
(e == null ? void 0 : e.serviceDateTimes) || []
|
|
28
|
-
),
|
|
29
|
-
|
|
27
|
+
), o = D(
|
|
28
|
+
g,
|
|
29
|
+
s,
|
|
30
|
+
n(),
|
|
31
|
+
n()
|
|
32
|
+
), T = !s && d && o.openingTime ? o.openingTime : void 0, f = n(), m = n(T), i = (f > m ? f : m).clone(), x = i.utcOffset();
|
|
33
|
+
i.seconds(0).milliseconds(0).utcOffset(x, !0);
|
|
34
|
+
const p = N(
|
|
35
|
+
t,
|
|
30
36
|
a,
|
|
31
|
-
m(),
|
|
32
|
-
m()
|
|
33
|
-
), r = !a && x && c.openingTime ? c.openingTime : void 0, t = m(), o = m(r);
|
|
34
|
-
i && (console.log(
|
|
35
|
-
"tag info - openingTime",
|
|
36
|
-
(d = c.openingTime) == null ? void 0 : d.format()
|
|
37
|
-
), console.log("nextOpeningTime", r == null ? void 0 : r.format()), console.log("now, next", t.format(), o.format()));
|
|
38
|
-
const n = (t > o ? t : o).clone();
|
|
39
|
-
i && console.log("now, next", t.format(), o.format()), n.hours(n.hours()).minutes(n.minutes()).seconds(0).milliseconds(0), i && console.log("nextOrderTime", n.format());
|
|
40
|
-
const g = F(
|
|
41
|
-
f,
|
|
42
|
-
T,
|
|
43
37
|
e == null ? void 0 : e.deliveryIntegrationEnabled
|
|
44
38
|
);
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
p > 0 && i.add(p, "minutes");
|
|
40
|
+
const c = S(i) - i.minutes();
|
|
41
|
+
c && i.add(c, "minutes");
|
|
42
|
+
const O = I(
|
|
43
|
+
m,
|
|
44
|
+
i
|
|
51
45
|
);
|
|
52
|
-
return
|
|
46
|
+
return O && i.add(O, "minutes"), i;
|
|
53
47
|
}
|
|
54
48
|
export {
|
|
55
|
-
|
|
49
|
+
J as default
|
|
56
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const g=require("@ancon/wildcat-types"),m=require("moment"),y=require("../date/isDSTShiftPresentInRange.js"),D=require("./getPickerIntervalsForDay.js"),P=require("./getSettingsForOrderFormat.js"),_=require("./getServiceIntervalStart.js"),k=require("./types.js"),I=require("./generatePickerTimesForDay.js"),b=require("./getServiceIntervalEnd.js"),x=require("./getOutletNextReadyToOrderTime.js");require("../date/getTimezoneUtcOffsetDifference.js");require("../shared/constants.js");require("../date/createLocalTimezoneMoment.js");require("./getServiceIntervalsForOrderFormat.js");require("../time/getTimeSpanParts.js");require("../time/getNextTenthMinute.js");require("./getServiceIntervalTimeSpanMoment.js");require("./hoursAndMinutesToMinutes.js");require("./isOutletAcceptingPreOrders.js");require("./getOutletTagInformation.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getTimezoneAdjustedServiceInterval.js");require("../date/convertToSpecificTimezone.js");require("./searchNextOpeningMoment.js");require("./getOutletNextServiceTimeOffset.js");function R(s,T,h,O){const{preparationTime:p="00:00:00"}=P(T,s==null?void 0:s.orderFormatSettings)??{},c=x(s,T);let u=c.clone();const o=m(h);if(o>c)u=c.clone().set({year:o.year(),month:o.month(),date:o.date()});else if(c.diff(o,"day")>0)return[];let e=[];const v=D(u,s==null?void 0:s.serviceDateTimes,T);let S;if(v.forEach(r=>{!S&&r.type&&(e=[]);const i=_(u,r,p),d=b(u,r,p);i<c&&i.add(c.valueOf()-i.valueOf(),"millisecond");const n=I(i,d,e,void 0,O);if(n.length>0)switch(r.state){case g.IntervalState.Closed:{const a=n[0],f=n[n.length-1];e=e.filter(({timestamp:t})=>t<a.timestamp||t>f.timestamp);break}case g.IntervalState.Opened:default:{let a=n;y(i,d)&&(a=n.filter(t=>{const l=m(t.timestamp).utc(!0),q=m(i).utc(!0);return l.isSameOrAfter(q)})),e=e.concat(a);break}}S=r.type}),e.length){const r=e[0],i=e[e.length-1];if(y(r.timestamp,i.timestamp)){const n=Math.max(m(r.timestamp).utcOffset(),m(i.timestamp).utcOffset()),a=e.map(t=>t.timeLabel),f=a.filter((t,l)=>a.indexOf(t)!==l);return e.map(t=>{if(f.includes(t.timeLabel)){const q=m(t.timestamp).utcOffset()===n?k.PickerTimeTimezoneTag.Summer:k.PickerTimeTimezoneTag.Standard;return{...t,timezoneTag:q}}return t})}}return e}module.exports=R;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { IntervalState as h } from "@ancon/wildcat-types";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { PickerTimeTimezoneTag as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
2
|
+
import s from "moment";
|
|
3
|
+
import k from "../date/isDSTShiftPresentInRange.mjs";
|
|
4
|
+
import P from "./getPickerIntervalsForDay.mjs";
|
|
5
|
+
import b from "./getSettingsForOrderFormat.mjs";
|
|
6
|
+
import x from "./getServiceIntervalStart.mjs";
|
|
7
|
+
import { PickerTimeTimezoneTag as y } from "./types.mjs";
|
|
8
|
+
import I from "./generatePickerTimesForDay.mjs";
|
|
9
|
+
import R from "./getServiceIntervalEnd.mjs";
|
|
10
|
+
import F from "./getOutletNextReadyToOrderTime.mjs";
|
|
11
11
|
import "../date/getTimezoneUtcOffsetDifference.mjs";
|
|
12
12
|
import "../shared/constants.mjs";
|
|
13
13
|
import "../date/createLocalTimezoneMoment.mjs";
|
|
@@ -24,110 +24,93 @@ import "./getTimezoneAdjustedServiceInterval.mjs";
|
|
|
24
24
|
import "../date/convertToSpecificTimezone.mjs";
|
|
25
25
|
import "./searchNextOpeningMoment.mjs";
|
|
26
26
|
import "./getOutletNextServiceTimeOffset.mjs";
|
|
27
|
-
function
|
|
28
|
-
const { preparationTime:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
function it(n, T, O, D) {
|
|
28
|
+
const { preparationTime: g = "00:00:00" } = b(T, n == null ? void 0 : n.orderFormatSettings) ?? {}, a = F(n, T);
|
|
29
|
+
let f = a.clone();
|
|
30
|
+
const c = s(O);
|
|
31
|
+
if (c > a)
|
|
32
|
+
f = a.clone().set({
|
|
33
|
+
year: c.year(),
|
|
34
|
+
month: c.month(),
|
|
35
|
+
date: c.date()
|
|
36
|
+
});
|
|
37
|
+
else if (a.diff(c, "day") > 0)
|
|
38
|
+
return [];
|
|
39
|
+
let t = [];
|
|
40
|
+
const v = P(
|
|
41
|
+
f,
|
|
42
|
+
n == null ? void 0 : n.serviceDateTimes,
|
|
43
|
+
T
|
|
32
44
|
);
|
|
33
|
-
|
|
34
|
-
let p = a.clone();
|
|
35
|
-
const s = f(k);
|
|
36
|
-
if (console.log("specificDateMoment", s.format()), s > a)
|
|
37
|
-
p = a.clone().set({
|
|
38
|
-
year: s.year(),
|
|
39
|
-
month: s.month(),
|
|
40
|
-
date: s.date()
|
|
41
|
-
}), console.log("specificDateMoment > nextReadyOrderTime", p.format());
|
|
42
|
-
else {
|
|
43
|
-
const i = a.diff(s, "day");
|
|
44
|
-
if (console.log("ELSE specificDateMoment > nextReadyOrderTime", i), i > 0)
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
let e = [];
|
|
48
|
-
const v = x(
|
|
49
|
-
p,
|
|
50
|
-
o == null ? void 0 : o.serviceDateTimes,
|
|
51
|
-
g
|
|
52
|
-
);
|
|
53
|
-
let y;
|
|
45
|
+
let u;
|
|
54
46
|
if (v.forEach((i) => {
|
|
55
|
-
!
|
|
56
|
-
const r =
|
|
57
|
-
|
|
47
|
+
!u && i.type && (t = []);
|
|
48
|
+
const r = x(
|
|
49
|
+
f,
|
|
58
50
|
i,
|
|
59
|
-
|
|
60
|
-
), d =
|
|
61
|
-
|
|
51
|
+
g
|
|
52
|
+
), d = R(
|
|
53
|
+
f,
|
|
62
54
|
i,
|
|
63
|
-
|
|
55
|
+
g
|
|
64
56
|
);
|
|
65
|
-
|
|
66
|
-
"intervalStartTime, intervalEndTime",
|
|
67
|
-
r.format(),
|
|
68
|
-
d.format()
|
|
69
|
-
), r < a && (console.log("Add the time that has already passed today"), r.add(
|
|
57
|
+
r < a && r.add(
|
|
70
58
|
a.valueOf() - r.valueOf(),
|
|
71
59
|
"millisecond"
|
|
72
|
-
)
|
|
73
|
-
const m =
|
|
60
|
+
);
|
|
61
|
+
const m = I(
|
|
74
62
|
r,
|
|
75
63
|
d,
|
|
76
|
-
|
|
64
|
+
t,
|
|
77
65
|
void 0,
|
|
78
66
|
D
|
|
79
67
|
);
|
|
80
68
|
if (m.length > 0)
|
|
81
69
|
switch (i.state) {
|
|
82
70
|
case h.Closed: {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
({ timestamp:
|
|
71
|
+
const o = m[0], p = m[m.length - 1];
|
|
72
|
+
t = t.filter(
|
|
73
|
+
({ timestamp: e }) => e < o.timestamp || e > p.timestamp
|
|
86
74
|
);
|
|
87
75
|
break;
|
|
88
76
|
}
|
|
89
77
|
case h.Opened:
|
|
90
78
|
default: {
|
|
91
|
-
let
|
|
92
|
-
|
|
79
|
+
let o = m;
|
|
80
|
+
k(
|
|
93
81
|
r,
|
|
94
82
|
d
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"=>",
|
|
100
|
-
l.format(),
|
|
101
|
-
T.format()
|
|
102
|
-
), l.isSameOrAfter(T);
|
|
103
|
-
})), e = e.concat(n);
|
|
83
|
+
) && (o = m.filter((e) => {
|
|
84
|
+
const l = s(e.timestamp).utc(!0), S = s(r).utc(!0);
|
|
85
|
+
return l.isSameOrAfter(S);
|
|
86
|
+
})), t = t.concat(o);
|
|
104
87
|
break;
|
|
105
88
|
}
|
|
106
89
|
}
|
|
107
|
-
|
|
108
|
-
}),
|
|
109
|
-
const i =
|
|
110
|
-
if (
|
|
90
|
+
u = i.type;
|
|
91
|
+
}), t.length) {
|
|
92
|
+
const i = t[0], r = t[t.length - 1];
|
|
93
|
+
if (k(
|
|
111
94
|
i.timestamp,
|
|
112
95
|
r.timestamp
|
|
113
96
|
)) {
|
|
114
97
|
const m = Math.max(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
),
|
|
118
|
-
(
|
|
98
|
+
s(i.timestamp).utcOffset(),
|
|
99
|
+
s(r.timestamp).utcOffset()
|
|
100
|
+
), o = t.map((e) => e.timeLabel), p = o.filter(
|
|
101
|
+
(e, l) => o.indexOf(e) !== l
|
|
119
102
|
);
|
|
120
|
-
return
|
|
121
|
-
if (
|
|
122
|
-
const
|
|
123
|
-
return { ...
|
|
103
|
+
return t.map((e) => {
|
|
104
|
+
if (p.includes(e.timeLabel)) {
|
|
105
|
+
const S = s(e.timestamp).utcOffset() === m ? y.Summer : y.Standard;
|
|
106
|
+
return { ...e, timezoneTag: S };
|
|
124
107
|
}
|
|
125
|
-
return
|
|
108
|
+
return e;
|
|
126
109
|
});
|
|
127
110
|
}
|
|
128
111
|
}
|
|
129
|
-
return
|
|
112
|
+
return t;
|
|
130
113
|
}
|
|
131
114
|
export {
|
|
132
|
-
|
|
115
|
+
it as default
|
|
133
116
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const n=require("./getOutletNextReadyToOrderTime.js"),l=require("./getOutletPickerTimesForDay.js");require("@ancon/wildcat-types");require("moment");require("../date/getTimezoneUtcOffsetDifference.js");require("../time/getNextTenthMinute.js");require("./getSettingsForOrderFormat.js");require("./isOutletAcceptingPreOrders.js");require("./getOutletTagInformation.js");require("../date/createLocalTimezoneMoment.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getTimezoneAdjustedServiceInterval.js");require("../time/getTimeSpanParts.js");require("../date/convertToSpecificTimezone.js");require("./getServiceIntervalTimeSpanMoment.js");require("./searchNextOpeningMoment.js");require("./getServiceIntervalsForOrderFormat.js");require("./getOutletNextServiceTimeOffset.js");require("../date/isDSTShiftPresentInRange.js");require("./getPickerIntervalsForDay.js");require("../shared/constants.js");require("./getServiceIntervalStart.js");require("./types.js");require("./generatePickerTimesForDay.js");require("./getServiceIntervalEnd.js");require("./hoursAndMinutesToMinutes.js");function k(r,i,q){const c=n(r,i),u=[],t=c.clone();for(let e=0;e<7;e+=1)u.push(t.clone()),t.add(1,"day");return u.reduce((e,s)=>{const o=l(r,i,s,q);return e.push(o),e},[]).filter(e=>e.length>0)}module.exports=k;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import s from "./getOutletNextReadyToOrderTime.mjs";
|
|
2
2
|
import u from "./getOutletPickerTimesForDay.mjs";
|
|
3
3
|
import "@ancon/wildcat-types";
|
|
4
4
|
import "moment";
|
|
@@ -25,20 +25,19 @@ import "./types.mjs";
|
|
|
25
25
|
import "./generatePickerTimesForDay.mjs";
|
|
26
26
|
import "./getServiceIntervalEnd.mjs";
|
|
27
27
|
import "./hoursAndMinutesToMinutes.mjs";
|
|
28
|
-
function H(
|
|
29
|
-
const
|
|
28
|
+
function H(r, o, e) {
|
|
29
|
+
const m = s(r, o), i = [], p = m.clone();
|
|
30
30
|
for (let t = 0; t < 7; t += 1)
|
|
31
|
-
i.push(
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
o,
|
|
31
|
+
i.push(p.clone()), p.add(1, "day");
|
|
32
|
+
return i.reduce((t, c) => {
|
|
33
|
+
const n = u(
|
|
35
34
|
r,
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
o,
|
|
36
|
+
c,
|
|
37
|
+
e
|
|
38
38
|
);
|
|
39
|
-
return t.push(
|
|
40
|
-
}, []);
|
|
41
|
-
return console.log("getOutletPickerTimesForWeek"), console.log(m), m.filter((t) => t.length > 0);
|
|
39
|
+
return t.push(n), t;
|
|
40
|
+
}, []).filter((t) => t.length > 0);
|
|
42
41
|
}
|
|
43
42
|
export {
|
|
44
43
|
H as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@ancon/wildcat-types"),M=require("moment"),u=require("../date/createLocalTimezoneMoment.js"),p=require("./constants.js"),O=require("./getOutletCurrentActiveOperatingHour.js"),k=require("./searchNextOpeningMoment.js"),D=require("./getTimezoneAdjustedServiceInterval.js");require("../time/getTimeSpanParts.js");require("../date/getTimezoneUtcOffsetDifference.js");require("../date/convertToSpecificTimezone.js");require("./getServiceIntervalTimeSpanMoment.js");const m={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function q(n,e){const t=n.isSame(e,"d"),a={[e.format(p.OutletMapKeyFormatter)]:{intervals:[],exception:null,metadata:{dayOfWeek:m[e.isoWeekday()]}}};for(let s=t?1:0;s<p.OutletTimelineDayCount;s+=1){const i=M(n).add(s,"d");a[i.format(p.OutletMapKeyFormatter)]={intervals:[],exception:null,metadata:{dayOfWeek:m[i.isoWeekday()]}}}return a}function S(n,e){const t=u(e.periodFrom),o=u(e.periodTo);if(!t.isSame(o,"d"))Object.keys(n).forEach(s=>{const i=M(s);if(i.isSame(t,"d")||i.isSame(o,"d")||i.isBetween(t,o)){const l=n[s],c=l.exception?l.exception.position:0;e.position>c&&(l.exception=e)}});else{const s=t.format(p.OutletMapKeyFormatter),i=n[s];if(i){const y=i.exception?i.exception.position:0;e.position>y&&(i.exception=e)}}}function T(n,e){Object.keys(n).forEach(t=>{const o=n[t],{dayOfWeek:a}=o.metadata,{dayOfWeek:s}=e;(a&s)===a&&o.intervals.push(e)})}function I(n,e,t){const o=q(e,t);return n.forEach(a=>{a.type===g.IntervalType.Exception?S(o,a):T(o,a)}),o}function v(n,e,t,o){const a=I(n,t,o),s=o.format(p.OutletMapKeyFormatter),i=O(s,a[s],o)!==null,y=e;let l=null,c=null;if(e){const d=t.format(p.OutletMapKeyFormatter),f=O(d,a[d],t);if(f){const r=D(d,f,t.utcOffset());c=r.openingTime,l=r.closingTime}}else c=k(a,t);if(!e&&!c){const d=n.filter(r=>r.state&&u(r.periodTo).isAfter(t)),[f]=d.sort((r,x)=>o.valueOf()-(u(r.periodTo).valueOf()-u(x.periodTo).valueOf()));if(f)return v(n,e,u(f.periodTo),o)}return{closingTime:l,openingTime:c,openDuringSpecifiedTime:y,openNow:i}}exports.DaysOfWeekMap=m;exports.default=v;
|
|
@@ -48,8 +48,8 @@ function S(n, e) {
|
|
|
48
48
|
Object.keys(n).forEach((s) => {
|
|
49
49
|
const i = x(s);
|
|
50
50
|
if (i.isSame(t, "d") || i.isSame(o, "d") || i.isBetween(t, o)) {
|
|
51
|
-
const
|
|
52
|
-
e.position >
|
|
51
|
+
const p = n[s], c = p.exception ? p.exception.position : 0;
|
|
52
|
+
e.position > c && (p.exception = e);
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
else {
|
|
@@ -82,7 +82,7 @@ function E(n, e, t, o) {
|
|
|
82
82
|
a[s],
|
|
83
83
|
o
|
|
84
84
|
) !== null, u = e;
|
|
85
|
-
let
|
|
85
|
+
let p = null, c = null;
|
|
86
86
|
if (e) {
|
|
87
87
|
const m = t.format(d), f = y(
|
|
88
88
|
m,
|
|
@@ -90,25 +90,20 @@ function E(n, e, t, o) {
|
|
|
90
90
|
t
|
|
91
91
|
);
|
|
92
92
|
if (f) {
|
|
93
|
-
const
|
|
93
|
+
const r = M(
|
|
94
94
|
m,
|
|
95
95
|
f,
|
|
96
96
|
t.utcOffset()
|
|
97
97
|
);
|
|
98
|
-
|
|
99
|
-
"specificTime",
|
|
100
|
-
t.format(),
|
|
101
|
-
p.format(),
|
|
102
|
-
r.format()
|
|
103
|
-
);
|
|
98
|
+
c = r.openingTime, p = r.closingTime;
|
|
104
99
|
}
|
|
105
100
|
} else
|
|
106
|
-
|
|
107
|
-
if (!e && !
|
|
101
|
+
c = D(a, t);
|
|
102
|
+
if (!e && !c) {
|
|
108
103
|
const m = n.filter(
|
|
109
|
-
(
|
|
104
|
+
(r) => r.state && l(r.periodTo).isAfter(t)
|
|
110
105
|
), [f] = m.sort(
|
|
111
|
-
(
|
|
106
|
+
(r, v) => o.valueOf() - (l(r.periodTo).valueOf() - l(v.periodTo).valueOf())
|
|
112
107
|
);
|
|
113
108
|
if (f)
|
|
114
109
|
return E(
|
|
@@ -118,7 +113,7 @@ function E(n, e, t, o) {
|
|
|
118
113
|
o
|
|
119
114
|
);
|
|
120
115
|
}
|
|
121
|
-
return { closingTime:
|
|
116
|
+
return { closingTime: p, openingTime: c, openDuringSpecifiedTime: u, openNow: i };
|
|
122
117
|
}
|
|
123
118
|
export {
|
|
124
119
|
O as DaysOfWeekMap,
|
|
@@ -3,7 +3,6 @@ import { ServiceDateTimeInterval } from '@ancon/wildcat-types';
|
|
|
3
3
|
/**
|
|
4
4
|
* This function adjusts the service interval opening and closing time to the specified timezone,
|
|
5
5
|
* if opening and closing time are in different timezone offsets.
|
|
6
|
-
*
|
|
7
6
|
* @param date The date of the service interval
|
|
8
7
|
* @param interval The service interval object
|
|
9
8
|
* @param timezoneOffset The specific timezone offset. If not provided, the local timezone offset will be used.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const m=require("moment"),
|
|
1
|
+
"use strict";const m=require("moment"),O=require("@ancon/wildcat-types"),d=require("../time/getTimeSpanParts.js"),f=require("./constants.js"),c=require("./getTimezoneAdjustedServiceInterval.js");require("../date/getTimezoneUtcOffsetDifference.js");require("../date/convertToSpecificTimezone.js");require("./getServiceIntervalTimeSpanMoment.js");function p(u){let e=null;const{intervals:t,exception:n}=u;if(n){const{state:s}=n;s||(e=n)}else{const s=t.sort((o,i)=>d(o.from).hours-d(i.from).hours),[r]=s;return r}return e}function g(u,e,t){var s,r;const n=[];if(e.exception){if(e.exception.state===O.IntervalState.Opened){const i=c(u,e.exception,t.utcOffset()).openingTime;t.isBefore(i)&&n.push({interval:e.exception,moment:i})}}else for(let o=0;o<e.intervals.length;o+=1){const i=e.intervals[o],l=c(u,i,t.utcOffset()).openingTime;t.isBefore(l)&&n.push({interval:i,moment:l})}return n.length<2?((s=n[0])==null?void 0:s.interval)??null:((r=n.sort((o,i)=>o.moment-t-(i.moment-t))[0])==null?void 0:r.interval)??null}function v(u,e){let t=null;const n=m(e).format(f.OutletMapKeyFormatter),s=g(n,u[n],e);if(s&&(t=c(n,s,e.utcOffset()).openingTime),!t)for(let r=1;r<f.OutletTimelineDayCount;r+=1){const o=m(e).add(r,"d"),i=o.format(f.OutletMapKeyFormatter),a=u[i],l=p(a);if(l){t=c(i,l,o.utcOffset()).openingTime;break}}return t}module.exports=v;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import c from "moment";
|
|
2
|
-
import { IntervalState as
|
|
2
|
+
import { IntervalState as p } from "@ancon/wildcat-types";
|
|
3
3
|
import a from "../time/getTimeSpanParts.mjs";
|
|
4
|
-
import { OutletMapKeyFormatter as
|
|
5
|
-
import
|
|
4
|
+
import { OutletMapKeyFormatter as d, OutletTimelineDayCount as O } from "./constants.mjs";
|
|
5
|
+
import f from "./getTimezoneAdjustedServiceInterval.mjs";
|
|
6
6
|
import "../date/getTimezoneUtcOffsetDifference.mjs";
|
|
7
7
|
import "../date/convertToSpecificTimezone.mjs";
|
|
8
8
|
import "./getServiceIntervalTimeSpanMoment.mjs";
|
|
9
|
-
function
|
|
9
|
+
function g(l) {
|
|
10
10
|
let t = null;
|
|
11
11
|
const { intervals: e, exception: n } = l;
|
|
12
12
|
if (n) {
|
|
@@ -24,8 +24,8 @@ function v(l, t, e) {
|
|
|
24
24
|
var r, s;
|
|
25
25
|
const n = [];
|
|
26
26
|
if (t.exception) {
|
|
27
|
-
if (t.exception.state ===
|
|
28
|
-
const o =
|
|
27
|
+
if (t.exception.state === p.Opened) {
|
|
28
|
+
const o = f(
|
|
29
29
|
l,
|
|
30
30
|
t.exception,
|
|
31
31
|
e.utcOffset()
|
|
@@ -37,12 +37,12 @@ function v(l, t, e) {
|
|
|
37
37
|
}
|
|
38
38
|
} else
|
|
39
39
|
for (let i = 0; i < t.intervals.length; i += 1) {
|
|
40
|
-
const o = t.intervals[i],
|
|
40
|
+
const o = t.intervals[i], u = f(
|
|
41
41
|
l,
|
|
42
42
|
o,
|
|
43
43
|
e.utcOffset()
|
|
44
44
|
).openingTime;
|
|
45
|
-
|
|
45
|
+
e.isBefore(u) && n.push({ interval: o, moment: u });
|
|
46
46
|
}
|
|
47
47
|
return n.length < 2 ? ((r = n[0]) == null ? void 0 : r.interval) ?? null : ((s = n.sort(
|
|
48
48
|
// @ts-ignore TODO
|
|
@@ -51,22 +51,22 @@ function v(l, t, e) {
|
|
|
51
51
|
}
|
|
52
52
|
function K(l, t) {
|
|
53
53
|
let e = null;
|
|
54
|
-
const n = c(t).format(
|
|
54
|
+
const n = c(t).format(d), r = v(
|
|
55
55
|
n,
|
|
56
56
|
l[n],
|
|
57
57
|
t
|
|
58
58
|
);
|
|
59
|
-
if (
|
|
59
|
+
if (r && (e = f(
|
|
60
60
|
n,
|
|
61
61
|
r,
|
|
62
62
|
t.utcOffset()
|
|
63
63
|
).openingTime), !e)
|
|
64
|
-
for (let s = 1; s <
|
|
65
|
-
const i = c(t).add(s, "d"), o = i.format(
|
|
66
|
-
if (
|
|
67
|
-
e =
|
|
64
|
+
for (let s = 1; s < O; s += 1) {
|
|
65
|
+
const i = c(t).add(s, "d"), o = i.format(d), m = l[o], u = g(m);
|
|
66
|
+
if (u) {
|
|
67
|
+
e = f(
|
|
68
68
|
o,
|
|
69
|
-
|
|
69
|
+
u,
|
|
70
70
|
i.utcOffset()
|
|
71
71
|
).openingTime;
|
|
72
72
|
break;
|