From 29fdee2df0f30a62988ed7f6adfad904aff18502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szab=C3=B3=20Csaba?= Date: Tue, 29 Oct 2024 11:16:18 +0100 Subject: [PATCH 1/3] fix_dateformat --- commit.js | 2 +- date.js | 10 +++++++++- index.js | 0 package-lock.json | 25 ++++++++++++++++++------- package.json | 3 ++- 5 files changed, 30 insertions(+), 10 deletions(-) mode change 100644 => 100755 index.js diff --git a/commit.js b/commit.js index d1f7a44..67a2a42 100644 --- a/commit.js +++ b/commit.js @@ -1,6 +1,6 @@ module.exports = class Commit { constructor({ date, name, message }) { - + this.date = date; this.name = name; this.message = message; diff --git a/date.js b/date.js index 970dcb6..72471db 100644 --- a/date.js +++ b/date.js @@ -17,7 +17,15 @@ const date = (input) => { return moment().subtract(amount, matches[2]); } + // Validate input date format + if (!moment(input, moment.ISO_8601, true).isValid() && !moment(input, 'ddd, DD MMM YYYY HH:mm:ss ZZ', true).isValid()) { + throw new Error('Invalid date format. Please use a valid RFC2822 or ISO format.'); + } + console.log('DATE', moment(input)); + return moment(input); }; -module.exports = date; + + +module.exports = date; \ No newline at end of file diff --git a/index.js b/index.js old mode 100644 new mode 100755 diff --git a/package-lock.json b/package-lock.json index 8bfbdca..9cdf016 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,10 @@ "version": "1.3.0", "license": "ISC", "dependencies": { + "-": "^0.0.1", "colors": "^1.4.0", "commander": "^9.4.1", - "moment": "^2.29.0" + "moment": "^2.29.4" }, "bin": { "git-scrum": "index.js" @@ -22,6 +23,11 @@ "jest": "^26.4.2" } }, + "node_modules/-": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/-/-/--0.0.1.tgz", + "integrity": "sha512-3HfneK3DGAm05fpyj20sT3apkNcvPpCuccOThOPdzz8sY7GgQGe0l93XH9bt+YzibcTIgUAIMoyVJI740RtgyQ==" + }, "node_modules/@babel/code-frame": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", @@ -4830,9 +4836,9 @@ } }, "node_modules/moment": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.0.tgz", - "integrity": "sha512-z6IJ5HXYiuxvFTI6eiQ9dm77uE0gyy1yXNApVHqTcnIKfY9tIwEjlzsZ6u1LQXvVgKeTnv9Xm7NDvJ7lso3MtA==", + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", "engines": { "node": "*" } @@ -7006,6 +7012,11 @@ } }, "dependencies": { + "-": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/-/-/--0.0.1.tgz", + "integrity": "sha512-3HfneK3DGAm05fpyj20sT3apkNcvPpCuccOThOPdzz8sY7GgQGe0l93XH9bt+YzibcTIgUAIMoyVJI740RtgyQ==" + }, "@babel/code-frame": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", @@ -10783,9 +10794,9 @@ } }, "moment": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.0.tgz", - "integrity": "sha512-z6IJ5HXYiuxvFTI6eiQ9dm77uE0gyy1yXNApVHqTcnIKfY9tIwEjlzsZ6u1LQXvVgKeTnv9Xm7NDvJ7lso3MtA==" + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==" }, "ms": { "version": "2.1.2", diff --git a/package.json b/package.json index ac3d91b..27b4295 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,10 @@ "jest": "^26.4.2" }, "dependencies": { + "-": "^0.0.1", "colors": "^1.4.0", "commander": "^9.4.1", - "moment": "^2.29.0" + "moment": "^2.29.4" }, "bin": { "git-scrum": "./index.js" From e436389b168816efed0b9cec93981e07e2c6491a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szab=C3=B3=20Csaba?= Date: Tue, 29 Oct 2024 11:18:43 +0100 Subject: [PATCH 2/3] clean --- commit.js | 1 - date.js | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/commit.js b/commit.js index 67a2a42..e38d42f 100644 --- a/commit.js +++ b/commit.js @@ -1,6 +1,5 @@ module.exports = class Commit { constructor({ date, name, message }) { - this.date = date; this.name = name; this.message = message; diff --git a/date.js b/date.js index 72471db..0acf3d0 100644 --- a/date.js +++ b/date.js @@ -21,8 +21,7 @@ const date = (input) => { if (!moment(input, moment.ISO_8601, true).isValid() && !moment(input, 'ddd, DD MMM YYYY HH:mm:ss ZZ', true).isValid()) { throw new Error('Invalid date format. Please use a valid RFC2822 or ISO format.'); } - console.log('DATE', moment(input)); - + return moment(input); }; From 280b3d2ed83a716557ee6710831cb8ee8839a364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szab=C3=B3=20Csaba?= Date: Tue, 29 Oct 2024 12:18:59 +0100 Subject: [PATCH 3/3] enable YYYY.MM.DD format --- date.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/date.js b/date.js index 0acf3d0..b8a0bb1 100644 --- a/date.js +++ b/date.js @@ -17,14 +17,17 @@ const date = (input) => { return moment().subtract(amount, matches[2]); } - // Validate input date format - if (!moment(input, moment.ISO_8601, true).isValid() && !moment(input, 'ddd, DD MMM YYYY HH:mm:ss ZZ', true).isValid()) { - throw new Error('Invalid date format. Please use a valid RFC2822 or ISO format.'); + if (!moment(input, moment.ISO_8601, true).isValid() && + !moment(input, 'ddd, DD MMM YYYY HH:mm:ss ZZ', true).isValid() && + !moment(input, 'YYYY.MM.DD', true).isValid()) { + throw new Error('Invalid date format. Please use a valid RFC2822, ISO, or YYYY.MM.DD format.'); } - - return moment(input); -}; + if (moment(input, 'YYYY.MM.DD', true).isValid()) { + return moment(input, 'YYYY.MM.DD', true); + } + return moment(input); +}; module.exports = date; \ No newline at end of file