@ancon/wildcat-utils 1.44.0-r13-2-tz.17 → 1.44.0-r13-2-tz.19

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.
@@ -3,6 +3,7 @@ import moment, { Moment } from 'moment';
3
3
  * This function converts a given moment object to the local timezone by adjusting the UTC offset.
4
4
  *
5
5
  * @param dateTimeMoment The moment object to convert to the local timezone.
6
+ * @param keepLocalTime Optional flag that specifies whether the offset would be changed without modifying the actual time itself.
6
7
  * @returns The moment object converted to the local timezone.
7
8
  */
8
- export default function convertToLocalTimezone(dateTimeMoment: Moment): moment.Moment;
9
+ export default function convertToLocalTimezone(dateTimeMoment: Moment, keepLocalTime?: boolean): moment.Moment;
@@ -1 +1 @@
1
- "use strict";const f=require("moment"),c=require("./getTimezoneUtcOffsetDifference.js");function r(t){const e=f();return c(e,t)?t.utcOffset(e.utcOffset()):t}module.exports=r;
1
+ "use strict";const c=require("moment"),r=require("./getTimezoneUtcOffsetDifference.js");function s(t,f){const e=c();return r(e,t)?t.utcOffset(e.utcOffset(),f):t}module.exports=s;
@@ -1,12 +1,12 @@
1
- import e from "moment";
2
- import o from "./getTimezoneUtcOffsetDifference.mjs";
3
- function i(f) {
4
- const t = e();
5
- return o(
1
+ import o from "moment";
2
+ import c from "./getTimezoneUtcOffsetDifference.mjs";
3
+ function s(f, e) {
4
+ const t = o();
5
+ return c(
6
6
  t,
7
7
  f
8
- ) ? f.utcOffset(t.utcOffset()) : f;
8
+ ) ? f.utcOffset(t.utcOffset(), e) : f;
9
9
  }
10
10
  export {
11
- i as default
11
+ s as default
12
12
  };
@@ -1 +1 @@
1
- "use strict";const s=require("moment"),o=require("./isDSTShiftPresentInRange.js");require("./getTimezoneUtcOffsetDifference.js");function a(r){const t=s(r),e=t.startOf("day"),n=t.endOf("day");return console.log("isDSTShiftPresentOnDate",e.format(),n.format()),o(e,n)}module.exports=a;
1
+ "use strict";const o=require("moment"),s=require("./isDSTShiftPresentInRange.js");require("./getTimezoneUtcOffsetDifference.js");function a(e){const t=o(e),n=t.startOf("day"),r=t.endOf("day");return console.log("isDSTShiftPresentOnDate",e,t.format(),n.format(),r.format()),s(n,r)}module.exports=a;
@@ -1,13 +1,15 @@
1
1
  import r from "moment";
2
2
  import a from "./isDSTShiftPresentInRange.mjs";
3
3
  import "./getTimezoneUtcOffsetDifference.mjs";
4
- function i(o) {
5
- const t = r(o), e = t.startOf("day"), n = t.endOf("day");
4
+ function i(n) {
5
+ const t = r(n), o = t.startOf("day"), e = t.endOf("day");
6
6
  return console.log(
7
7
  "isDSTShiftPresentOnDate",
8
- e.format(),
9
- n.format()
10
- ), a(e, n);
8
+ n,
9
+ t.format(),
10
+ o.format(),
11
+ e.format()
12
+ ), a(o, e);
11
13
  }
12
14
  export {
13
15
  i as default
@@ -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, utcOffset?: number): Moment;
9
+ export default function getServiceIntervalTimeSpanMoment(date: MomentInput, timeSpan: string, timezoneOffset?: number): Moment;
@@ -1,9 +1,9 @@
1
1
  import i from "moment";
2
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);
3
+ function u(m, n, t) {
4
+ const e = r(n), o = i(m);
5
+ return t !== void 0 && o.utcOffset(t), o.hour(e.hours).minute(e.minutes).second(0).millisecond(0);
6
6
  }
7
7
  export {
8
- d as default
8
+ u as default
9
9
  };
@@ -1 +1 @@
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
+ "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 g(i,n){const e=i.clone().date()-n.date();return e!==0?i.subtract(e,"day"):i}function p(i){let n=null;const{intervals:t,exception:e}=i;if(e){const{state:r}=e;r||(n=e)}else{const r=t.sort((o,s)=>O(o.from).hours-O(s.from).hours),[l]=r;return l}return n}function d(i,n,t){var r,l;const e=[];if(n.exception){if(n.exception.state===y.IntervalState.Opened){const o=u(i,n.exception.from,t.utcOffset());t.isBefore(o)&&e.push({interval:n.exception,moment:o})}}else for(let o=0;o<n.intervals.length;o+=1){const s=n.intervals[o],c=u(i,s.from,t.utcOffset());console.log("relevantMoment",t.format()),console.log("openingMoment",c.format()),t.isBefore(c)&&e.push({interval:s,moment:c})}return e.length<2?((r=e[0])==null?void 0:r.interval)??null:((l=e.sort((o,s)=>o.moment-t-(s.moment-t))[0])==null?void 0:l.interval)??null}function h(i,n){let t=null;const e=m(n).format(f.OutletMapKeyFormatter),r=d(e,i[e],n);if(r&&(t=u(e,r.from)),!t)for(let l=1;l<f.OutletTimelineDayCount;l+=1){const o=m(n).add(l,"d"),s=o.format(f.OutletMapKeyFormatter),c=i[s],a=p(c);if(a){t=u(s,a.from),t=g(t,o);break}}return t}module.exports=h;
@@ -1,83 +1,77 @@
1
- import u from "moment";
1
+ import m from "moment";
2
2
  import { IntervalState as p } from "@ancon/wildcat-types";
