@pittica/google-business-intelligence-helpers 1.9.0 → 1.11.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/README.md +0 -4
- package/dist/index.js +7 -1
- package/dist/naming/date.js +32 -1
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -33,8 +33,11 @@ const {
|
|
|
33
33
|
} = require("./naming/dataset");
|
|
34
34
|
const {
|
|
35
35
|
partsToDate,
|
|
36
|
+
partsToDateUTC,
|
|
36
37
|
stringToDate,
|
|
37
|
-
|
|
38
|
+
stringToDateUTC,
|
|
39
|
+
getNow,
|
|
40
|
+
formatDate
|
|
38
41
|
} = require("./naming/date");
|
|
39
42
|
const {
|
|
40
43
|
isDataCsv
|
|
@@ -66,8 +69,11 @@ exports.getSafeFilenameFromBucket = getSafeFilenameFromBucket;
|
|
|
66
69
|
exports.getTemporaryTableName = getTemporaryTableName;
|
|
67
70
|
exports.getTemporaryTableSuffix = getTemporaryTableSuffix;
|
|
68
71
|
exports.partsToDate = partsToDate;
|
|
72
|
+
exports.partsToDateUTC = partsToDateUTC;
|
|
69
73
|
exports.stringToDate = stringToDate;
|
|
74
|
+
exports.stringToDateUTC = stringToDateUTC;
|
|
70
75
|
exports.getNow = getNow;
|
|
76
|
+
exports.formatDate = formatDate;
|
|
71
77
|
exports.isDataCsv = isDataCsv;
|
|
72
78
|
exports.getFilenameVersion = getFilenameVersion;
|
|
73
79
|
exports.incrementFilenameVersion = incrementFilenameVersion;
|
package/dist/naming/date.js
CHANGED
|
@@ -24,6 +24,14 @@ const {
|
|
|
24
24
|
*/
|
|
25
25
|
exports.partsToDate = parts => new Date(parseInt(parts[1]), parseInt(parts[2]) - 1, parseInt(parts[3]));
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Converts the file name parts to an UTC date object.
|
|
29
|
+
*
|
|
30
|
+
* @param {Array} parts String array from regular expression split representing a date from file name.
|
|
31
|
+
* @returns {Date} The UTC date from the given array.
|
|
32
|
+
*/
|
|
33
|
+
exports.partsToDateUTC = parts => new Date(Date.UTC(parseInt(parts[1]), parseInt(parts[2]) - 1, parseInt(parts[3])));
|
|
34
|
+
|
|
27
35
|
/**
|
|
28
36
|
* Extracts a date from the given date representation.
|
|
29
37
|
*
|
|
@@ -38,10 +46,33 @@ exports.stringToDate = date => {
|
|
|
38
46
|
return null;
|
|
39
47
|
};
|
|
40
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Extracts an UTC date from the given date representation.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} date Date in string format YYYY-MM-DD.
|
|
53
|
+
* @returns {Date} An UTC date from the given date representation.
|
|
54
|
+
*/
|
|
55
|
+
exports.stringToDateUTC = date => {
|
|
56
|
+
const split = date.split(/^(\d{4})\-(\d{2})\-(\d{2})$/gis);
|
|
57
|
+
if (split.length === 5) {
|
|
58
|
+
return this.partsToDateUTC(split);
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
62
|
+
|
|
41
63
|
/**
|
|
42
64
|
* Gets the current date in the given format.
|
|
43
65
|
*
|
|
44
66
|
* @param {string} dateFormat Format string.
|
|
45
67
|
* @returns {string} The current date in the given format.
|
|
46
68
|
*/
|
|
47
|
-
exports.getNow = (dateFormat = "YYYY-MM-DD") =>
|
|
69
|
+
exports.getNow = (dateFormat = "YYYY-MM-DD") => this.formatDate(new Date(), dateFormat);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets the given date in the given format.
|
|
73
|
+
*
|
|
74
|
+
* @param {Date} date Date object.
|
|
75
|
+
* @param {string} dateFormat Format string.
|
|
76
|
+
* @returns {string} The given date in the given format.
|
|
77
|
+
*/
|
|
78
|
+
exports.formatDate = (date, dateFormat = "YYYY-MM-DD") => format(date, dateFormat);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pittica/google-business-intelligence-helpers",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.11.0",
|
|
5
5
|
"description": "Helpers for business intelligence for Google Cloud.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/pittica/google-business-intelligence-helpers#README.md",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@pittica/google-cloud-storage-helpers": "^1.
|
|
30
|
-
"date-and-time": "^
|
|
29
|
+
"@pittica/google-cloud-storage-helpers": "^1.3.1",
|
|
30
|
+
"date-and-time": "^4.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/cli": "^7.
|
|
33
|
+
"@babel/cli": "^7.28.3",
|
|
34
34
|
"mkdirp": "^3.0.1",
|
|
35
|
-
"prettier": "^3.
|
|
35
|
+
"prettier": "^3.6.2",
|
|
36
36
|
"rimraf": "^6.0.1"
|
|
37
37
|
}
|
|
38
38
|
}
|