@ancon/wildcat-utils 1.44.0-timezone-refactor.1 → 1.44.0

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.
Files changed (100) hide show
  1. package/checkout/checkoutHasWallet.d.ts +3 -0
  2. package/checkout/getCheckoutRequestItemFromCheckoutItem.d.ts +2 -2
  3. package/checkout/getCheckoutRequestItemFromCheckoutItem.js +1 -1
  4. package/checkout/getCheckoutRequestItemFromCheckoutItem.mjs +26 -14
  5. package/checkout/getCheckoutWalletTopUpMetaData.d.ts +7 -0
  6. package/checkout/getCheckoutWalletTopUpMetaData.js +1 -0
  7. package/checkout/getCheckoutWalletTopUpMetaData.mjs +15 -0
  8. package/checkout/getWalletMetaFromCheckout.d.ts +3 -0
  9. package/checkout/index.d.ts +4 -1
  10. package/checkout/index.js +1 -1
  11. package/checkout/index.mjs +25 -19
  12. package/checkout/isWalletTopUpCheckout.d.ts +2 -0
  13. package/checkout/isWalletTopUpCheckout.js +1 -0
  14. package/checkout/isWalletTopUpCheckout.mjs +12 -0
  15. package/checkout/isWalletTopUpCheckoutItem.d.ts +2 -0
  16. package/checkout/isWalletTopUpCheckoutItem.js +1 -0
  17. package/checkout/isWalletTopUpCheckoutItem.mjs +9 -0
  18. package/courses/constants.js +1 -1
  19. package/courses/constants.mjs +1 -1
  20. package/date/convertToLocalTimezone.d.ts +8 -0
  21. package/date/convertToLocalTimezone.js +1 -0
  22. package/date/convertToLocalTimezone.mjs +12 -0
  23. package/date/convertToSpecificTimezone.d.ts +9 -0
  24. package/date/convertToSpecificTimezone.js +1 -0
  25. package/date/convertToSpecificTimezone.mjs +6 -0
  26. package/date/getTimezoneUtcOffsetDifference.d.ts +8 -0
  27. package/date/getTimezoneUtcOffsetDifference.js +1 -0
  28. package/date/getTimezoneUtcOffsetDifference.mjs +8 -0
  29. package/date/index.d.ts +5 -1
  30. package/date/index.js +1 -1
  31. package/date/index.mjs +14 -6
  32. package/date/isDSTShiftPresentInRange.d.ts +8 -0
  33. package/date/isDSTShiftPresentInRange.js +1 -0
  34. package/date/isDSTShiftPresentInRange.mjs +9 -0
  35. package/hangfire/createHangfirePoller.d.ts +8 -2
  36. package/hangfire/createHangfirePoller.js +1 -1
  37. package/hangfire/createHangfirePoller.mjs +72 -62
  38. package/hangfire/createMakeHangfireRequest.d.ts +10 -1
  39. package/hangfire/createMakeHangfireRequest.js +1 -1
  40. package/hangfire/createMakeHangfireRequest.mjs +16 -14
  41. package/index.js +1 -1
  42. package/index.mjs +216 -198
  43. package/outlet/getOutletCurrentActiveOperatingHour.js +1 -1
  44. package/outlet/getOutletCurrentActiveOperatingHour.mjs +26 -21
  45. package/outlet/getOutletCurrentAvailabilityInfo.js +1 -1
  46. package/outlet/getOutletCurrentAvailabilityInfo.mjs +18 -15
  47. package/outlet/getOutletNextOpeningTagInformation.js +1 -1
  48. package/outlet/getOutletNextOpeningTagInformation.mjs +13 -10
  49. package/outlet/getOutletNextOpeningTimeText.js +1 -1
  50. package/outlet/getOutletNextOpeningTimeText.mjs +12 -9
  51. package/outlet/getOutletNextReadyToOrderTime.js +1 -1
  52. package/outlet/getOutletNextReadyToOrderTime.mjs +38 -26
  53. package/outlet/getOutletPickerTimesForDay.js +1 -1
  54. package/outlet/getOutletPickerTimesForDay.mjs +101 -46
  55. package/outlet/getOutletPickerTimesForWeek.js +1 -1
  56. package/outlet/getOutletPickerTimesForWeek.mjs +13 -8
  57. package/outlet/getOutletTagInformation.js +1 -1
  58. package/outlet/getOutletTagInformation.mjs +64 -62
  59. package/outlet/getServiceIntervalEnd.js +1 -1
  60. package/outlet/getServiceIntervalEnd.mjs +11 -10
  61. package/outlet/getServiceIntervalStart.js +1 -1
  62. package/outlet/getServiceIntervalStart.mjs +7 -6
  63. package/outlet/getServiceIntervalTimeSpanMoment.d.ts +9 -0
  64. package/outlet/getServiceIntervalTimeSpanMoment.js +1 -0
  65. package/outlet/getServiceIntervalTimeSpanMoment.mjs +9 -0
  66. package/outlet/getTimezoneAdjustedServiceInterval.d.ts +14 -0
  67. package/outlet/getTimezoneAdjustedServiceInterval.js +1 -0
  68. package/outlet/getTimezoneAdjustedServiceInterval.mjs +26 -0
  69. package/outlet/index.js +1 -1
  70. package/outlet/index.mjs +69 -66
  71. package/outlet/searchNextOpeningMoment.js +1 -1
  72. package/outlet/searchNextOpeningMoment.mjs +61 -58
  73. package/outlet/types.d.ts +6 -0
  74. package/outlet/types.js +1 -1
  75. package/outlet/types.mjs +3 -2
  76. package/package.json +56 -11
  77. package/time/convertSecondsToTimeSpan.d.ts +9 -0
  78. package/time/convertSecondsToTimeSpan.js +1 -0
  79. package/time/convertSecondsToTimeSpan.mjs +12 -0
  80. package/time/convertTimeSpanToSeconds.d.ts +6 -0
  81. package/time/convertTimeSpanToSeconds.js +1 -0
  82. package/time/convertTimeSpanToSeconds.mjs +8 -0
  83. package/time/createTimeSpan.js +1 -1
  84. package/time/createTimeSpan.mjs +10 -5
  85. package/time/formatTimeSpan.js +1 -1
  86. package/time/formatTimeSpan.mjs +5 -4
  87. package/time/getDurationBetweenTimeSpans.d.ts +2 -2
  88. package/time/getDurationBetweenTimeSpans.js +1 -1
  89. package/time/getDurationBetweenTimeSpans.mjs +11 -9
  90. package/time/getEndTimeSpanOfTimePeriod.js +1 -1
  91. package/time/getEndTimeSpanOfTimePeriod.mjs +8 -6
  92. package/time/index.d.ts +3 -1
  93. package/time/index.js +1 -1
  94. package/time/index.mjs +16 -12
  95. package/outlet/getMomentFromDateAndTimeString.d.ts +0 -3
  96. package/outlet/getMomentFromDateAndTimeString.js +0 -1
  97. package/outlet/getMomentFromDateAndTimeString.mjs +0 -17
  98. package/outlet/getNextTenthMinute.d.ts +0 -2
  99. package/outlet/getNextTenthMinute.js +0 -1
  100. package/outlet/getNextTenthMinute.mjs +0 -7
