@ancon/wildcat-utils 1.44.0-r13-2-tz.20 → 1.44.0-r13-2-tz.22
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/outlet/getOutletCurrentActiveOperatingHour.js +1 -1
- package/outlet/getOutletCurrentActiveOperatingHour.mjs +17 -15
- package/outlet/getOutletTagInformation.js +1 -1
- package/outlet/getOutletTagInformation.mjs +37 -36
- package/outlet/searchNextOpeningMoment.js +1 -1
- package/outlet/searchNextOpeningMoment.mjs +40 -39
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const f=require("@ancon/wildcat-types"),s=require("../time/getTimeSpanParts.js"),l=require("./getServiceIntervalTimeSpanMoment.js");require("moment");function a(c,e,i){if(e.exception){const{exception:t}=e;if(t.type===f.IntervalType.Normal){const n=s(t.duration),o=l(c,t.from,i.utcOffset()),r=o.clone().add(n);if(i.isBetween(o,r))return e.exception}}else for(let t=0;t<e.intervals.length;t+=1){const n=e.intervals[t],o=s(n.duration),r=l(c,n.from,i.utcOffset()),u=r.clone().add(o);if(i.isBetween(r,u))return n}return null}module.exports=a;
|
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { IntervalType as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { IntervalType as u } from "@ancon/wildcat-types";
|
|
2
|
+
import l from "../time/getTimeSpanParts.mjs";
|
|
3
|
+
import f from "./getServiceIntervalTimeSpanMoment.mjs";
|
|
4
4
|
import "moment";
|
|
5
|
-
function g(
|
|
5
|
+
function g(c, n, i) {
|
|
6
6
|
if (n.exception) {
|
|
7
7
|
const { exception: t } = n;
|
|
8
|
-
if (t.type ===
|
|
9
|
-
const e =
|
|
10
|
-
|
|
11
|
-
t.from
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
if (t.type === u.Normal) {
|
|
9
|
+
const e = l(t.duration), o = f(
|
|
10
|
+
c,
|
|
11
|
+
t.from,
|
|
12
|
+
i.utcOffset()
|
|
13
|
+
), r = o.clone().add(e);
|
|
14
|
+
if (i.isBetween(o, r))
|
|
14
15
|
return n.exception;
|
|
15
16
|
}
|
|
16
17
|
} else
|
|
17
18
|
for (let t = 0; t < n.intervals.length; t += 1) {
|
|
18
|
-
const e = n.intervals[t], o =
|
|
19
|
-
|
|
20
|
-
e.from
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const e = n.intervals[t], o = l(e.duration), r = f(
|
|
20
|
+
c,
|
|
21
|
+
e.from,
|
|
22
|
+
i.utcOffset()
|
|
23
|
+
), s = r.clone().add(o);
|
|
24
|
+
if (i.isBetween(r, s))
|
|
23
25
|
return e;
|
|
24
26
|
}
|
|
25
27
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@ancon/wildcat-types"),v=require("moment"),u=require("../date/createLocalTimezoneMoment.js"),k=require("../time/getTimeSpanParts.js"),d=require("./constants.js"),M=require("./getOutletCurrentActiveOperatingHour.js"),D=require("./getServiceIntervalTimeSpanMoment.js"),S=require("./searchNextOpeningMoment.js"),O={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function T(n,e){const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@ancon/wildcat-types"),v=require("moment"),u=require("../date/createLocalTimezoneMoment.js"),k=require("../time/getTimeSpanParts.js"),d=require("./constants.js"),M=require("./getOutletCurrentActiveOperatingHour.js"),D=require("./getServiceIntervalTimeSpanMoment.js"),S=require("./searchNextOpeningMoment.js"),O={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function T(n,e){const t=n.isSame(e,"d"),a={[e.format(d.OutletMapKeyFormatter)]:{intervals:[],exception:null,metadata:{dayOfWeek:O[e.isoWeekday()]}}};for(let i=t?1:0;i<d.OutletTimelineDayCount;i+=1){const s=v(n).add(i,"d");a[s.format(d.OutletMapKeyFormatter)]={intervals:[],exception:null,metadata:{dayOfWeek:O[s.isoWeekday()]}}}return a}function W(n,e){const t=u(e.periodFrom),o=u(e.periodTo);if(!t.isSame(o,"d"))Object.keys(n).forEach(i=>{const s=v(i);if(s.isSame(t,"d")||s.isSame(o,"d")||s.isBetween(t,o)){const c=n[i],r=c.exception?c.exception.position:0;e.position>r&&(c.exception=e)}});else{const i=t.format(d.OutletMapKeyFormatter),s=n[i];if(s){const m=s.exception?s.exception.position:0;e.position>m&&(s.exception=e)}}}function I(n,e){Object.keys(n).forEach(t=>{const o=n[t],{dayOfWeek:a}=o.metadata,{dayOfWeek:i}=e;(a&i)===a&&o.intervals.push(e)})}function q(n,e,t){const o=T(e,t);return n.forEach(a=>{a.type===g.IntervalType.Exception?W(o,a):I(o,a)}),o}function x(n,e,t,o){const a=q(n,t,o),i=o.format(d.OutletMapKeyFormatter),s=M(i,a[i],o)!==null,m=e;let c=null,r=null;if(e){const f=t.format(d.OutletMapKeyFormatter),l=M(f,a[f],t);if(l){const{hours:p,minutes:y}=k(l.duration);r=D(f,l.from,t.utcOffset()),c=r.clone().add(p,"hours").add(y,"minutes")}}else r=S(a,t);if(!e&&!r){const f=n.filter(p=>p.state&&u(p.periodTo).isAfter(t)),[l]=f.sort((p,y)=>o.valueOf()-(u(p.periodTo).valueOf()-u(y.periodTo).valueOf()));if(l)return x(n,e,u(l.periodTo),o)}return{closingTime:c,openingTime:r,openDuringSpecifiedTime:m,openNow:s}}exports.DaysOfWeekMap=O;exports.default=x;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IntervalType as g } from "@ancon/wildcat-types";
|
|
2
2
|
import v from "moment";
|
|
3
|
-
import
|
|
3
|
+
import f from "../date/createLocalTimezoneMoment.mjs";
|
|
4
4
|
import M from "../time/getTimeSpanParts.mjs";
|
|
5
5
|
import { OutletMapKeyFormatter as d, OutletTimelineDayCount as k } from "./constants.mjs";
|
|
6
6
|
import O from "./getOutletCurrentActiveOperatingHour.mjs";
|
|
@@ -19,14 +19,14 @@ const x = {
|
|
|
19
19
|
// WEEKENDS: 96,
|
|
20
20
|
};
|
|
21
21
|
function I(n, e) {
|
|
22
|
-
const
|
|
22
|
+
const t = n.isSame(e, "d"), a = {
|
|
23
23
|
[e.format(d)]: {
|
|
24
24
|
intervals: [],
|
|
25
25
|
exception: null,
|
|
26
26
|
metadata: { dayOfWeek: x[e.isoWeekday()] }
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
for (let s =
|
|
29
|
+
for (let s = t ? 1 : 0; s < k; s += 1) {
|
|
30
30
|
const i = v(n).add(s, "d");
|
|
31
31
|
a[i.format(d)] = {
|
|
32
32
|
intervals: [],
|
|
@@ -36,79 +36,80 @@ function I(n, e) {
|
|
|
36
36
|
}
|
|
37
37
|
return a;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
|
|
39
|
+
function W(n, e) {
|
|
40
|
+
const t = f(e.periodFrom), o = f(e.periodTo);
|
|
41
|
+
if (!t.isSame(
|
|
42
|
+
o,
|
|
43
43
|
"d"
|
|
44
44
|
))
|
|
45
45
|
Object.keys(n).forEach((s) => {
|
|
46
46
|
const i = v(s);
|
|
47
|
-
if (i.isSame(
|
|
47
|
+
if (i.isSame(t, "d") || i.isSame(o, "d") || i.isBetween(t, o)) {
|
|
48
48
|
const p = n[s], r = p.exception ? p.exception.position : 0;
|
|
49
49
|
e.position > r && (p.exception = e);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
else {
|
|
53
|
-
const s =
|
|
53
|
+
const s = t.format(d), i = n[s];
|
|
54
54
|
if (i) {
|
|
55
55
|
const u = i.exception ? i.exception.position : 0;
|
|
56
56
|
e.position > u && (i.exception = e);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
Object.keys(n).forEach((
|
|
62
|
-
const
|
|
63
|
-
(a & s) === a &&
|
|
60
|
+
function E(n, e) {
|
|
61
|
+
Object.keys(n).forEach((t) => {
|
|
62
|
+
const o = n[t], { dayOfWeek: a } = o.metadata, { dayOfWeek: s } = e;
|
|
63
|
+
(a & s) === a && o.intervals.push(e);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const
|
|
66
|
+
function T(n, e, t) {
|
|
67
|
+
const o = I(e, t);
|
|
68
68
|
return n.forEach((a) => {
|
|
69
|
-
a.type === g.Exception ?
|
|
70
|
-
}),
|
|
69
|
+
a.type === g.Exception ? W(o, a) : E(o, a);
|
|
70
|
+
}), o;
|
|
71
71
|
}
|
|
72
|
-
function h(n, e,
|
|
73
|
-
const a =
|
|
72
|
+
function h(n, e, t, o) {
|
|
73
|
+
const a = T(
|
|
74
74
|
n,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
), s =
|
|
75
|
+
t,
|
|
76
|
+
o
|
|
77
|
+
), s = o.format(d), i = O(
|
|
78
78
|
s,
|
|
79
79
|
a[s],
|
|
80
|
-
|
|
80
|
+
o
|
|
81
81
|
) !== null, u = e;
|
|
82
82
|
let p = null, r = null;
|
|
83
83
|
if (e) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
a[
|
|
87
|
-
|
|
84
|
+
const m = t.format(d), c = O(
|
|
85
|
+
m,
|
|
86
|
+
a[m],
|
|
87
|
+
t
|
|
88
88
|
);
|
|
89
89
|
if (c) {
|
|
90
90
|
const { hours: l, minutes: y } = M(
|
|
91
91
|
c.duration
|
|
92
92
|
);
|
|
93
93
|
r = D(
|
|
94
|
-
|
|
95
|
-
c.from
|
|
94
|
+
m,
|
|
95
|
+
c.from,
|
|
96
|
+
t.utcOffset()
|
|
96
97
|
), p = r.clone().add(l, "hours").add(y, "minutes");
|
|
97
98
|
}
|
|
98
99
|
} else
|
|
99
|
-
r = S(a,
|
|
100
|
+
r = S(a, t);
|
|
100
101
|
if (!e && !r) {
|
|
101
|
-
const
|
|
102
|
-
(l) => l.state &&
|
|
103
|
-
), [c] =
|
|
104
|
-
(l, y) =>
|
|
102
|
+
const m = n.filter(
|
|
103
|
+
(l) => l.state && f(l.periodTo).isAfter(t)
|
|
104
|
+
), [c] = m.sort(
|
|
105
|
+
(l, y) => o.valueOf() - (f(l.periodTo).valueOf() - f(y.periodTo).valueOf())
|
|
105
106
|
);
|
|
106
107
|
if (c)
|
|
107
108
|
return h(
|
|
108
109
|
n,
|
|
109
110
|
e,
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
f(c.periodTo),
|
|
112
|
+
o
|
|
112
113
|
);
|
|
113
114
|
}
|
|
114
115
|
return { closingTime: p, openingTime: r, openDuringSpecifiedTime: u, openNow: i };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const m=require("moment"),
|
|
1
|
+
"use strict";const m=require("moment"),g=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),f=require("./constants.js"),c=require("./getServiceIntervalTimeSpanMoment.js");function y(i,e){return i.clone().date()-e.date(),i}function p(i){let e=null;const{intervals:t,exception:o}=i;if(o){const{state:r}=o;r||(e=o)}else{const r=t.sort((n,s)=>O(n.from).hours-O(s.from).hours),[l]=r;return l}return e}function h(i,e,t){var r,l;const o=[];if(e.exception){if(e.exception.state===g.IntervalState.Opened){const n=c(i,e.exception.from,t.utcOffset());t.isBefore(n)&&o.push({interval:e.exception,moment:n})}}else for(let n=0;n<e.intervals.length;n+=1){const s=e.intervals[n],u=c(i,s.from,t.utcOffset());console.log("relevantMoment",t.format()),console.log("openingMoment",u.format()),t.isBefore(u)&&o.push({interval:s,moment:u})}return o.length<2?((r=o[0])==null?void 0:r.interval)??null:((l=o.sort((n,s)=>n.moment-t-(s.moment-t))[0])==null?void 0:l.interval)??null}function x(i,e){let t=null;const o=m(e).format(f.OutletMapKeyFormatter),r=h(o,i[o],e);if(r&&(t=c(o,r.from,e.utcOffset())),!t)for(let l=1;l<f.OutletTimelineDayCount;l+=1){const n=m(e).add(l,"d"),s=n.format(f.OutletMapKeyFormatter),u=i[s],a=p(u);if(a){t=c(s,a.from,n.utcOffset()),t=y(t,n);break}}return t}module.exports=x;
|
|
@@ -1,73 +1,74 @@
|
|
|
1
1
|
import m from "moment";
|
|
2
2
|
import { IntervalState as p } from "@ancon/wildcat-types";
|
|
3
|
-
import
|
|
3
|
+
import a from "../time/getTimeSpanParts.mjs";
|
|
4
4
|
import { OutletMapKeyFormatter as O, OutletTimelineDayCount as g } from "./constants.mjs";
|
|
5
|
-
import
|
|
6
|
-
function y(i,
|
|
7
|
-
|
|
8
|
-
return e !== 0 ? i.subtract(e, "day") : i;
|
|
5
|
+
import u from "./getServiceIntervalTimeSpanMoment.mjs";
|
|
6
|
+
function y(i, e) {
|
|
7
|
+
return i.clone().date() - e.date(), i;
|
|
9
8
|
}
|
|
10
|
-
function
|
|
11
|
-
let
|
|
12
|
-
const { intervals: t, exception:
|
|
13
|
-
if (
|
|
14
|
-
const { state: r } =
|
|
15
|
-
r || (
|
|
9
|
+
function h(i) {
|
|
10
|
+
let e = null;
|
|
11
|
+
const { intervals: t, exception: o } = i;
|
|
12
|
+
if (o) {
|
|
13
|
+
const { state: r } = o;
|
|
14
|
+
r || (e = o);
|
|
16
15
|
} else {
|
|
17
16
|
const r = t.sort(
|
|
18
|
-
(
|
|
17
|
+
(n, f) => a(n.from).hours - a(f.from).hours
|
|
19
18
|
), [s] = r;
|
|
20
19
|
return s;
|
|
21
20
|
}
|
|
22
|
-
return
|
|
21
|
+
return e;
|
|
23
22
|
}
|
|
24
|
-
function
|
|
23
|
+
function x(i, e, t) {
|
|
25
24
|
var r, s;
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
25
|
+
const o = [];
|
|
26
|
+
if (e.exception) {
|
|
27
|
+
if (e.exception.state === p.Opened) {
|
|
28
|
+
const n = u(
|
|
30
29
|
i,
|
|
31
|
-
|
|
30
|
+
e.exception.from,
|
|
32
31
|
t.utcOffset()
|
|
33
32
|
);
|
|
34
|
-
t.isBefore(
|
|
35
|
-
interval:
|
|
36
|
-
moment:
|
|
33
|
+
t.isBefore(n) && o.push({
|
|
34
|
+
interval: e.exception,
|
|
35
|
+
moment: n
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
} else
|
|
40
|
-
for (let
|
|
41
|
-
const f =
|
|
39
|
+
for (let n = 0; n < e.intervals.length; n += 1) {
|
|
40
|
+
const f = e.intervals[n], l = u(
|
|
42
41
|
i,
|
|
43
42
|
f.from,
|
|
44
43
|
t.utcOffset()
|
|
45
44
|
);
|
|
46
|
-
console.log("relevantMoment", t.format()), console.log("openingMoment", l.format()), t.isBefore(l) &&
|
|
45
|
+
console.log("relevantMoment", t.format()), console.log("openingMoment", l.format()), t.isBefore(l) && o.push({ interval: f, moment: l });
|
|
47
46
|
}
|
|
48
|
-
return
|
|
47
|
+
return o.length < 2 ? ((r = o[0]) == null ? void 0 : r.interval) ?? null : ((s = o.sort(
|
|
49
48
|
// @ts-ignore TODO
|
|
50
|
-
(
|
|
49
|
+
(n, f) => n.moment - t - (f.moment - t)
|
|
51
50
|
)[0]) == null ? void 0 : s.interval) ?? null;
|
|
52
51
|
}
|
|
53
|
-
function S(i,
|
|
52
|
+
function S(i, e) {
|
|
54
53
|
let t = null;
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
i[
|
|
58
|
-
|
|
54
|
+
const o = m(e).format(O), r = x(
|
|
55
|
+
o,
|
|
56
|
+
i[o],
|
|
57
|
+
e
|
|
59
58
|
);
|
|
60
|
-
if (r && (t =
|
|
61
|
-
|
|
62
|
-
r.from
|
|
59
|
+
if (r && (t = u(
|
|
60
|
+
o,
|
|
61
|
+
r.from,
|
|
62
|
+
e.utcOffset()
|
|
63
63
|
)), !t)
|
|
64
64
|
for (let s = 1; s < g; s += 1) {
|
|
65
|
-
const
|
|
65
|
+
const n = m(e).add(s, "d"), f = n.format(O), l = i[f], c = h(l);
|
|
66
66
|
if (c) {
|
|
67
|
-
t =
|
|
67
|
+
t = u(
|
|
68
68
|
f,
|
|
69
|
-
c.from
|
|
70
|
-
|
|
69
|
+
c.from,
|
|
70
|
+
n.utcOffset()
|
|
71
|
+
), t = y(t, n);
|
|
71
72
|
break;
|
|
72
73
|
}
|
|
73
74
|
}
|