@ancon/wildcat-utils 1.44.0-r13-2-tz.10 → 1.44.0-r13-2-tz.11

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