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