@ancon/wildcat-utils 1.44.0-r13-2-tz.49 → 1.44.0-r13-2-tz.51
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const S=require("@ancon/wildcat-types"),f=require("moment"),y=require("../date/isDSTShiftPresentInRange.js"),D=require("./getPickerIntervalsForDay.js"),P=require("./getSettingsForOrderFormat.js"),x=require("./getServiceIntervalStart.js"),h=require("./types.js"),R=require("./generatePickerTimesForDay.js"),_=require("./getServiceIntervalEnd.js"),I=require("./getOutletNextReadyToOrderTime.js");require("../date/getTimezoneUtcOffsetDifference.js");require("../shared/constants.js");require("../date/createLocalTimezoneMoment.js");require("./getServiceIntervalsForOrderFormat.js");require("../time/getTimeSpanParts.js");require("./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 M(n,d,O,k){const{preparationTime:T="00:00:00"}=P(d,n==null?void 0:n.orderFormatSettings)??{},s=I(n,d);console.log("nextReadyOrderTime",s.format());let a=s.clone();const c=f(O);if(console.log("specificDateMoment",c.format()),c>s)a=s.clone().set({year:c.year(),month:c.month(),date:c.date()}),console.log("specificDateMoment > nextReadyOrderTime",a.format());else{const t=s.diff(c,"day");if(console.log("ELSE specificDateMoment > nextReadyOrderTime",t),t>0)return[]}let e=[];const v=D(a,n==null?void 0:n.serviceDateTimes,d);let g;if(v.forEach(t=>{!g&&t.type&&(e=[]);const r=x(a,t,T),u=_(a,t,T);console.log("intervalStartTime, intervalEndTime",r.format(),u.format()),r<s&&(console.log("Add the time that has already passed today"),r.add(s.valueOf()-r.valueOf(),"millisecond"));const i=R(r,u,e,void 0,k);if(i.length>0)switch(t.state){case S.IntervalState.Closed:{const o=i[0],l=i[i.length-1];e=e.filter(({timestamp:m})=>m<o.timestamp||m>l.timestamp);break}case S.IntervalState.Opened:default:{let o=i;const l=y(r,u);console.log("isDSTShiftInterval",l),l&&(o=i.filter(m=>{const q=f(m.timestamp).utc(!0),p=a.clone().utc(!0);return console.log("=>",q.format(),p.format()),q.isSameOrAfter(p)})),e=e.concat(o);break}}g=t.type}),e.length){const t=e[0],r=e[e.length-1];if(y(t.timestamp,r.timestamp)){const i=Math.max(f(t.timestamp).utcOffset(),f(r.timestamp).utcOffset());return e.map(o=>{const m=f(o.timestamp).utcOffset()===i?h.PickerTimeTimezoneTag.Summer:h.PickerTimeTimezoneTag.Standard;return{...o,timezoneTag:m}})}}return e}module.exports=M;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { IntervalState as
|
|
2
|
-
import
|
|
1
|
+
import { IntervalState as h } from "@ancon/wildcat-types";
|
|
2
|
+
import p from "moment";
|
|
3
3
|
import O from "../date/isDSTShiftPresentInRange.mjs";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import x from "./getPickerIntervalsForDay.mjs";
|
|
5
|
+
import P from "./getSettingsForOrderFormat.mjs";
|
|
6
|
+
import R from "./getServiceIntervalStart.mjs";
|
|
7
7
|
import { PickerTimeTimezoneTag as k } from "./types.mjs";
|
|
8
|
-
import
|
|
8
|
+
import M from "./generatePickerTimesForDay.mjs";
|
|
9
9
|
import E from "./getServiceIntervalEnd.mjs";
|
|
10
|
-
import
|
|
10
|
+
import I from "./getOutletNextReadyToOrderTime.mjs";
|
|
11
11
|
import "../date/getTimezoneUtcOffsetDifference.mjs";
|
|
12
12
|
import "../shared/constants.mjs";
|
|
13
13
|
import "../date/createLocalTimezoneMoment.mjs";
|
|
@@ -24,98 +24,101 @@ import "./getTimezoneAdjustedServiceInterval.mjs";
|
|
|
24
24
|
import "../date/convertToSpecificTimezone.mjs";
|
|
25
25
|
import "./searchNextOpeningMoment.mjs";
|
|
26
26
|
import "./getOutletNextServiceTimeOffset.mjs";
|
|
27
|
-
function
|
|
28
|
-
const { preparationTime: T = "00:00:00" } =
|
|
29
|
-
console.log("nextReadyOrderTime",
|
|
30
|
-
let
|
|
31
|
-
const s =
|
|
32
|
-
if (s >
|
|
33
|
-
|
|
27
|
+
function ie(o, d, u, v) {
|
|
28
|
+
const { preparationTime: T = "00:00:00" } = P(d, o == null ? void 0 : o.orderFormatSettings) ?? {}, m = I(o, d);
|
|
29
|
+
console.log("nextReadyOrderTime", m.format());
|
|
30
|
+
let a = m.clone();
|
|
31
|
+
const s = p(u);
|
|
32
|
+
if (console.log("specificDateMoment", s.format()), s > m)
|
|
33
|
+
a = m.clone().set({
|
|
34
34
|
year: s.year(),
|
|
35
35
|
month: s.month(),
|
|
36
36
|
date: s.date()
|
|
37
|
-
});
|
|
38
|
-
else
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
}), console.log("specificDateMoment > nextReadyOrderTime", a.format());
|
|
38
|
+
else {
|
|
39
|
+
const t = m.diff(s, "day");
|
|
40
|
+
if (console.log("ELSE specificDateMoment > nextReadyOrderTime", t), t > 0)
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
let e = [];
|
|
44
|
+
const D = x(
|
|
45
|
+
a,
|
|
43
46
|
o == null ? void 0 : o.serviceDateTimes,
|
|
44
47
|
d
|
|
45
48
|
);
|
|
46
49
|
let g;
|
|
47
|
-
if (D.forEach((
|
|
48
|
-
!g &&
|
|
49
|
-
const i =
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (D.forEach((t) => {
|
|
51
|
+
!g && t.type && (e = []);
|
|
52
|
+
const i = R(
|
|
53
|
+
a,
|
|
54
|
+
t,
|
|
52
55
|
T
|
|
53
56
|
), l = E(
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
a,
|
|
58
|
+
t,
|
|
56
59
|
T
|
|
57
60
|
);
|
|
58
61
|
console.log(
|
|
59
62
|
"intervalStartTime, intervalEndTime",
|
|
60
63
|
i.format(),
|
|
61
64
|
l.format()
|
|
62
|
-
), i <
|
|
63
|
-
|
|
65
|
+
), i < m && (console.log("Add the time that has already passed today"), i.add(
|
|
66
|
+
m.valueOf() - i.valueOf(),
|
|
64
67
|
"millisecond"
|
|
65
68
|
));
|
|
66
|
-
const
|
|
69
|
+
const r = M(
|
|
67
70
|
i,
|
|
68
71
|
l,
|
|
69
|
-
|
|
72
|
+
e,
|
|
70
73
|
void 0,
|
|
71
74
|
v
|
|
72
75
|
);
|
|
73
|
-
if (
|
|
74
|
-
switch (
|
|
75
|
-
case
|
|
76
|
-
const n =
|
|
77
|
-
|
|
78
|
-
({ timestamp:
|
|
76
|
+
if (r.length > 0)
|
|
77
|
+
switch (t.state) {
|
|
78
|
+
case h.Closed: {
|
|
79
|
+
const n = r[0], f = r[r.length - 1];
|
|
80
|
+
e = e.filter(
|
|
81
|
+
({ timestamp: c }) => c < n.timestamp || c > f.timestamp
|
|
79
82
|
);
|
|
80
83
|
break;
|
|
81
84
|
}
|
|
82
|
-
case
|
|
85
|
+
case h.Opened:
|
|
83
86
|
default: {
|
|
84
|
-
let n =
|
|
87
|
+
let n = r;
|
|
85
88
|
const f = O(
|
|
86
89
|
i,
|
|
87
90
|
l
|
|
88
91
|
);
|
|
89
|
-
console.log("isDSTShiftInterval", f), f && (n =
|
|
90
|
-
const S = c
|
|
92
|
+
console.log("isDSTShiftInterval", f), f && (n = r.filter((c) => {
|
|
93
|
+
const S = p(c.timestamp).utc(!0), y = a.clone().utc(!0);
|
|
91
94
|
return console.log(
|
|
92
95
|
"=>",
|
|
93
96
|
S.format(),
|
|
94
|
-
|
|
95
|
-
), S.isSameOrAfter(
|
|
96
|
-
})),
|
|
97
|
+
y.format()
|
|
98
|
+
), S.isSameOrAfter(y);
|
|
99
|
+
})), e = e.concat(n);
|
|
97
100
|
break;
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
|
-
g =
|
|
101
|
-
}),
|
|
102
|
-
const
|
|
103
|
+
g = t.type;
|
|
104
|
+
}), e.length) {
|
|
105
|
+
const t = e[0], i = e[e.length - 1];
|
|
103
106
|
if (O(
|
|
104
|
-
|
|
107
|
+
t.timestamp,
|
|
105
108
|
i.timestamp
|
|
106
109
|
)) {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
const r = Math.max(
|
|
111
|
+
p(t.timestamp).utcOffset(),
|
|
112
|
+
p(i.timestamp).utcOffset()
|
|
110
113
|
);
|
|
111
|
-
return
|
|
112
|
-
const
|
|
113
|
-
return { ...n, timezoneTag:
|
|
114
|
+
return e.map((n) => {
|
|
115
|
+
const c = p(n.timestamp).utcOffset() === r ? k.Summer : k.Standard;
|
|
116
|
+
return { ...n, timezoneTag: c };
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
|
-
return
|
|
120
|
+
return e;
|
|
118
121
|
}
|
|
119
122
|
export {
|
|
120
|
-
|
|
123
|
+
ie as default
|
|
121
124
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const m=require("moment"),
|
|
1
|
+
"use strict";const m=require("moment"),p=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 O(u){let e=null;const{intervals:t,exception:n}=u;if(n){const{state:s}=n;s||(e=n)}else{const s=t.sort((i,o)=>d(i.from).hours-d(o.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===p.IntervalState.Opened){const o=c(u,e.exception,t.utcOffset()).openingTime;t.isBefore(o)&&n.push({interval:e.exception,moment:o})}}else for(let i=0;i<e.intervals.length;i+=1){const o=e.intervals[i],l=c(u,o,t.utcOffset()).openingTime;console.log("relevantMoment",t.format()),console.log("openingMoment",l.format()),t.isBefore(l)&&n.push({interval:o,moment:l})}return n.length<2?((s=n[0])==null?void 0:s.interval)??null:((r=n.sort((i,o)=>i.moment-t-(o.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 i=m(e).add(r,"d"),o=i.format(f.OutletMapKeyFormatter),a=u[o],l=O(a);if(l){t=c(o,l,i.utcOffset()).openingTime;break}}return t}module.exports=v;
|
|
@@ -1,74 +1,70 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { IntervalState as
|
|
3
|
-
import
|
|
4
|
-
import { OutletMapKeyFormatter as
|
|
1
|
+
import c from "moment";
|
|
2
|
+
import { IntervalState as p } from "@ancon/wildcat-types";
|
|
3
|
+
import a from "../time/getTimeSpanParts.mjs";
|
|
4
|
+
import { OutletMapKeyFormatter as d, OutletTimelineDayCount as g } from "./constants.mjs";
|
|
5
5
|
import m from "./getTimezoneAdjustedServiceInterval.mjs";
|
|
6
6
|
import "../date/getTimezoneUtcOffsetDifference.mjs";
|
|
7
7
|
import "../date/convertToSpecificTimezone.mjs";
|
|
8
8
|
import "./getServiceIntervalTimeSpanMoment.mjs";
|
|
9
9
|
function O(l) {
|
|
10
|
-
let
|
|
11
|
-
const { intervals:
|
|
10
|
+
let t = null;
|
|
11
|
+
const { intervals: e, exception: n } = l;
|
|
12
12
|
if (n) {
|
|
13
13
|
const { state: r } = n;
|
|
14
|
-
r || (
|
|
14
|
+
r || (t = n);
|
|
15
15
|
} else {
|
|
16
|
-
const r =
|
|
17
|
-
(i, o) =>
|
|
16
|
+
const r = e.sort(
|
|
17
|
+
(i, o) => a(i.from).hours - a(o.from).hours
|
|
18
18
|
), [s] = r;
|
|
19
19
|
return s;
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return t;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function v(l, t, e) {
|
|
24
24
|
var r, s;
|
|
25
25
|
const n = [];
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
26
|
+
if (t.exception) {
|
|
27
|
+
if (t.exception.state === p.Opened) {
|
|
28
28
|
const o = m(
|
|
29
29
|
l,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
t.exception,
|
|
31
|
+
e.utcOffset()
|
|
32
32
|
).openingTime;
|
|
33
|
-
|
|
34
|
-
interval:
|
|
33
|
+
e.isBefore(o) && n.push({
|
|
34
|
+
interval: t.exception,
|
|
35
35
|
moment: o
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
} else
|
|
39
|
-
for (let i = 0; i <
|
|
40
|
-
const o =
|
|
39
|
+
for (let i = 0; i < t.intervals.length; i += 1) {
|
|
40
|
+
const o = t.intervals[i], f = m(
|
|
41
41
|
l,
|
|
42
42
|
o,
|
|
43
|
-
|
|
43
|
+
e.utcOffset()
|
|
44
44
|
).openingTime;
|
|
45
|
-
console.log("relevantMoment",
|
|
45
|
+
console.log("relevantMoment", e.format()), console.log("openingMoment", f.format()), e.isBefore(f) && n.push({ interval: o, moment: f });
|
|
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
|
|
49
|
-
(i, o) => i.moment -
|
|
49
|
+
(i, o) => i.moment - e - (o.moment - e)
|
|
50
50
|
)[0]) == null ? void 0 : s.interval) ?? null;
|
|
51
51
|
}
|
|
52
|
-
function K(l,
|
|
53
|
-
let
|
|
54
|
-
const n =
|
|
52
|
+
function K(l, t) {
|
|
53
|
+
let e = null;
|
|
54
|
+
const n = c(t).format(d), r = v(
|
|
55
55
|
n,
|
|
56
56
|
l[n],
|
|
57
|
-
|
|
57
|
+
t
|
|
58
58
|
);
|
|
59
|
-
if (
|
|
60
|
-
"initialDayOperatingHour",
|
|
61
|
-
r,
|
|
62
|
-
e.format()
|
|
63
|
-
), r && (t = m(
|
|
59
|
+
if (r && (e = m(
|
|
64
60
|
n,
|
|
65
61
|
r,
|
|
66
|
-
|
|
67
|
-
).openingTime),
|
|
62
|
+
t.utcOffset()
|
|
63
|
+
).openingTime), !e)
|
|
68
64
|
for (let s = 1; s < g; s += 1) {
|
|
69
|
-
const i =
|
|
65
|
+
const i = c(t).add(s, "d"), o = i.format(d), u = l[o], f = O(u);
|
|
70
66
|
if (f) {
|
|
71
|
-
|
|
67
|
+
e = m(
|
|
72
68
|
o,
|
|
73
69
|
f,
|
|
74
70
|
i.utcOffset()
|
|
@@ -76,7 +72,7 @@ function K(l, e) {
|
|
|
76
72
|
break;
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
|
-
return
|
|
75
|
+
return e;
|
|
80
76
|
}
|
|
81
77
|
export {
|
|
82
78
|
K as default
|