@ancon/wildcat-utils 1.44.0-r13-2-tz.21 → 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.
|
@@ -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,75 +1,74 @@
|
|
|
1
|
-
import
|
|
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
|
|
5
|
+
import u from "./getServiceIntervalTimeSpanMoment.mjs";
|
|
6
6
|
function y(i, e) {
|
|
7
|
-
|
|
8
|
-
return n !== 0 ? i.subtract(n, "day") : i;
|
|
7
|
+
return i.clone().date() - e.date(), i;
|
|
9
8
|
}
|
|
10
|
-
function
|
|
9
|
+
function h(i) {
|
|
11
10
|
let e = null;
|
|
12
|
-
const { intervals: t, exception:
|
|
13
|
-
if (
|
|
14
|
-
const { state: r } =
|
|
15
|
-
r || (e =
|
|
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
21
|
return e;
|
|
23
22
|
}
|
|
24
|
-
function
|
|
23
|
+
function x(i, e, t) {
|
|
25
24
|
var r, s;
|
|
26
|
-
const
|
|
25
|
+
const o = [];
|
|
27
26
|
if (e.exception) {
|
|
28
27
|
if (e.exception.state === p.Opened) {
|
|
29
|
-
const
|
|
28
|
+
const n = u(
|
|
30
29
|
i,
|
|
31
30
|
e.exception.from,
|
|
32
31
|
t.utcOffset()
|
|
33
32
|
);
|
|
34
|
-
t.isBefore(
|
|
33
|
+
t.isBefore(n) && o.push({
|
|
35
34
|
interval: e.exception,
|
|
36
|
-
moment:
|
|
35
|
+
moment: n
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
} else
|
|
40
|
-
for (let
|
|
41
|
-
const f = e.intervals[
|
|
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
52
|
function S(i, e) {
|
|
54
53
|
let t = null;
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
i[
|
|
54
|
+
const o = m(e).format(O), r = x(
|
|
55
|
+
o,
|
|
56
|
+
i[o],
|
|
58
57
|
e
|
|
59
58
|
);
|
|
60
|
-
if (r && (t =
|
|
61
|
-
|
|
59
|
+
if (r && (t = u(
|
|
60
|
+
o,
|
|
62
61
|
r.from,
|
|
63
62
|
e.utcOffset()
|
|
64
63
|
)), !t)
|
|
65
64
|
for (let s = 1; s < g; s += 1) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
t =
|
|
65
|
+
const n = m(e).add(s, "d"), f = n.format(O), l = i[f], c = h(l);
|
|
66
|
+
if (c) {
|
|
67
|
+
t = u(
|
|
69
68
|
f,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
), t = y(t,
|
|
69
|
+
c.from,
|
|
70
|
+
n.utcOffset()
|
|
71
|
+
), t = y(t, n);
|
|
73
72
|
break;
|
|
74
73
|
}
|
|
75
74
|
}
|