3
- import m from "../time/getTimeSpanParts.mjs";
3
+ import u from "../time/getTimeSpanParts.mjs";
4
4
  import { OutletMapKeyFormatter as O, OutletTimelineDayCount as g } from "./constants.mjs";
5
- import c from "./getServiceIntervalTimeSpanMoment.mjs";
6
- function y(r, e) {
7
- const t = r.clone().date() - e.date();
8
- return t !== 0 ? r.subtract(t, "day") : r;
5
+ import a from "./getServiceIntervalTimeSpanMoment.mjs";
6
+ function y(i, n) {
7
+ const e = i.clone().date() - n.date();
8
+ return e !== 0 ? i.subtract(e, "day") : i;
9
9
  }
10
- function h(r) {
11
- let e = null;
12
- const { intervals: n, exception: t } = r;
13
- if (t) {
14
- const { state: l } = t;
15
- l || (e = t);
10
+ function d(i) {
11
+ let n = null;
12
+ const { intervals: t, exception: e } = i;
13
+ if (e) {
14
+ const { state: r } = e;
15
+ r || (n = e);
16
16
  } else {
17
- const l = n.sort(
18
- (o, i) => m(o.from).hours - m(i.from).hours
19
- ), [f] = l;
20
- return f;
17
+ const r = t.sort(
18
+ (o, f) => u(o.from).hours - u(f.from).hours
19
+ ), [s] = r;
20
+ return s;
21
21
  }
22
- return e;
22
+ return n;
23
23
  }
24
- function v(r, e, n) {
25
- var l, f;
26
- const t = [];
27
- if (e.exception) {
28
- if (e.exception.state === p.Opened) {
29
- const o = c(
30
- r,
31
- e.exception.from
24
+ function h(i, n, t) {
25
+ var r, s;
26
+ const e = [];
27
+ if (n.exception) {
28
+ if (n.exception.state === p.Opened) {
29
+ const o = a(
30
+ i,
31
+ n.exception.from,
32
+ t.utcOffset()
32
33
  );
33
- n.clone().utc(!0).isBefore(o.clone().utc(!0)) && t.push({
34
- interval: e.exception,
34
+ t.isBefore(o) && e.push({
35
+ interval: n.exception,
35
36
  moment: o
36
37
  });
37
38
  }
38
39
  } else
39
- for (let o = 0; o < e.intervals.length; o += 1) {
40
- const i = e.intervals[o], s = c(
41
- r,
42
- i.from
40
+ for (let o = 0; o < n.intervals.length; o += 1) {
41
+ const f = n.intervals[o], l = a(
42
+ i,
43
+ f.from,
44
+ t.utcOffset()
43
45
  );
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 });
46
+ console.log("relevantMoment", t.format()), console.log("openingMoment", l.format()), t.isBefore(l) && e.push({ interval: f, moment: l });
53
47
  }
54
- return t.length < 2 ? ((l = t[0]) == null ? void 0 : l.interval) ?? null : ((f = t.sort(
48
+ return e.length < 2 ? ((r = e[0]) == null ? void 0 : r.interval) ?? null : ((s = e.sort(
55
49
  // @ts-ignore TODO
56
- (o, i) => o.moment - n - (i.moment - n)
57
- )[0]) == null ? void 0 : f.interval) ?? null;
50
+ (o, f) => o.moment - t - (f.moment - t)
51
+ )[0]) == null ? void 0 : s.interval) ?? null;
58
52
  }
59
- function S(r, e) {
60
- let n = null;
61
- const t = u(e).format(O), l = v(
62
- t,
63
- r[t],
64
- e
53
+ function S(i, n) {
54
+ let t = null;
55
+ const e = m(n).format(O), r = h(
56
+ e,
57
+ i[e],
58
+ n
65
59
  );
66
- if (l && (n = c(
67
- t,
68
- l.from
69
- )), !n)
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) {
73
- n = c(
74
- i,
75
- a.from
76
- ), n = y(n, o);
60
+ if (r && (t = a(
61
+ e,
62
+ r.from
63
+ )), !t)
64
+ for (let s = 1; s < g; s += 1) {
65
+ const o = m(n).add(s, "d"), f = o.format(O), l = i[f], c = d(l);
66
+ if (c) {
67
+ t = a(
68
+ f,
69
+ c.from
70
+ ), t = y(t, o);
77
71
  break;
78
72
  }
79
73
  }
80
- return n;
74
+ return t;
81
75
  }
82
76
  export {
83
77
  S as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.44.0-r13-2-tz.17",
3
+ "version": "1.44.0-r13-2-tz.19",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",