@@ -1,76 +1,79 @@
1
- import u from "moment";
1
+ import c from "moment";
2
2
  import { IntervalState as p } from "@ancon/wildcat-types";
3
- import c from "../time/getTimeSpanParts.mjs";
4
- import { OutletMapKeyFormatter as O, OutletTimelineDayCount as y } from "./constants.mjs";
5
- import a from "./getMomentFromDateAndTimeString.mjs";
6
- function d(i, e) {
7
- const t = i.clone().date() - e.date();
8
- return t !== 0 ? i.subtract(t, "day") : i;
9
- }
10
- function g(i) {
11
- let e = null;
12
- const { intervals: n, exception: t } = i;
13
- if (t) {
14
- const { state: r } = t;
15
- r || (e = t);
3
+ import a from "../time/getTimeSpanParts.mjs";
4
+ import { OutletMapKeyFormatter as d, OutletTimelineDayCount as O } from "./constants.mjs";
5
+ import f from "./getTimezoneAdjustedServiceInterval.mjs";
6
+ import "../date/getTimezoneUtcOffsetDifference.mjs";
7
+ import "../date/convertToSpecificTimezone.mjs";
8
+ import "./getServiceIntervalTimeSpanMoment.mjs";
9
+ function g(l) {
10
+ let t = null;
11
+ const { intervals: e, exception: n } = l;
12
+ if (n) {
13
+ const { state: r } = n;
14
+ r || (t = n);
16
15
  } else {
17
- const r = n.sort(
18
- (o, s) => c(o.from).hours - c(s.from).hours
19
- ), [f] = r;
20
- return f;
16
+ const r = e.sort(
17
+ (i, o) => a(i.from).hours - a(o.from).hours
18
+ ), [s] = r;
19
+ return s;
21
20
  }
22
- return e;
21
+ return t;
23
22
  }
24
- function h(i, e, n) {
25
- var r, f;
26
- const t = [];
27
- if (e.exception) {
28
- if (e.exception.state === p.Opened) {
29
- const o = a(
30
- i,
31
- e.exception.from
32
- );
33
- n.isBefore(o) && t.push({
34
- interval: e.exception,
23
+ function v(l, t, e) {
24
+ var r, s;
25
+ const n = [];
26
+ if (t.exception) {
27
+ if (t.exception.state === p.Opened) {
28
+ const o = f(
29
+ l,
30
+ t.exception,
31
+ e.utcOffset()
32
+ ).openingTime;
33
+ e.isBefore(o) && n.push({
34
+ interval: t.exception,
35
35
  moment: o
36
36
  });
37
37
  }
38
38
  } else
39
- for (let o = 0; o < e.intervals.length; o += 1) {
40
- const s = e.intervals[o], l = a(
41
- i,
42
- s.from
43
- );
44
- n.isBefore(l) && t.push({ interval: s, moment: l });
39
+ for (let i = 0; i < t.intervals.length; i += 1) {
40
+ const o = t.intervals[i], u = f(
41
+ l,
42
+ o,
43
+ e.utcOffset()
44
+ ).openingTime;
45
+ e.isBefore(u) && n.push({ interval: o, moment: u });
45
46
  }
46
- return t.length < 2 ? ((r = t[0]) == null ? void 0 : r.interval) ?? null : ((f = t.sort(
47
+ return n.length < 2 ? ((r = n[0]) == null ? void 0 : r.interval) ?? null : ((s = n.sort(
47
48
  // @ts-ignore TODO
48
- (o, s) => o.moment - n - (s.moment - n)
49
- )[0]) == null ? void 0 : f.interval) ?? null;
49
+ (i, o) => i.moment - e - (o.moment - e)
50
+ )[0]) == null ? void 0 : s.interval) ?? null;
50
51
  }
51
- function S(i, e) {
52
- let n = null;
53
- const t = u(e).format(O), r = h(
54
- t,
55
- i[t],
56
- e
52
+ function K(l, t) {
53
+ let e = null;
54
+ const n = c(t).format(d), r = v(
55
+ n,
56
+ l[n],
57
+ t
57
58
  );
58
- if (r && (n = a(
59
- t,
60
- r.from
61
- )), !n)
62
- for (let f = 1; f < y; f += 1) {
63
- const o = u(e).add(f, "d"), s = o.format(O), l = i[s], m = g(l);
64
- if (m) {
65
- n = a(
66
- s,
67
- m.from
68
- ), n = d(n, o);
59
+ if (r && (e = f(
60
+ n,
61
+ r,
62
+ t.utcOffset()
63
+ ).openingTime), !e)
64
+ for (let s = 1; s < O; s += 1) {
65
+ const i = c(t).add(s, "d"), o = i.format(d), m = l[o], u = g(m);
66
+ if (u) {
67
+ e = f(
68
+ o,
69
+ u,
70
+ i.utcOffset()
71
+ ).openingTime;
69
72
  break;
70
73
  }
71
74
  }
72
- return n;
75
+ return e;
73
76
  }
74
77
  export {
75
- S as default
78
+ K as default
76
79
  };
package/outlet/types.d.ts CHANGED
@@ -24,9 +24,15 @@ export declare enum OutletListSection {
24
24
  OrderNow = "OrderNow",
25
25
  Closed = "Closed"
26
26
  }
27
+ export declare enum PickerTimeTimezoneTag {
28
+ Standard = 0,
29
+ Summer = 1
30
+ }
27
31
  export declare type PickerTime = {
28
32
  timestamp: number;
29
33
  timeLabel: string;
30
34
  dayLabel: string;
35
+ /** This is available for time label duplicated picker times in an interval that has a DST shift */
36
+ timezoneTag?: PickerTimeTimezoneTag;
31
37
  };
32
38
  export declare type PickerDay = PickerTime[];
package/outlet/types.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(r=>(r.PreOrder="PreOrder",r.OrderNow="OrderNow",r.Closed="Closed",r))(e||{});exports.OutletListSection=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var d=(r=>(r.PreOrder="PreOrder",r.OrderNow="OrderNow",r.Closed="Closed",r))(d||{}),e=(r=>(r[r.Standard=0]="Standard",r[r.Summer=1]="Summer",r))(e||{});exports.OutletListSection=d;exports.PickerTimeTimezoneTag=e;
package/outlet/types.mjs CHANGED
@@ -1,4 +1,5 @@
1
- var d = /* @__PURE__ */ ((r) => (r.PreOrder = "PreOrder", r.OrderNow = "OrderNow", r.Closed = "Closed", r))(d || {});
1
+ var d = /* @__PURE__ */ ((r) => (r.PreOrder = "PreOrder", r.OrderNow = "OrderNow", r.Closed = "Closed", r))(d || {}), a = /* @__PURE__ */ ((r) => (r[r.Standard = 0] = "Standard", r[r.Summer = 1] = "Summer", r))(a || {});
2
2
  export {
3
- d as OutletListSection
3
+ d as OutletListSection,
4
+ a as PickerTimeTimezoneTag
4
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.44.0-timezone-refactor.1",
3
+ "version": "1.44.0",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -156,6 +156,11 @@
156
156
  "require": "./checkout/getCheckoutRequestItemFromCheckoutItem.js",
157
157
  "types": "./checkout/getCheckoutRequestItemFromCheckoutItem.d.ts"
158
158
  },
159
+ "./checkout/getCheckoutWalletTopUpMetaData": {
160
+ "import": "./checkout/getCheckoutWalletTopUpMetaData.mjs",
161
+ "require": "./checkout/getCheckoutWalletTopUpMetaData.js",
162
+ "types": "./checkout/getCheckoutWalletTopUpMetaData.d.ts"
163
+ },
159
164
  "./checkout/getTotalCheckoutItemsQuantity": {
160
165
  "import": "./checkout/getTotalCheckoutItemsQuantity.mjs",
161
166
  "require": "./checkout/getTotalCheckoutItemsQuantity.js",
@@ -211,6 +216,16 @@
211
216
  "require": "./checkout/isUpdatingCheckoutAllowed.js",
212
217
  "types": "./checkout/isUpdatingCheckoutAllowed.d.ts"
213
218
  },
219
+ "./checkout/isWalletTopUpCheckout": {
220
+ "import": "./checkout/isWalletTopUpCheckout.mjs",
221
+ "require": "./checkout/isWalletTopUpCheckout.js",
222
+ "types": "./checkout/isWalletTopUpCheckout.d.ts"
223
+ },
224
+ "./checkout/isWalletTopUpCheckoutItem": {
225
+ "import": "./checkout/isWalletTopUpCheckoutItem.mjs",
226
+ "require": "./checkout/isWalletTopUpCheckoutItem.js",
227
+ "types": "./checkout/isWalletTopUpCheckoutItem.d.ts"
228
+ },
214
229
  "./checkout/isWoltDeliveryInProgress": {
215
230
  "import": "./checkout/isWoltDeliveryInProgress.mjs",
216
231
  "require": "./checkout/isWoltDeliveryInProgress.js",
@@ -286,6 +301,16 @@
286
301
  "require": "./currency/index.js",
287
302
  "types": "./currency/index.d.ts"
288
303
  },
304
+ "./date/convertToLocalTimezone": {
305
+ "import": "./date/convertToLocalTimezone.mjs",
306
+ "require": "./date/convertToLocalTimezone.js",
307
+ "types": "./date/convertToLocalTimezone.d.ts"
308
+ },
309
+ "./date/convertToSpecificTimezone": {
310
+ "import": "./date/convertToSpecificTimezone.mjs",
311
+ "require": "./date/convertToSpecificTimezone.js",
312
+ "types": "./date/convertToSpecificTimezone.d.ts"
313
+ },
289
314
  "./date/createLocalTimezoneDate": {
290
315
  "import": "./date/createLocalTimezoneDate.mjs",
291
316
  "require": "./date/createLocalTimezoneDate.js",
@@ -301,11 +326,21 @@
301
326
  "require": "./date/getFormattedUTCDateTime.js",
302
327
  "types": "./date/getFormattedUTCDateTime.d.ts"
303
328
  },
329
+ "./date/getTimezoneUtcOffsetDifference": {
330
+ "import": "./date/getTimezoneUtcOffsetDifference.mjs",
331
+ "require": "./date/getTimezoneUtcOffsetDifference.js",
332
+ "types": "./date/getTimezoneUtcOffsetDifference.d.ts"
333
+ },
304
334
  "./date": {
305
335
  "import": "./date/index.mjs",
306
336
  "require": "./date/index.js",
307
337
  "types": "./date/index.d.ts"
308
338
  },
339
+ "./date/isDSTShiftPresentInRange": {
340
+ "import": "./date/isDSTShiftPresentInRange.mjs",
341
+ "require": "./date/isDSTShiftPresentInRange.js",
342
+ "types": "./date/isDSTShiftPresentInRange.d.ts"
343
+ },
309
344
  "./error/createCodedError": {
310
345
  "import": "./error/createCodedError.mjs",
311
346
  "require": "./error/createCodedError.js",
@@ -596,16 +631,6 @@
596
631
  "require": "./outlet/getListOutletOpeningHoursTable.js",
597
632
  "types": "./outlet/getListOutletOpeningHoursTable.d.ts"
598
633
  },
599
- "./outlet/getMomentFromDateAndTimeString": {
600
- "import": "./outlet/getMomentFromDateAndTimeString.mjs",
601
- "require": "./outlet/getMomentFromDateAndTimeString.js",
602
- "types": "./outlet/getMomentFromDateAndTimeString.d.ts"
603
- },
604
- "./outlet/getNextTenthMinute": {
605
- "import": "./outlet/getNextTenthMinute.mjs",
606
- "require": "./outlet/getNextTenthMinute.js",
607
- "types": "./outlet/getNextTenthMinute.d.ts"
608
- },
609
634
  "./outlet/getOrderFormatAOTipSettings": {
610
635
  "import": "./outlet/getOrderFormatAOTipSettings.mjs",
611
636
  "require": "./outlet/getOrderFormatAOTipSettings.js",
@@ -741,6 +766,11 @@
741
766
  "require": "./outlet/getServiceIntervalStart.js",
742
767
  "types": "./outlet/getServiceIntervalStart.d.ts"
743
768
  },
769
+ "./outlet/getServiceIntervalTimeSpanMoment": {
770
+ "import": "./outlet/getServiceIntervalTimeSpanMoment.mjs",
771
+ "require": "./outlet/getServiceIntervalTimeSpanMoment.js",
772
+ "types": "./outlet/getServiceIntervalTimeSpanMoment.d.ts"
773
+ },
744
774
  "./outlet/getServiceIntervalsForOrderFormat": {
745
775
  "import": "./outlet/getServiceIntervalsForOrderFormat.mjs",
746
776
  "require": "./outlet/getServiceIntervalsForOrderFormat.js",
@@ -756,6 +786,11 @@
756
786
  "require": "./outlet/getStructuredOutletAddress.js",
757
787
  "types": "./outlet/getStructuredOutletAddress.d.ts"
758
788
  },
789
+ "./outlet/getTimezoneAdjustedServiceInterval": {
790
+ "import": "./outlet/getTimezoneAdjustedServiceInterval.mjs",
791
+ "require": "./outlet/getTimezoneAdjustedServiceInterval.js",
792
+ "types": "./outlet/getTimezoneAdjustedServiceInterval.d.ts"
793
+ },
759
794
  "./outlet/hoursAndMinutesToMinutes": {
760
795
  "import": "./outlet/hoursAndMinutesToMinutes.mjs",
761
796
  "require": "./outlet/hoursAndMinutesToMinutes.js",
@@ -1046,6 +1081,16 @@
1046
1081
  "require": "./ticketItem/isTicketItemReady.js",
1047
1082
  "types": "./ticketItem/isTicketItemReady.d.ts"
1048
1083
  },
1084
+ "./time/convertSecondsToTimeSpan": {
1085
+ "import": "./time/convertSecondsToTimeSpan.mjs",
1086
+ "require": "./time/convertSecondsToTimeSpan.js",
1087
+ "types": "./time/convertSecondsToTimeSpan.d.ts"
1088
+ },
1089
+ "./time/convertTimeSpanToSeconds": {
1090
+ "import": "./time/convertTimeSpanToSeconds.mjs",
1091
+ "require": "./time/convertTimeSpanToSeconds.js",
1092
+ "types": "./time/convertTimeSpanToSeconds.d.ts"
1093
+ },
1049
1094
  "./time/createTimeSpan": {
1050
1095
  "import": "./time/createTimeSpan.mjs",
1051
1096
  "require": "./time/createTimeSpan.js",
@@ -0,0 +1,9 @@
1
+ import { TimeFormat } from './types';
2
+ /**
3
+ * This function converts the given seconds to a time span.
4
+ *
5
+ * @param seconds The seconds to convert.
6
+ * @param format The format of the time. Default is `HH:mm`.
7
+ * @returns The formatted time span.
8
+ */
9
+ export default function convertSecondsToTimeSpan(seconds: number, format?: TimeFormat): string;
@@ -0,0 +1 @@
1
+ "use strict";const s=require("./createTimeSpan.js");function i(t,n="HH:mm"){const e=Math.floor(t/3600),o=Math.floor(t%3600/60),r=t%60;return s({hours:e,minutes:o,seconds:r},n)}module.exports=i;
@@ -0,0 +1,12 @@
1
+ import a from "./createTimeSpan.mjs";
2
+ function s(t, n = "HH:mm") {
3
+ const o = Math.floor(t / 3600), e = Math.floor(t % 3600 / 60), r = t % 60;
4
+ return a({
5
+ hours: o,
6
+ minutes: e,
7
+ seconds: r
8
+ }, n);
9
+ }
10
+ export {
11
+ s as default
12
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Converts a time span in the format `HH:mm:ss` to seconds.
3
+ * @param timeSpan The time span to convert.
4
+ * @returns The time span in seconds.
5
+ */
6
+ export default function convertTimeSpanToSeconds(timeSpan: string): number;
@@ -0,0 +1 @@
1
+ "use strict";const o=require("./getTimeSpanParts.js");function r(e){const{hours:t,minutes:n,seconds:s}=o(e);return t*3600+n*60+(s??0)}module.exports=r;
@@ -0,0 +1,8 @@
1
+ import r from "./getTimeSpanParts.mjs";
2
+ function a(e) {
3
+ const { hours: n, minutes: o, seconds: t } = r(e);
4
+ return n * 3600 + o * 60 + (t ?? 0);
5
+ }
6
+ export {
7
+ a as default
8
+ };
@@ -1 +1 @@
1
- "use strict";const n=require("moment");function r(t,m="HH:mm"){const e=n("00:00:00","HH:mm:ss");return e.add(t),e.format(m)}module.exports=r;
1
+ "use strict";function m(n,r="HH:mm"){const{hours:e,minutes:a,seconds:c}=n,t=e.toString().padStart(2,"0"),s=a.toString().padStart(2,"0"),o=(c??0).toString().padStart(2,"0");switch(r){case"HH:mm:ss":return`${t}:${s}:${o}`;case"HH:mm":default:return`${t}:${s}`}}module.exports=m;
@@ -1,8 +1,13 @@
1
- import o from "moment";
2
- function n(t, e = "HH:mm") {
3
- const m = o("00:00:00", "HH:mm:ss");
4
- return m.add(t), m.format(e);
1
+ function m(n, a = "HH:mm") {
2
+ const { hours: r, minutes: e, seconds: o } = n, t = r.toString().padStart(2, "0"), s = e.toString().padStart(2, "0"), c = (o ?? 0).toString().padStart(2, "0");
3
+ switch (a) {
4
+ case "HH:mm:ss":
5
+ return `${t}:${s}:${c}`;
6
+ case "HH:mm":
7
+ default:
8
+ return `${t}:${s}`;
9
+ }
5
10
  }
6
11
  export {
7
- n as default
12
+ m as default
8
13
  };
@@ -1 +1 @@
1
- "use strict";const r=require("moment");function e(m,t="HH:mm"){return r(m,"HH:mm:ss").format(t)}module.exports=e;
1
+ "use strict";const r=require("./getTimeSpanParts.js"),i=require("./createTimeSpan.js");function m(e,t="HH:mm"){return i(r(e),t)}module.exports=m;
@@ -1,7 +1,8 @@
1
- import o from "moment";
2
- function a(m, t = "HH:mm") {
3
- return o(m, "HH:mm:ss").format(t);
1
+ import t from "./getTimeSpanParts.mjs";
2
+ import e from "./createTimeSpan.mjs";
3
+ function i(m, r = "HH:mm") {
4
+ return e(t(m), r);
4
5
  }
5
6
  export {
6
- a as default
7
+ i as default
7
8
  };
@@ -1,11 +1,11 @@
1
1
  import { TimeFormat } from './types';
2
2
  /**
3
- * This function gets the duration between `from` and `to` time spans.
4
- * If the `to` time span is before the `from` time span, it will return the duration of the next day.
3
+ * This function gets the duration between `from` and `to` time spans of a day.
5
4
  *
6
5
  * @param fromTimeSpan The start time span.
7
6
  * @param toTimeSpan The end time span.
8
7
  * @param format The format of the time. Default is `HH:mm`.
8
+ * @throws An error if the `to` time span is before the `from` time span.
9
9
  * @returns The duration time span between the two time spans.
10
10
  */
11
11
  export default function getDurationBetweenTimeSpans(fromTimeSpan: string, toTimeSpan: string, format?: TimeFormat): string;
@@ -1 +1 @@
1
- "use strict";const t=require("moment"),u=require("./createTimeSpan.js");function a(n,s,o="HH:mm"){const m=t(n,"HH:mm:ss"),i=t(s,"HH:mm:ss"),e=t.duration(i.diff(m)),r={hours:e.hours(),minutes:e.minutes(),seconds:e.seconds()};return u(r,o)}module.exports=a;
1
+ "use strict";const i=require("./convertSecondsToTimeSpan.js"),n=require("./convertTimeSpanToSeconds.js");require("./createTimeSpan.js");require("./getTimeSpanParts.js");function c(o,t,r="HH:mm"){const s=n(o),e=n(t)-s;if(e<0)throw new Error("The `to` time span should be greater than the `from` time span.");return i(e,r)}module.exports=c;
@@ -1,12 +1,14 @@
1
- import e from "moment";
2
- import a from "./createTimeSpan.mjs";
3
- function d(o, m, n = "HH:mm") {
4
- const s = e(o, "HH:mm:ss"), r = e(m, "HH:mm:ss"), t = e.duration(r.diff(s)), i = {
5
- hours: t.hours(),
6
- minutes: t.minutes(),
7
- seconds: t.seconds()
8
- };
9
- return a(i, n);
1
+ import s from "./convertSecondsToTimeSpan.mjs";
2
+ import e from "./convertTimeSpanToSeconds.mjs";
3
+ import "./createTimeSpan.mjs";
4
+ import "./getTimeSpanParts.mjs";
5
+ function d(n, t, r = "HH:mm") {
6
+ const m = e(n), o = e(t) - m;
7
+ if (o < 0)
8
+ throw new Error(
9
+ "The `to` time span should be greater than the `from` time span."
10
+ );
11
+ return s(o, r);
10
12
  }
11
13
  export {
12
14
  d as default
@@ -1 +1 @@
1
- "use strict";const c=require("moment"),o=require("./getTimeSpanParts.js");function u(n,m="HH:mm"){const{from:r,duration:i}=n,e=o(r),s=o(i),t=c().startOf("day").hour(e.hours).minute(e.minutes).second(e.seconds??0).millisecond(0);return t.add(s),t.format(m)}module.exports=u;
1
+ "use strict";const m=require("./convertSecondsToTimeSpan.js"),e=require("./convertTimeSpanToSeconds.js");require("./createTimeSpan.js");require("./getTimeSpanParts.js");function d(n,o="HH:mm"){const{from:r,duration:t}=n,i=e(r),c=e(t),s=i+c;return m(s,o)}module.exports=d;
@@ -1,9 +1,11 @@
1
- import a from "moment";
2
- import m from "./getTimeSpanParts.mjs";
3
- function u(e, n = "HH:mm") {
4
- const { from: r, duration: i } = e, o = m(r), s = m(i), t = a().startOf("day").hour(o.hours).minute(o.minutes).second(o.seconds ?? 0).millisecond(0);
5
- return t.add(s), t.format(n);
1
+ import d from "./convertSecondsToTimeSpan.mjs";
2
+ import o from "./convertTimeSpanToSeconds.mjs";
3
+ import "./createTimeSpan.mjs";
4
+ import "./getTimeSpanParts.mjs";
5
+ function a(n, e = "HH:mm") {
6
+ const { from: t, duration: m } = n, r = o(t), i = o(m), c = r + i;
7
+ return d(c, e);
6
8
  }
7
9
  export {
8
- u as default
10
+ a as default
9
11
  };
package/time/index.d.ts CHANGED
@@ -6,4 +6,6 @@ import getEndTimeSpanOfTimePeriod from './getEndTimeSpanOfTimePeriod';
6
6
  import createTimeSpan from './createTimeSpan';
7
7
  import formatTimeSpan from './formatTimeSpan';
8
8
  import getDurationBetweenTimeSpans from './getDurationBetweenTimeSpans';
9
- export { toMinutes, getNextTenthMinute, getTimeSpanParts, getPrevNthMinute, getEndTimeSpanOfTimePeriod, createTimeSpan, formatTimeSpan, getDurationBetweenTimeSpans, };
9
+ import convertSecondsToTimeSpan from './convertSecondsToTimeSpan';
10
+ import convertTimeSpanToSeconds from './convertTimeSpanToSeconds';
11
+ export { toMinutes, getNextTenthMinute, getTimeSpanParts, getPrevNthMinute, getEndTimeSpanOfTimePeriod, createTimeSpan, formatTimeSpan, getDurationBetweenTimeSpans, convertSecondsToTimeSpan, convertTimeSpanToSeconds, };
package/time/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./toMinutes.js"),t=require("./getNextTenthMinute.js"),i=require("./getPrevNthMinute.js"),n=require("./getTimeSpanParts.js"),r=require("./getEndTimeSpanOfTimePeriod.js"),m=require("./createTimeSpan.js"),a=require("./formatTimeSpan.js"),o=require("./getDurationBetweenTimeSpans.js");require("moment");exports.toMinutes=e;exports.getNextTenthMinute=t;exports.getPrevNthMinute=i;exports.getTimeSpanParts=n;exports.getEndTimeSpanOfTimePeriod=r;exports.createTimeSpan=m;exports.formatTimeSpan=a;exports.getDurationBetweenTimeSpans=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./toMinutes.js"),t=require("./getNextTenthMinute.js"),i=require("./getPrevNthMinute.js"),n=require("./getTimeSpanParts.js"),r=require("./getEndTimeSpanOfTimePeriod.js"),o=require("./createTimeSpan.js"),m=require("./formatTimeSpan.js"),a=require("./getDurationBetweenTimeSpans.js"),T=require("./convertSecondsToTimeSpan.js"),c=require("./convertTimeSpanToSeconds.js");require("moment");exports.toMinutes=e;exports.getNextTenthMinute=t;exports.getPrevNthMinute=i;exports.getTimeSpanParts=n;exports.getEndTimeSpanOfTimePeriod=r;exports.createTimeSpan=o;exports.formatTimeSpan=m;exports.getDurationBetweenTimeSpans=a;exports.convertSecondsToTimeSpan=T;exports.convertTimeSpanToSeconds=c;
package/time/index.mjs CHANGED
@@ -1,19 +1,23 @@
1
- import { default as r } from "./toMinutes.mjs";
1
+ import { default as o } from "./toMinutes.mjs";
2
2
  import { default as f } from "./getNextTenthMinute.mjs";
3
- import { default as p } from "./getPrevNthMinute.mjs";
4
- import { default as n } from "./getTimeSpanParts.mjs";
5
- import { default as s } from "./getEndTimeSpanOfTimePeriod.mjs";
3
+ import { default as n } from "./getPrevNthMinute.mjs";
4
+ import { default as s } from "./getTimeSpanParts.mjs";
5
+ import { default as i } from "./getEndTimeSpanOfTimePeriod.mjs";
6
6
  import { default as x } from "./createTimeSpan.mjs";
7
- import { default as T } from "./formatTimeSpan.mjs";
8
- import { default as S } from "./getDurationBetweenTimeSpans.mjs";
7
+ import { default as l } from "./formatTimeSpan.mjs";
8
+ import { default as c } from "./getDurationBetweenTimeSpans.mjs";
9
+ import { default as v } from "./convertSecondsToTimeSpan.mjs";
10
+ import { default as P } from "./convertTimeSpanToSeconds.mjs";
9
11
  import "moment";
10
12
  export {
13
+ v as convertSecondsToTimeSpan,
14
+ P as convertTimeSpanToSeconds,
11
15
  x as createTimeSpan,
12
- T as formatTimeSpan,
13
- S as getDurationBetweenTimeSpans,
14
- s as getEndTimeSpanOfTimePeriod,
16
+ l as formatTimeSpan,
17
+ c as getDurationBetweenTimeSpans,
18
+ i as getEndTimeSpanOfTimePeriod,
15
19
  f as getNextTenthMinute,
16
- p as getPrevNthMinute,
17
- n as getTimeSpanParts,
18
- r as toMinutes
20
+ n as getPrevNthMinute,
21
+ s as getTimeSpanParts,
22
+ o as toMinutes
19
23
  };
@@ -1,3 +0,0 @@
1
- import { Moment } from 'moment';
2
- declare function getMomentFromDateAndTimeString(date: string, time: string): Moment;
3
- export default getMomentFromDateAndTimeString;
@@ -1 +0,0 @@
1
- "use strict";const m=require("moment");function u(t){const[e,r,n]=t.split(":");return m().startOf("day").set({hour:Number(e),minute:Number(r),second:Number(n),millisecond:0})}function i(t,e){const[r,n,o]=t.split("-");return u(e).year(Number(r)).month(Number(n)-1).date(Number(o))}module.exports=i;
@@ -1,17 +0,0 @@
1
- import o from "moment";
2
- function u(t) {
3
- const [e, r, n] = t.split(":");
4
- return o().startOf("day").set({
5
- hour: Number(e),
6
- minute: Number(r),
7
- second: Number(n),
8
- millisecond: 0
9
- });
10
- }
11
- function a(t, e) {
12
- const [r, n, m] = t.split("-");
13
- return u(e).year(Number(r)).month(Number(n) - 1).date(Number(m));
14
- }
15
- export {
16
- a as default
17
- };
@@ -1,2 +0,0 @@
1
- import { Moment } from 'moment';
2
- export default function getNextTenthMinute(momentObject: Moment): number;
@@ -1 +0,0 @@
1
- "use strict";const e=require("moment");function n(t){return Math.ceil((t??e()).minutes()/10)*10}module.exports=n;
@@ -1,7 +0,0 @@
1
- import e from "moment";
2
- function i(t) {
3
- return Math.ceil((t ?? e()).minutes() / 10) * 10;
4
- }
5
- export {
6
- i as default
7
- };