@8ms/helpers 2.0.14 → 2.0.16

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.
Binary file
@@ -11,13 +11,24 @@ export declare const getUnix: (input?: InputDate) => number;
11
11
  * If it's not UTC, it needs to be converted to UTC before being used.
12
12
  */
13
13
  export declare const getDate: (input?: InputDate, setMidnight?: boolean) => DateTime<boolean>;
14
+ export declare const isMonday: (input?: InputDate) => boolean;
15
+ export declare const isTuesday: (input?: InputDate) => boolean;
16
+ export declare const isWednesday: (input?: InputDate) => boolean;
17
+ export declare const isThursday: (input?: InputDate) => boolean;
18
+ export declare const isFriday: (input?: InputDate) => boolean;
19
+ export declare const isSaturday: (input?: InputDate) => boolean;
20
+ export declare const isSunday: (input?: InputDate) => boolean;
14
21
  /**
15
22
  * Determines if a given date falls on a weekend.
16
23
  *
17
24
  * This function checks whether the day of the week for the provided input corresponds
18
25
  * to Saturday or Sunday, where weekday values of 6 and 7 represent Saturday and Sunday, respectively.
19
26
  */
20
- export declare const isWeekend: (input: InputDate) => boolean;
27
+ export declare const isWeekend: (input?: InputDate) => boolean;
28
+ /**
29
+ * Calculates the difference in minutes between two provided dates.
30
+ */
31
+ export declare const differenceInMinutes: (start: InputDate, end: InputDate) => number;
21
32
  /**
22
33
  * Calculates the difference in business days between two dates.
23
34
  * Business days are considered as weekdays (Monday to Friday).
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLastWeek = exports.isThisWeek = exports.getYesterday = exports.getWeeksAgo = exports.getToday = exports.getTwoWeeksAgo = exports.getThisWeek = exports.getLastWeek = exports.getSunday = exports.getMonday = exports.getMin = exports.getMax = exports.getDatesBetween = exports.differenceInBusinessDays = exports.isWeekend = exports.getDate = exports.getUnix = exports.getUtcDate = void 0;
3
+ exports.isLastWeek = exports.isThisWeek = exports.getYesterday = exports.getWeeksAgo = exports.getToday = exports.getTwoWeeksAgo = exports.getThisWeek = exports.getLastWeek = exports.getSunday = exports.getMonday = exports.getMin = exports.getMax = exports.getDatesBetween = exports.differenceInBusinessDays = exports.differenceInMinutes = exports.isWeekend = exports.isSunday = exports.isSaturday = exports.isFriday = exports.isThursday = exports.isWednesday = exports.isTuesday = exports.isMonday = exports.getDate = exports.getUnix = exports.getUtcDate = void 0;
4
4
  const luxon_1 = require("luxon");
5
5
  /**
6
6
  * Convert an client's input (any time-zone) ready to be used by the server (UTC).
@@ -63,6 +63,41 @@ const getDate = (input, setMidnight) => {
63
63
  return instance;
64
64
  };
65
65
  exports.getDate = getDate;
66
+ const isMonday = (input) => {
67
+ const date = (0, exports.getDate)(input);
68
+ return date.weekday === 1;
69
+ };
70
+ exports.isMonday = isMonday;
71
+ const isTuesday = (input) => {
72
+ const date = (0, exports.getDate)(input);
73
+ return date.weekday === 2;
74
+ };
75
+ exports.isTuesday = isTuesday;
76
+ const isWednesday = (input) => {
77
+ const date = (0, exports.getDate)(input);
78
+ return date.weekday === 3;
79
+ };
80
+ exports.isWednesday = isWednesday;
81
+ const isThursday = (input) => {
82
+ const date = (0, exports.getDate)(input);
83
+ return date.weekday === 4;
84
+ };
85
+ exports.isThursday = isThursday;
86
+ const isFriday = (input) => {
87
+ const date = (0, exports.getDate)(input);
88
+ return date.weekday === 6;
89
+ };
90
+ exports.isFriday = isFriday;
91
+ const isSaturday = (input) => {
92
+ const date = (0, exports.getDate)(input);
93
+ return date.weekday === 6;
94
+ };
95
+ exports.isSaturday = isSaturday;
96
+ const isSunday = (input) => {
97
+ const date = (0, exports.getDate)(input);
98
+ return date.weekday === 7;
99
+ };
100
+ exports.isSunday = isSunday;
66
101
  /**
67
102
  * Determines if a given date falls on a weekend.
68
103
  *
@@ -71,9 +106,18 @@ exports.getDate = getDate;
71
106
  */
