@ancon/wildcat-utils 1.44.0-r13-2-tz.31 → 1.44.0-r13-2-tz.32
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 m=require("moment"),g=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),u=require("./constants.js"),
|
|
1
|
+
"use strict";const m=require("moment"),g=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),u=require("./constants.js"),f=require("./getServiceIntervalTimeSpanMoment.js");function y(l){let e=null;const{intervals:t,exception:n}=l;if(n){const{state:i}=n;i||(e=n)}else{const i=t.sort((o,r)=>O(o.from).hours-O(r.from).hours),[s]=i;return s}return e}function p(l,e,t){var i,s;const n=[];if(e.exception){if(e.exception.state===g.IntervalState.Opened){const o=f(l,e.exception.from,t.utcOffset());t.isBefore(o)&&n.push({interval:e.exception,moment:o})}}else for(let o=0;o<e.intervals.length;o+=1){const r=e.intervals[o],c=f(l,r.from,t.utcOffset());console.log("relevantMoment",t.format()),console.log("openingMoment",c.format()),t.isBefore(c)&&n.push({interval:r,moment:c})}return n.length<2?((i=n[0])==null?void 0:i.interval)??null:((s=n.sort((o,r)=>o.moment-t-(r.moment-t))[0])==null?void 0:s.interval)??null}function x(l,e){let t=null;const n=m(e).format(u.OutletMapKeyFormatter),i=p(n,l[n],e);if(console.log("initialDayOperatingHour",i,e.format()),i&&(t=f(n,i.from,e.utcOffset())),console.log("initialDayOperatingHour",t==null?void 0:t.format()),!t)for(let s=1;s<u.OutletTimelineDayCount;s+=1){const r=m(e).add(s,"d").format(u.OutletMapKeyFormatter),c=l[r],a=y(c);if(a){t=f(r,a.from);break}}return t}module.exports=x;
|
|
@@ -1,64 +1,69 @@
|
|
|
1
1
|
import c from "moment";
|
|
2
|
-
import { IntervalState as
|
|
2
|
+
import { IntervalState as O } from "@ancon/wildcat-types";
|
|
3
3
|
import u from "../time/getTimeSpanParts.mjs";
|
|
4
|
-
import { OutletMapKeyFormatter as p, OutletTimelineDayCount as
|
|
4
|
+
import { OutletMapKeyFormatter as p, OutletTimelineDayCount as g } from "./constants.mjs";
|
|
5
5
|
import a from "./getServiceIntervalTimeSpanMoment.mjs";
|
|
6
|
-
function y(
|
|
7
|
-
let
|
|
8
|
-
const { intervals: t, exception:
|
|
9
|
-
if (
|
|
10
|
-
const { state: i } =
|
|
11
|
-
i || (
|
|
6
|
+
function y(l) {
|
|
7
|
+
let o = null;
|
|
8
|
+
const { intervals: t, exception: e } = l;
|
|
9
|
+
if (e) {
|
|
10
|
+
const { state: i } = e;
|
|
11
|
+
i || (o = e);
|
|
12
12
|
} else {
|
|
13
13
|
const i = t.sort(
|
|
14
14
|
(n, r) => u(n.from).hours - u(r.from).hours
|
|
15
|
-
), [
|
|
16
|
-
return
|
|
15
|
+
), [f] = i;
|
|
16
|
+
return f;
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return o;
|
|
19
19
|
}
|
|
20
|
-
function x(
|
|
21
|
-
var i,
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
20
|
+
function x(l, o, t) {
|
|
21
|
+
var i, f;
|
|
22
|
+
const e = [];
|
|
23
|
+
if (o.exception) {
|
|
24
|
+
if (o.exception.state === O.Opened) {
|
|
25
25
|
const n = a(
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
l,
|
|
27
|
+
o.exception.from,
|
|
28
28
|
t.utcOffset()
|
|
29
29
|
);
|
|
30
|
-
t.isBefore(n) &&
|
|
31
|
-
interval:
|
|
30
|
+
t.isBefore(n) && e.push({
|
|
31
|
+
interval: o.exception,
|
|
32
32
|
moment: n
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
} else
|
|
36
|
-
for (let n = 0; n <
|
|
37
|
-
const r =
|
|
38
|
-
|
|
36
|
+
for (let n = 0; n < o.intervals.length; n += 1) {
|
|
37
|
+
const r = o.intervals[n], s = a(
|
|
38
|
+
l,
|
|
39
39
|
r.from,
|
|
40
40
|
t.utcOffset()
|
|
41
41
|
);
|
|
42
|
-
console.log("relevantMoment", t.format()), console.log("openingMoment", s.format()), t.isBefore(s) &&
|
|
42
|
+
console.log("relevantMoment", t.format()), console.log("openingMoment", s.format()), t.isBefore(s) && e.push({ interval: r, moment: s });
|
|
43
43
|
}
|
|
44
|
-
return
|
|
44
|
+
return e.length < 2 ? ((i = e[0]) == null ? void 0 : i.interval) ?? null : ((f = e.sort(
|
|
45
45
|
// @ts-ignore TODO
|
|
46
46
|
(n, r) => n.moment - t - (r.moment - t)
|
|
47
|
-
)[0]) == null ? void 0 :
|
|
47
|
+
)[0]) == null ? void 0 : f.interval) ?? null;
|
|
48
48
|
}
|
|
49
|
-
function K(
|
|
49
|
+
function K(l, o) {
|
|
50
50
|
let t = null;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const e = c(o).format(p), i = x(
|
|
52
|
+
e,
|
|
53
|
+
l[e],
|
|
54
|
+
o
|
|
55
55
|
);
|
|
56
|
-
if (console.log(
|
|
57
|
-
|
|
58
|
-
i
|
|
56
|
+
if (console.log(
|
|
57
|
+
"initialDayOperatingHour",
|
|
58
|
+
i,
|
|
59
|
+
o.format()
|
|
60
|
+
), i && (t = a(
|
|
61
|
+
e,
|
|
62
|
+
i.from,
|
|
63
|
+
o.utcOffset()
|
|
59
64
|
)), console.log("initialDayOperatingHour", t == null ? void 0 : t.format()), !t)
|
|
60
|
-
for (let
|
|
61
|
-
const r = c(
|
|
65
|
+
for (let f = 1; f < g; f += 1) {
|
|
66
|
+
const r = c(o).add(f, "d").format(p), s = l[r], m = y(s);
|
|
62
67
|
if (m) {
|
|
63
68
|
t = a(
|
|
64
69
|
r,
|