@8ms/helpers 2.0.15 → 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,6 +11,13 @@ 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
  *
@@ -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.differenceInMinutes = 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,7 +106,7 @@ 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;
77
112
  /**
@@ -80,7 +115,7 @@ exports.isWeekend = isWeekend;
80
115
  const differenceInMinutes = (start, end) => {
81
116
  const startDate = (0, exports.getDate)(start);
82
117
  const endDate = (0, exports.getDate)(end);
83
- return endDate.diff(startDate, 'minutes').minutes;
118
+ return endDate.diff(startDate, "minutes").minutes;
84
119
  };
85
120
  exports.differenceInMinutes = differenceInMinutes;
86
121
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.0.15",
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"