From 598d4c288445b1c2f1684ad05a8d9aa1fc1e44c9 Mon Sep 17 00:00:00 2001 From: Mohamed Boushab Date: Tue, 30 Nov 2021 13:10:55 +0100 Subject: [PATCH 1/2] Fix number of days of the selected month by adding an optional function --- src/cron-gen.component.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cron-gen.component.js b/src/cron-gen.component.js index 65a7fdfa..c0589f27 100644 --- a/src/cron-gen.component.js +++ b/src/cron-gen.component.js @@ -190,6 +190,10 @@ export class CronGenComponent { return MONTH_LOOKUPS[monthNumber]; } + getMonthDaysWithLasts(yearly, month){ + return ['1W', ...[...new Array(new Date(yearly, month, 0).getDate())].map((val, idx) => `${idx + 1}`), 'LW', 'L'] + } + monthDayDisplay(monthDay) { if (monthDay === 'L') { return 'Last Day'; From 3090221c0a4b4be09e7cd5b3e93bce2326916eb2 Mon Sep 17 00:00:00 2001 From: Mohamed Boushab Date: Tue, 30 Nov 2021 13:31:39 +0100 Subject: [PATCH 2/2] add default value --- src/cron-gen.component.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cron-gen.component.js b/src/cron-gen.component.js index c0589f27..bcab28e4 100644 --- a/src/cron-gen.component.js +++ b/src/cron-gen.component.js @@ -190,7 +190,7 @@ export class CronGenComponent { return MONTH_LOOKUPS[monthNumber]; } - getMonthDaysWithLasts(yearly, month){ + getMonthDaysWithLasts(month, yearly=new Date().getFullYear()){ return ['1W', ...[...new Array(new Date(yearly, month, 0).getDate())].map((val, idx) => `${idx + 1}`), 'LW', 'L'] }