72
107
  const isWeekend = (input) => {
73
108
  const date = (0, exports.getDate)(input);
74
- return date.weekday >= 6;
109
+ return 6 === date.weekday || 7 === date.weekday;
75
110
  };
76
111
  exports.isWeekend = isWeekend;
112
+ /**
113
+ * Calculates the difference in minutes between two provided dates.
114
+ */
115
+ const differenceInMinutes = (start, end) => {
116
+ const startDate = (0, exports.getDate)(start);
117
+ const endDate = (0, exports.getDate)(end);
118
+ return endDate.diff(startDate, "minutes").minutes;
119
+ };
120
+ exports.differenceInMinutes = differenceInMinutes;
77
121
  /**
78
122
  * Calculates the difference in business days between two dates.
79
123
  * Business days are considered as weekdays (Monday to Friday).
package/date/index.d.ts CHANGED
@@ -30,6 +30,6 @@ export declare enum Month {
30
30
  NOVEMBER = "NOVEMBER",
31
31
  DECEMBER = "DECEMBER"
32
32
  }
33
- export { getUtcDate, getDate, getDatesBetween, getMax, getMin, getMonday, getSunday, getThisWeek, getLastWeek, getTwoWeeksAgo, getToday, getWeeksAgo, getYesterday, isThisWeek, isLastWeek, isWeekend, differenceInBusinessDays, } from "./calculation";
34
- export { getFinancialYear, getFinancialYearToDate, getFinancialYearToYesterday, getFinancialYearWeeks, } from "./financialYear";
35
- export { format, getDayNumber, getFullDate, getFullDateTime, getDurationHours, getDurationMinutes, getMonthYearString, getTodayYmdString, getYearNumber, getYmdHisNumber, getYmdHisString, getYmdNumber, getYmdString, parseExcelDate } from "./format";
33
+ export * from "./calculation";
34
+ export * from "./financialYear";
35
+ export * from "./format";
package/date/index.js CHANGED
@@ -1,6 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseExcelDate = exports.getYmdString = exports.getYmdNumber = exports.getYmdHisString = exports.getYmdHisNumber = exports.getYearNumber = exports.getTodayYmdString = exports.getMonthYearString = exports.getDurationMinutes = exports.getDurationHours = exports.getFullDateTime = exports.getFullDate = exports.getDayNumber = exports.format = exports.getFinancialYearWeeks = exports.getFinancialYearToYesterday = exports.getFinancialYearToDate = exports.getFinancialYear = exports.differenceInBusinessDays = exports.isWeekend = exports.isLastWeek = exports.isThisWeek = exports.getYesterday = exports.getWeeksAgo = exports.getToday = exports.getTwoWeeksAgo = exports.getLastWeek = exports.getThisWeek = exports.getSunday = exports.getMonday = exports.getMin = exports.getMax = exports.getDatesBetween = exports.getDate = exports.getUtcDate = exports.Month = void 0;
17
+ exports.Month = void 0;
4
18
  /**
5
19
  * Used by Google Ads API.
6
20
  */
@@ -19,41 +33,6 @@ var Month;
19
33
  Month["NOVEMBER"] = "NOVEMBER";
20
34
  Month["DECEMBER"] = "DECEMBER";
21
35
  })(Month || (exports.Month = Month = {}));
