@ancon/wildcat-utils 1.44.0-r13-2-tz.13 → 1.44.0-r13-2-tz.15
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.
|
@@ -6,4 +6,4 @@ import { Moment, MomentInput } from 'moment';
|
|
|
6
6
|
* @param timeSpan - Service interval time span.
|
|
7
7
|
* @returns The generated Moment object
|
|
8
8
|
*/
|
|
9
|
-
export default function getServiceIntervalTimeSpanMoment(date: MomentInput, timeSpan: string): Moment;
|
|
9
|
+
export default function getServiceIntervalTimeSpanMoment(date: MomentInput, timeSpan: string, utcOffset?: number): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const m=require("moment"),r=require("../time/getTimeSpanParts.js");function s(i,o,e){const t=r(o),n=m(i);return e!==void 0&&n.utcOffset(e),n.hour(t.hours).minute(t.minutes).second(0).millisecond(0)}module.exports=s;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
return
|
|
1
|
+
import i from "moment";
|
|
2
|
+
import r from "../time/getTimeSpanParts.mjs";
|
|
3
|
+
function d(m, n, e) {
|
|
4
|
+
const t = r(n), o = i(m);
|
|
5
|
+
return e !== void 0 && o.utcOffset(e), o.hour(t.hours).minute(t.minutes).second(0).millisecond(0);
|
|
6
6
|
}
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
d as default
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const a=require("moment"),g=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),f=require("./constants.js"),u=require("./getServiceIntervalTimeSpanMoment.js");function y(r,e){const t=r.clone().date()-e.date();return t!==0?r.subtract(t,"day"):r}function p(r){let e=null;const{intervals:n,exception:t}=r;if(t){const{state:s}=t;s||(e=t)}else{const s=n.sort((o,i)=>O(o.from).hours-O(i.from).hours),[l]=s;return l}return e}function h(r,e,n){var s,l;const t=[];if(e.exception){if(e.exception.state===g.IntervalState.Opened){const o=u(r,e.exception.from);n.clone().utc(!0).isBefore(o.clone().utc(!0))&&t.push({interval:e.exception,moment:o})}}else for(let o=0;o<e.intervals.length;o+=1){const i=e.intervals[o],c=u(r,i.from);console.log("relevantMoment",n.format()),console.log("openingMoment",c.format(),u(r,i.from,a().utcOffset()).format()),n.clone().utc(!0).isBefore(c.clone().utc(!0))&&t.push({interval:i,moment:c})}return t.length<2?((s=t[0])==null?void 0:s.interval)??null:((l=t.sort((o,i)=>o.moment-n-(i.moment-n))[0])==null?void 0:l.interval)??null}function v(r,e){let n=null;const t=a(e).format(f.OutletMapKeyFormatter),s=h(t,r[t],e);if(s&&(n=u(t,s.from)),!n)for(let l=1;l<f.OutletTimelineDayCount;l+=1){const o=a(e).add(l,"d"),i=o.format(f.OutletMapKeyFormatter),c=r[i],m=p(c);if(m){n=u(i,m.from),n=y(n,o);break}}return n}module.exports=v;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import u from "moment";
|
|
2
2
|
import { IntervalState as p } from "@ancon/wildcat-types";
|
|
3
3
|
import m from "../time/getTimeSpanParts.mjs";
|
|
4
4
|
import { OutletMapKeyFormatter as O, OutletTimelineDayCount as g } from "./constants.mjs";
|
|
@@ -7,22 +7,22 @@ function y(r, e) {
|
|
|
7
7
|
const t = r.clone().date() - e.date();
|
|
8
8
|
return t !== 0 ? r.subtract(t, "day") : r;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function h(r) {
|
|
11
11
|
let e = null;
|
|
12
12
|
const { intervals: n, exception: t } = r;
|
|
13
13
|
if (t) {
|
|
14
|
-
const { state:
|
|
15
|
-
|
|
14
|
+
const { state: l } = t;
|
|
15
|
+
l || (e = t);
|
|
16
16
|
} else {
|
|
17
|
-
const
|
|
18
|
-
(o,
|
|
19
|
-
), [
|
|
20
|
-
return
|
|
17
|
+
const l = n.sort(
|
|
18
|
+
(o, i) => m(o.from).hours - m(i.from).hours
|
|
19
|
+
), [f] = l;
|
|
20
|
+
return f;
|
|
21
21
|
}
|
|
22
22
|
return e;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
var
|
|
24
|
+
function v(r, e, n) {
|
|
25
|
+
var l, f;
|
|
26
26
|
const t = [];
|
|
27
27
|
if (e.exception) {
|
|
28
28
|
if (e.exception.state === p.Opened) {
|
|
@@ -37,34 +37,42 @@ function h(r, e, n) {
|
|
|
37
37
|
}
|
|
38
38
|
} else
|
|
39
39
|
for (let o = 0; o < e.intervals.length; o += 1) {
|
|
40
|
-
const
|
|
40
|
+
const i = e.intervals[o], s = c(
|
|
41
41
|
r,
|
|
42
|
-
|
|
42
|
+
i.from
|
|
43
43
|
);
|
|
44
|
-
console.log("relevantMoment", n.format()), console.log(
|
|
44
|
+
console.log("relevantMoment", n.format()), console.log(
|
|
45
|
+
"openingMoment",
|
|
46
|
+
s.format(),
|
|
47
|
+
c(
|
|
48
|
+
r,
|
|
49
|
+
i.from,
|
|
50
|
+
u().utcOffset()
|
|
51
|
+
).format()
|
|
52
|
+
), n.clone().utc(!0).isBefore(s.clone().utc(!0)) && t.push({ interval: i, moment: s });
|
|
45
53
|
}
|
|
46
|
-
return t.length < 2 ? ((
|
|
54
|
+
return t.length < 2 ? ((l = t[0]) == null ? void 0 : l.interval) ?? null : ((f = t.sort(
|
|
47
55
|
// @ts-ignore TODO
|
|
48
|
-
(o,
|
|
49
|
-
)[0]) == null ? void 0 :
|
|
56
|
+
(o, i) => o.moment - n - (i.moment - n)
|
|
57
|
+
)[0]) == null ? void 0 : f.interval) ?? null;
|
|
50
58
|
}
|
|
51
59
|
function S(r, e) {
|
|
52
60
|
let n = null;
|
|
53
|
-
const t =
|
|
61
|
+
const t = u(e).format(O), l = v(
|
|
54
62
|
t,
|
|
55
63
|
r[t],
|
|
56
64
|
e
|
|
57
65
|
);
|
|
58
|
-
if (
|
|
66
|
+
if (l && (n = c(
|
|
59
67
|
t,
|
|
60
|
-
|
|
68
|
+
l.from
|
|
61
69
|
)), !n)
|
|
62
|
-
for (let
|
|
63
|
-
const o =
|
|
64
|
-
if (
|
|
70
|
+
for (let f = 1; f < g; f += 1) {
|
|
71
|
+
const o = u(e).add(f, "d"), i = o.format(O), s = r[i], a = h(s);
|
|
72
|
+
if (a) {
|
|
65
73
|
n = c(
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
i,
|
|
75
|
+
a.from
|
|
68
76
|
), n = y(n, o);
|
|
69
77
|
break;
|
|
70
78
|
}
|