@pittica/google-business-intelligence-helpers 1.11.0 → 1.12.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.
- package/dist/index.js +3 -1
- package/dist/naming/date.js +18 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37,7 +37,8 @@ const {
|
|
|
37
37
|
stringToDate,
|
|
38
38
|
stringToDateUTC,
|
|
39
39
|
getNow,
|
|
40
|
-
formatDate
|
|
40
|
+
formatDate,
|
|
41
|
+
getDatesUntil
|
|
41
42
|
} = require("./naming/date");
|
|
42
43
|
const {
|
|
43
44
|
isDataCsv
|
|
@@ -74,6 +75,7 @@ exports.stringToDate = stringToDate;
|
|
|
74
75
|
exports.stringToDateUTC = stringToDateUTC;
|
|
75
76
|
exports.getNow = getNow;
|
|
76
77
|
exports.formatDate = formatDate;
|
|
78
|
+
exports.getDatesUntil = getDatesUntil;
|
|
77
79
|
exports.isDataCsv = isDataCsv;
|
|
78
80
|
exports.getFilenameVersion = getFilenameVersion;
|
|
79
81
|
exports.incrementFilenameVersion = incrementFilenameVersion;
|
package/dist/naming/date.js
CHANGED
|
@@ -75,4 +75,21 @@ exports.getNow = (dateFormat = "YYYY-MM-DD") => this.formatDate(new Date(), date
|
|
|
75
75
|
* @param {string} dateFormat Format string.
|
|
76
76
|
* @returns {string} The given date in the given format.
|
|
77
77
|
*/
|
|
78
|
-
exports.formatDate = (date, dateFormat = "YYYY-MM-DD") => format(date, dateFormat);
|
|
78
|
+
exports.formatDate = (date, dateFormat = "YYYY-MM-DD") => format(date, dateFormat);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Gets the dates from the beginning of the year of the given date.
|
|
82
|
+
*
|
|
83
|
+
* @param {Date} until The day at the end of the loop.
|
|
84
|
+
* @returns {Array} The dates from the beginning of the year of the given date.
|
|
85
|
+
*/
|
|
86
|
+
exports.getDatesUntil = (until = new Date()) => {
|
|
87
|
+
const dates = [];
|
|
88
|
+
const year = until.getFullYear();
|
|
89
|
+
let current = new Date(Date.UTC(year, 0, 1));
|
|
90
|
+
while (current <= until && current.getFullYear() === year) {
|
|
91
|
+
dates.push(formatDate(new Date(current)));
|
|
92
|
+
current.setDate(current.getDate() + 1);
|
|
93
|
+
}
|
|
94
|
+
return dates;
|
|
95
|
+
};
|
package/package.json
CHANGED