22
- var calculation_1 = require("./calculation");
23
- Object.defineProperty(exports, "getUtcDate", { enumerable: true, get: function () { return calculation_1.getUtcDate; } });
24
- Object.defineProperty(exports, "getDate", { enumerable: true, get: function () { return calculation_1.getDate; } });
25
- Object.defineProperty(exports, "getDatesBetween", { enumerable: true, get: function () { return calculation_1.getDatesBetween; } });
26
- Object.defineProperty(exports, "getMax", { enumerable: true, get: function () { return calculation_1.getMax; } });
27
- Object.defineProperty(exports, "getMin", { enumerable: true, get: function () { return calculation_1.getMin; } });
28
- Object.defineProperty(exports, "getMonday", { enumerable: true, get: function () { return calculation_1.getMonday; } });
29
- Object.defineProperty(exports, "getSunday", { enumerable: true, get: function () { return calculation_1.getSunday; } });
30
- Object.defineProperty(exports, "getThisWeek", { enumerable: true, get: function () { return calculation_1.getThisWeek; } });
31
- Object.defineProperty(exports, "getLastWeek", { enumerable: true, get: function () { return calculation_1.getLastWeek; } });
32
- Object.defineProperty(exports, "getTwoWeeksAgo", { enumerable: true, get: function () { return calculation_1.getTwoWeeksAgo; } });
33
- Object.defineProperty(exports, "getToday", { enumerable: true, get: function () { return calculation_1.getToday; } });
34
- Object.defineProperty(exports, "getWeeksAgo", { enumerable: true, get: function () { return calculation_1.getWeeksAgo; } });
35
- Object.defineProperty(exports, "getYesterday", { enumerable: true, get: function () { return calculation_1.getYesterday; } });
36
- Object.defineProperty(exports, "isThisWeek", { enumerable: true, get: function () { return calculation_1.isThisWeek; } });
37
- Object.defineProperty(exports, "isLastWeek", { enumerable: true, get: function () { return calculation_1.isLastWeek; } });
38
- Object.defineProperty(exports, "isWeekend", { enumerable: true, get: function () { return calculation_1.isWeekend; } });
39
- Object.defineProperty(exports, "differenceInBusinessDays", { enumerable: true, get: function () { return calculation_1.differenceInBusinessDays; } });
40
- var financialYear_1 = require("./financialYear");
41
- Object.defineProperty(exports, "getFinancialYear", { enumerable: true, get: function () { return financialYear_1.getFinancialYear; } });
42
- Object.defineProperty(exports, "getFinancialYearToDate", { enumerable: true, get: function () { return financialYear_1.getFinancialYearToDate; } });
43
- Object.defineProperty(exports, "getFinancialYearToYesterday", { enumerable: true, get: function () { return financialYear_1.getFinancialYearToYesterday; } });
44
- Object.defineProperty(exports, "getFinancialYearWeeks", { enumerable: true, get: function () { return financialYear_1.getFinancialYearWeeks; } });
45
- var format_1 = require("./format");
46
- Object.defineProperty(exports, "format", { enumerable: true, get: function () { return format_1.format; } });
47
- Object.defineProperty(exports, "getDayNumber", { enumerable: true, get: function () { return format_1.getDayNumber; } });
48
- Object.defineProperty(exports, "getFullDate", { enumerable: true, get: function () { return format_1.getFullDate; } });
49
- Object.defineProperty(exports, "getFullDateTime", { enumerable: true, get: function () { return format_1.getFullDateTime; } });
50
- Object.defineProperty(exports, "getDurationHours", { enumerable: true, get: function () { return format_1.getDurationHours; } });
51
- Object.defineProperty(exports, "getDurationMinutes", { enumerable: true, get: function () { return format_1.getDurationMinutes; } });
52
- Object.defineProperty(exports, "getMonthYearString", { enumerable: true, get: function () { return format_1.getMonthYearString; } });
53
- Object.defineProperty(exports, "getTodayYmdString", { enumerable: true, get: function () { return format_1.getTodayYmdString; } });
54
- Object.defineProperty(exports, "getYearNumber", { enumerable: true, get: function () { return format_1.getYearNumber; } });
55
- Object.defineProperty(exports, "getYmdHisNumber", { enumerable: true, get: function () { return format_1.getYmdHisNumber; } });
56
- Object.defineProperty(exports, "getYmdHisString", { enumerable: true, get: function () { return format_1.getYmdHisString; } });
57
- Object.defineProperty(exports, "getYmdNumber", { enumerable: true, get: function () { return format_1.getYmdNumber; } });
58
- Object.defineProperty(exports, "getYmdString", { enumerable: true, get: function () { return format_1.getYmdString; } });
59
- Object.defineProperty(exports, "parseExcelDate", { enumerable: true, get: function () { return format_1.parseExcelDate; } });
36
+ __exportStar(require("./calculation"), exports);
37
+ __exportStar(require("./financialYear"), exports);
38
+ __exportStar(require("./format"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.0.14",
4
+ "version": "2.0.16",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"