@ancon/wildcat-utils 1.44.0-r13-2-tz.30 → 1.44.0-r13-2-tz.31

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