@ancon/wildcat-utils 1.44.0-r13-2-tz.26 → 1.44.0-r13-2-tz.27
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 p=require("@ancon/wildcat-types"),m=require("moment"),y=require("../date/isDSTShiftPresentInRange.js"),D=require("./getPickerIntervalsForDay.js"),P=require("./getSettingsForOrderFormat.js"),_=require("./getServiceIntervalStart.js"),h=require("./types.js"),x=require("./generatePickerTimesForDay.js"),I=require("./getServiceIntervalEnd.js"),R=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("./searchNextOpeningMoment.js");require("./getOutletNextServiceTimeOffset.js");function z(s,u,O,k){const{preparationTime:T="00:00:00"}=P(u,s==null?void 0:s.orderFormatSettings)??{},i=R(s,u);console.log("nextReadyOrderTime",i.format());let f=i.clone();const c=m(O);if(c>i)f=i.clone().set({year:c.year(),month:c.month(),date:c.date()});else if(i.diff(c,"day")>0)return[];let e=[];const v=D(f,s==null?void 0:s.serviceDateTimes,u);let q;if(v.forEach(t=>{!q&&t.type&&(e=[]);const r=_(f,t,T),l=I(f,t,T);console.log("intervalStartTime, intervalEndTime",r.format(),l.format()),r<i&&(console.log("Add the time that has already passed today"),r.add(i.valueOf()-r.valueOf(),"millisecond"));const n=x(r,l,e,void 0,k);if(n.length>0)switch(t.state){case p.IntervalState.Closed:{const a=n[0],d=n[n.length-1];e=e.filter(({timestamp:o})=>o<a.timestamp||o>d.timestamp);break}case p.IntervalState.Opened:default:{let a=n;y(r,l)&&(a=n.filter(o=>{const S=m(o.timestamp).utc(!0),g=i.clone().utc(!0);return console.log("=>",S.format(),g.format()),S.isSameOrAfter(g)})),e=e.concat(a);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(m(t.timestamp).utcOffset(),m(r.timestamp).utcOffset());return e.map(a=>{const o=m(a.timestamp).utcOffset()===n?h.PickerTimeTimezoneTag.Summer:h.PickerTimeTimezoneTag.Standard;return{...a,timezoneTag:o}})}}return e}module.exports=z;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IntervalState as
|
|
1
|
+
import { IntervalState as y } from "@ancon/wildcat-types";
|
|
2
2
|
import f from "moment";
|
|
3
|
-
import
|
|
3
|
+
import O from "../date/isDSTShiftPresentInRange.mjs";
|
|
4
4
|
import P from "./getPickerIntervalsForDay.mjs";
|
|
5
5
|
import x from "./getSettingsForOrderFormat.mjs";
|
|
6
6
|
import I from "./getServiceIntervalStart.mjs";
|
|
7
|
-
import { PickerTimeTimezoneTag as
|
|
7
|
+
import { PickerTimeTimezoneTag as k } from "./types.mjs";
|
|
8
8
|
import R from "./generatePickerTimesForDay.mjs";
|
|
9
9
|
import E from "./getServiceIntervalEnd.mjs";
|
|
10
10
|
import F from "./getOutletNextReadyToOrderTime.mjs";
|
|
@@ -22,11 +22,11 @@ import "./constants.mjs";
|
|
|
22
22
|
import "./getOutletCurrentActiveOperatingHour.mjs";
|
|
23
23
|
import "./searchNextOpeningMoment.mjs";
|
|
24
24
|
import "./getOutletNextServiceTimeOffset.mjs";
|
|
25
|
-
function tt(o,
|
|
26
|
-
const { preparationTime: T = "00:00:00" } = x(
|
|
25
|
+
function tt(o, l, u, v) {
|
|
26
|
+
const { preparationTime: T = "00:00:00" } = x(l, o == null ? void 0 : o.orderFormatSettings) ?? {}, r = F(o, l);
|
|
27
27
|
console.log("nextReadyOrderTime", r.format());
|
|
28
28
|
let c = r.clone();
|
|
29
|
-
const s = f(
|
|
29
|
+
const s = f(u);
|
|
30
30
|
if (s > r)
|
|
31
31
|
c = r.clone().set({
|
|
32
32
|
year: s.year(),
|
|
@@ -36,13 +36,13 @@ function tt(o, d, O, k) {
|
|
|
36
36
|
else if (r.diff(s, "day") > 0)
|
|
37
37
|
return [];
|
|
38
38
|
let t = [];
|
|
39
|
-
const
|
|
39
|
+
const D = P(
|
|
40
40
|
c,
|
|
41
41
|
o == null ? void 0 : o.serviceDateTimes,
|
|
42
|
-
|
|
42
|
+
l
|
|
43
43
|
);
|
|
44
44
|
let S;
|
|
45
|
-
if (
|
|
45
|
+
if (D.forEach((e) => {
|
|
46
46
|
!S && e.type && (t = []);
|
|
47
47
|
const i = I(
|
|
48
48
|
c,
|
|
@@ -66,34 +66,38 @@ function tt(o, d, O, k) {
|
|
|
66
66
|
p,
|
|
67
67
|
t,
|
|
68
68
|
void 0,
|
|
69
|
-
|
|
69
|
+
v
|
|
70
70
|
);
|
|
71
71
|
if (m.length > 0)
|
|
72
72
|
switch (e.state) {
|
|
73
|
-
case
|
|
74
|
-
const
|
|
73
|
+
case y.Closed: {
|
|
74
|
+
const a = m[0], d = m[m.length - 1];
|
|
75
75
|
t = t.filter(
|
|
76
|
-
({ timestamp:
|
|
76
|
+
({ timestamp: n }) => n < a.timestamp || n > d.timestamp
|
|
77
77
|
);
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
|
-
case
|
|
80
|
+
case y.Opened:
|
|
81
81
|
default: {
|
|
82
|
-
let
|
|
83
|
-
|
|
82
|
+
let a = m;
|
|
83
|
+
O(
|
|
84
84
|
i,
|
|
85
85
|
p
|
|
86
|
-
) && (
|
|
87
|
-
const
|
|
88
|
-
return
|
|
89
|
-
|
|
86
|
+
) && (a = m.filter((n) => {
|
|
87
|
+
const g = f(n.timestamp).utc(!0), h = r.clone().utc(!0);
|
|
88
|
+
return console.log(
|
|
89
|
+
"=>",
|
|
90
|
+
g.format(),
|
|
91
|
+
h.format()
|
|
92
|
+
), g.isSameOrAfter(h);
|
|
93
|
+
})), t = t.concat(a);
|
|
90
94
|
break;
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
S = e.type;
|
|
94
98
|
}), t.length) {
|
|
95
99
|
const e = t[0], i = t[t.length - 1];
|
|
96
|
-
if (
|
|
100
|
+
if (O(
|
|
97
101
|
e.timestamp,
|
|
98
102
|
i.timestamp
|
|
99
103
|
)) {
|
|
@@ -101,9 +105,9 @@ function tt(o, d, O, k) {
|
|
|
101
105
|
f(e.timestamp).utcOffset(),
|
|
102
106
|
f(i.timestamp).utcOffset()
|
|
103
107
|
);
|
|
104
|
-
return t.map((
|
|
105
|
-
const
|
|
106
|
-
return { ...
|
|
108
|
+
return t.map((a) => {
|
|
109
|
+
const n = f(a.timestamp).utcOffset() === m ? k.Summer : k.Standard;
|
|
110
|
+
return { ...a, timezoneTag: n };
|
|
107
111
|
});
|
|
108
112
|
}
|
|
109
113
|
}
|