@8ms/helpers 1.1.21 → 1.1.24
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/dist/date/getDate.js
CHANGED
|
@@ -23,9 +23,9 @@ var getDate = function (_a) {
|
|
|
23
23
|
var day = Number(dateString.substring(6, 8));
|
|
24
24
|
if (year > 999 && month < 13 && day < 32) {
|
|
25
25
|
date = new Date();
|
|
26
|
-
date.
|
|
27
|
-
date.
|
|
28
|
-
date.
|
|
26
|
+
date.setFullYear(year);
|
|
27
|
+
date.setMonth(month - 1);
|
|
28
|
+
date.setDate(day);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
// 2022-04-12
|
|
@@ -18,20 +18,20 @@ var getFinancialYear = function (_a) {
|
|
|
18
18
|
if (undefined === year) {
|
|
19
19
|
var today = (0, getToday_1.default)();
|
|
20
20
|
// If today is before 1st of April, then use last year
|
|
21
|
-
if (today < new Date(today.
|
|
22
|
-
financialYear = today.
|
|
21
|
+
if (today < new Date(today.getFullYear(), 3, 1)) {
|
|
22
|
+
financialYear = today.getFullYear() - 1;
|
|
23
23
|
}
|
|
24
24
|
// On or after 1st of April, use this year
|
|
25
25
|
else {
|
|
26
|
-
financialYear = today.
|
|
26
|
+
financialYear = today.getFullYear();
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
// The year-end needs to be 31st March next year
|
|
30
30
|
var yearEnd = new Date("".concat(financialYear + 1, "-03-31"));
|
|
31
|
-
yearEnd.
|
|
31
|
+
yearEnd.setHours(0, 0, 0, 0);
|
|
32
32
|
// The year start needs to be 1st April this year
|
|
33
33
|
var yearStart = new Date("".concat(financialYear, "-04-01"));
|
|
34
|
-
yearStart.
|
|
34
|
+
yearStart.setHours(0, 0, 0, 0);
|
|
35
35
|
// Get the previous Monday if the 1st of April isn't a Monday
|
|
36
36
|
if (!(0, isMonday_1.default)(yearStart)) {
|
|
37
37
|
yearStart = (0, previousMonday_1.default)(yearStart);
|
package/dist/date/getToday.d.ts
CHANGED
package/dist/date/getToday.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
4
|
* Shortcut to get today's date.
|
|
5
|
-
* Set to 1am to prevent daylight savings causing issues
|
|
6
5
|
*/
|
|
7
6
|
var getToday = function () {
|
|
8
7
|
var today = new Date();
|
|
9
|
-
today.
|
|
8
|
+
today.setHours(0, 0, 0, 0);
|
|
10
9
|
return today;
|
|
11
10
|
};
|
|
12
11
|
exports.default = getToday;
|