From 109c10ff74eafe5430f05ddaedab0d8dbe260bb7 Mon Sep 17 00:00:00 2001 From: Hero Date: Mon, 10 Jul 2023 17:58:06 +0200 Subject: [PATCH] The addDaysToDate function should not modify the original date. (#96) * addDaysToDate * removed the commented code * removed date format and return null when new date is not a function * Code improvements --------- Co-authored-by: Hero Co-authored-by: Samuel Male --- src/utils/common-expression-helpers.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/common-expression-helpers.ts b/src/utils/common-expression-helpers.ts index 1eca0842..78169f0b 100644 --- a/src/utils/common-expression-helpers.ts +++ b/src/utils/common-expression-helpers.ts @@ -78,10 +78,10 @@ export class CommonExpressionHelpers { return date; }; - addDaysToDate = (date, days) => { - date.setDate(date.getDate() + days); - - return date; + addDaysToDate = (date: Date, days: number): Date => { + return dayjs(date) + .add(days, 'day') + .toDate(); }; useFieldValue = (questionId: string) => {