@ancon/wildcat-utils 1.43.0-timezone-refactor.4 → 1.43.0-timezone-refactor.6
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.
- package/outlet/getExpressAvailableOrderFormats.js +1 -1
- package/outlet/getExpressAvailableOrderFormats.mjs +38 -31
- package/outlet/getExpressNextAvailabilityShiftTime.d.ts +1 -1
- package/outlet/getExpressNextAvailabilityShiftTime.js +1 -1
- package/outlet/getExpressNextAvailabilityShiftTime.mjs +22 -14
- package/outlet/getExpressServiceIntervalEnd.d.ts +1 -1
- package/outlet/getExpressServiceIntervalEnd.js +1 -1
- package/outlet/getExpressServiceIntervalEnd.mjs +9 -5
- package/outlet/getExpressServiceIntervalStart.d.ts +1 -1
- package/outlet/getExpressServiceIntervalStart.js +1 -1
- package/outlet/getExpressServiceIntervalStart.mjs +9 -5
- package/outlet/getOutletFormattedAddress.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("@ancon/wildcat-types"),
|
|
1
|
+
"use strict";const r=require("@ancon/wildcat-types"),F=require("moment"),k=require("../shared/constants.js"),d=require("../date/createLocalTimezoneMoment.js"),u=require("./getExpressServiceIntervalStart.js"),m=require("./getExpressServiceIntervalEnd.js");require("../time/getTimeSpanParts.js");const E=[r.OrderFormat.TakeAway,r.OrderFormat.EatIn];function g(i){var c;if(!((c=i.openingHours)!=null&&c.length))return[];const o=F(),{openingHours:p,supportedOrderFormats:f,timeZoneOffset:s}=i,y=[...p].reduce((t,e,q,O)=>{switch(e.type){case r.IntervalType.Exception:{const a=d(e.periodFrom),n=d(e.periodTo),T=u(a,e,s),l=m(n,e,s);if(o.isBetween(T,l,void 0,"[]"))return e.state===r.IntervalState.Closed?(O.splice(1),r.OrderFormat.None):e.orderFormat}break;case r.IntervalType.Normal:default:if(e.dayOfWeek===r.DayOfWeek.Everyday||e.dayOfWeek===k.DaysOfWeekMap[o.isoWeekday()]){const a=u(o,e,s),n=m(o,e,s);if(o.isBetween(a,n,void 0,"[]"))return t|e.orderFormat}break}return t},r.OrderFormat.None);return E.filter(t=>(y&t)===t&&(f&t)===t)}module.exports=g;
|
|
@@ -1,59 +1,66 @@
|
|
|
1
|
-
import { OrderFormat as
|
|
2
|
-
import
|
|
3
|
-
import { DaysOfWeekMap as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { OrderFormat as s, DayOfWeek as g, IntervalType as p, IntervalState as l } from "@ancon/wildcat-types";
|
|
2
|
+
import F from "moment";
|
|
3
|
+
import { DaysOfWeekMap as x } from "../shared/constants.mjs";
|
|
4
|
+
import d from "../date/createLocalTimezoneMoment.mjs";
|
|
5
|
+
import f from "./getExpressServiceIntervalStart.mjs";
|
|
6
6
|
import c from "./getExpressServiceIntervalEnd.mjs";
|
|
7
7
|
import "../time/getTimeSpanParts.mjs";
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
var
|
|
11
|
-
if (!((
|
|
8
|
+
const D = [s.TakeAway, s.EatIn];
|
|
9
|
+
function A(m) {
|
|
10
|
+
var i;
|
|
11
|
+
if (!((i = m.openingHours) != null && i.length))
|
|
12
12
|
return [];
|
|
13
|
-
const t =
|
|
14
|
-
(r, e,
|
|
13
|
+
const t = F(), { openingHours: u, supportedOrderFormats: y, timeZoneOffset: o } = m, O = [...u].reduce(
|
|
14
|
+
(r, e, I, T) => {
|
|
15
15
|
switch (e.type) {
|
|
16
|
-
case
|
|
16
|
+
case p.Exception:
|
|
17
17
|
{
|
|
18
|
-
const
|
|
19
|
-
s,
|
|
20
|
-
e
|
|
21
|
-
), k = c(
|
|
18
|
+
const a = d(e.periodFrom), n = d(e.periodTo), k = f(
|
|
22
19
|
a,
|
|
23
|
-
e
|
|
20
|
+
e,
|
|
21
|
+
o
|
|
22
|
+
), E = c(
|
|
23
|
+
n,
|
|
24
|
+
e,
|
|
25
|
+
o
|
|
24
26
|
);
|
|
25
|
-
if (t.isBetween(
|
|
26
|
-
return e.state ===
|
|
27
|
+
if (t.isBetween(k, E, void 0, "[]"))
|
|
28
|
+
return e.state === l.Closed ? (T.splice(1), s.None) : e.orderFormat;
|
|
27
29
|
}
|
|
28
30
|
break;
|
|
29
|
-
case
|
|
31
|
+
case p.Normal:
|
|
30
32
|
default:
|
|
31
33
|
if (
|
|
32
34
|
// Every day in the week
|
|
33
|
-
e.dayOfWeek ===
|
|
34
|
-
e.dayOfWeek ===
|
|
35
|
+
e.dayOfWeek === g.Everyday || // Specific day in the week
|
|
36
|
+
e.dayOfWeek === x[t.isoWeekday()]
|
|
35
37
|
) {
|
|
36
|
-
const
|
|
38
|
+
const a = f(
|
|
37
39
|
t,
|
|
38
|
-
e
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
e,
|
|
41
|
+
o
|
|
42
|
+
), n = c(
|
|
43
|
+
t,
|
|
44
|
+
e,
|
|
45
|
+
o
|
|
46
|
+
);
|
|
47
|
+
if (t.isBetween(a, n, void 0, "[]"))
|
|
41
48
|
return r | e.orderFormat;
|
|
42
49
|
}
|
|
43
50
|
break;
|
|
44
51
|
}
|
|
45
52
|
return r;
|
|
46
53
|
},
|
|
47
|
-
|
|
54
|
+
s.None
|
|
48
55
|
);
|
|
49
|
-
return
|
|
56
|
+
return D.filter(
|
|
50
57
|
(r) => (
|
|
51
58
|
// Check if the order format is available
|
|
52
|
-
(
|
|
53
|
-
(
|
|
59
|
+
(O & r) === r && // Check if the order format is supported by the outlet
|
|
60
|
+
(y & r) === r
|
|
54
61
|
)
|
|
55
62
|
);
|
|
56
63
|
}
|
|
57
64
|
export {
|
|
58
|
-
|
|
65
|
+
A as default
|
|
59
66
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OpeningHoursInterval } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
|
-
export default function getExpressNextAvailabilityShiftTime(openingHours: Array<OpeningHoursInterval
|
|
3
|
+
export default function getExpressNextAvailabilityShiftTime(openingHours: Array<OpeningHoursInterval>, outletTimezoneOffset?: string): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const o=require("@ancon/wildcat-types"),u=require("moment"),m=require("../shared/constants.js"),d=require("../date/createLocalTimezoneMoment.js"),x=require("./getExpressServiceIntervalStart.js"),E=require("./getExpressServiceIntervalEnd.js");require("../time/getTimeSpanParts.js");function T(p,s){const t=u();let r=t.clone().add(1,"day").startOf("day");function i(e){const n=e.type===o.IntervalType.Exception,y=n?d(e.periodFrom):t,f=n?d(e.periodTo):t,a=x(y,e,s),c=E(f,e,s);a.isBetween(t,r)?r=a:c.isBetween(t,r)&&(r=c)}return p.forEach(e=>{switch(e.type){case o.IntervalType.Exception:i(e);break;case o.IntervalType.Normal:default:(e.dayOfWeek===o.DayOfWeek.Everyday||e.dayOfWeek===m.DaysOfWeekMap[t.isoWeekday()])&&i(e);break}}),r}module.exports=T;
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
import { DayOfWeek as
|
|
2
|
-
import
|
|
3
|
-
import { DaysOfWeekMap as
|
|
1
|
+
import { DayOfWeek as y, IntervalType as r } from "@ancon/wildcat-types";
|
|
2
|
+
import x from "moment";
|
|
3
|
+
import { DaysOfWeekMap as E } from "../shared/constants.mjs";
|
|
4
4
|
import f from "../date/createLocalTimezoneMoment.mjs";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import k from "./getExpressServiceIntervalStart.mjs";
|
|
6
|
+
import S from "./getExpressServiceIntervalEnd.mjs";
|
|
7
7
|
import "../time/getTimeSpanParts.mjs";
|
|
8
|
-
function
|
|
9
|
-
const t =
|
|
8
|
+
function O(n, i) {
|
|
9
|
+
const t = x();
|
|
10
10
|
let o = t.clone().add(1, "day").startOf("day");
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
|
|
11
|
+
function a(e) {
|
|
12
|
+
const m = e.type === r.Exception, p = m ? f(e.periodFrom) : t, d = m ? f(e.periodTo) : t, s = k(
|
|
13
|
+
p,
|
|
14
|
+
e,
|
|
15
|
+
i
|
|
16
|
+
), c = S(
|
|
17
|
+
d,
|
|
18
|
+
e,
|
|
19
|
+
i
|
|
20
|
+
);
|
|
21
|
+
s.isBetween(t, o) ? o = s : c.isBetween(t, o) && (o = c);
|
|
14
22
|
}
|
|
15
23
|
return n.forEach((e) => {
|
|
16
24
|
switch (e.type) {
|
|
17
25
|
case r.Exception:
|
|
18
|
-
|
|
26
|
+
a(e);
|
|
19
27
|
break;
|
|
20
28
|
case r.Normal:
|
|
21
29
|
default:
|
|
22
30
|
// Every day in the week
|
|
23
|
-
(e.dayOfWeek ===
|
|
24
|
-
e.dayOfWeek ===
|
|
31
|
+
(e.dayOfWeek === y.Everyday || // Specific day in the week
|
|
32
|
+
e.dayOfWeek === E[t.isoWeekday()]) && a(e);
|
|
25
33
|
break;
|
|
26
34
|
}
|
|
27
35
|
}), o;
|
|
28
36
|
}
|
|
29
37
|
export {
|
|
30
|
-
|
|
38
|
+
O as default
|
|
31
39
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OpeningHoursInterval } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
|
-
export default function getExpressServiceIntervalEnd(date: Moment, interval: OpeningHoursInterval): Moment;
|
|
3
|
+
export default function getExpressServiceIntervalEnd(date: Moment, interval: OpeningHoursInterval, outletTimezoneOffset?: string): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e=require("../time/getTimeSpanParts.js");function a(s,n,o){const c=e(n.from),u=e(n.duration),t=s.clone().hour(c.hours).minute(c.minutes).second(0).millisecond(0);if(t.add(u),o){const i=e(o),r=i.hours*60+i.minutes,f=s.utcOffset()-r;t.add(f,"minute")}return t}module.exports=a;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
|
|
1
|
+
import e from "../time/getTimeSpanParts.mjs";
|
|
2
|
+
function m(n, s, o) {
|
|
3
|
+
const c = e(s.from), f = e(s.duration), t = n.clone().hour(c.hours).minute(c.minutes).second(0).millisecond(0);
|
|
4
|
+
if (t.add(f), o) {
|
|
5
|
+
const i = e(o), u = i.hours * 60 + i.minutes, r = n.utcOffset() - u;
|
|
6
|
+
t.add(r, "minute");
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
5
9
|
}
|
|
6
10
|
export {
|
|
7
|
-
|
|
11
|
+
m as default
|
|
8
12
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OpeningHoursInterval } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
|
-
export default function getExpressServiceIntervalStart(date: Moment, interval: OpeningHoursInterval): Moment;
|
|
3
|
+
export default function getExpressServiceIntervalStart(date: Moment, interval: OpeningHoursInterval, outletTimezoneOffset?: string): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const i=require("../time/getTimeSpanParts.js");function f(t,o,e){const s=i(o.from),n=t.clone().hour(s.hours).minute(s.minutes).second(0).millisecond(0);if(e){const c=i(e),r=c.hours*60+c.minutes,u=t.utcOffset()-r;n.add(u,"minute")}return n}module.exports=f;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
|
|
1
|
+
import c from "../time/getTimeSpanParts.mjs";
|
|
2
|
+
function m(t, f, e) {
|
|
3
|
+
const s = c(f.from), n = t.clone().hour(s.hours).minute(s.minutes).second(0).millisecond(0);
|
|
4
|
+
if (e) {
|
|
5
|
+
const o = c(e), i = o.hours * 60 + o.minutes, r = t.utcOffset() - i;
|
|
6
|
+
n.add(r, "minute");
|
|
7
|
+
}
|
|
8
|
+
return n;
|
|
5
9
|
}
|
|
6
10
|
export {
|
|
7
|
-
|
|
11
|
+
m as default
|
|
8
12
|
};
|
|
@@ -5,5 +5,5 @@ declare type StreetCity = {
|
|
|
5
5
|
declare type FormatOptions = {
|
|
6
6
|
streetMaxLength?: number;
|
|
7
7
|
};
|
|
8
|
-
export default function getOutletFormattedAddress<OutletAddress extends StreetCity>(address: OutletAddress, options?: FormatOptions): string;
|
|
8
|
+
export default function getOutletFormattedAddress<OutletAddress extends StreetCity>(address: OutletAddress | undefined, options?: FormatOptions): string;
|
|
9
9
|
export {};
|