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