From 1f221f2deb3216acde13a15975425cce993a22b2 Mon Sep 17 00:00:00 2001 From: delangle Date: Fri, 13 May 2022 10:20:14 +0200 Subject: [PATCH] Remove useless date clone in dayjs adapter --- packages/dayjs/src/dayjs-utils.ts | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/dayjs/src/dayjs-utils.ts b/packages/dayjs/src/dayjs-utils.ts index 57788377..3c35508c 100644 --- a/packages/dayjs/src/dayjs-utils.ts +++ b/packages/dayjs/src/dayjs-utils.ts @@ -162,11 +162,11 @@ export default class DayjsUtils implements IUtils { - return date.clone().startOf("day") as TDate; + return date.startOf("day") as TDate; }; public endOfDay = (date: TDate) => { - return date.clone().endOf("day") as TDate; + return date.endOf("day") as TDate; }; public format = (date: Dayjs, formatKey: keyof DateIOFormats) => { @@ -234,7 +234,7 @@ export default class DayjsUtils implements IUtils { - return date.clone().set("minute", count) as TDate; + return date.set("minute", count) as TDate; }; public getSeconds = (date: Dayjs) => { @@ -242,7 +242,7 @@ export default class DayjsUtils implements IUtils { - return date.clone().set("second", count) as TDate; + return date.set("second", count) as TDate; }; public getMonth = (date: Dayjs) => { @@ -282,31 +282,31 @@ export default class DayjsUtils implements IUtils { - return date.clone().startOf("month") as TDate; + return date.startOf("month") as TDate; }; public endOfMonth = (date: Dayjs) => { - return date.clone().endOf("month") as TDate; + return date.endOf("month") as TDate; }; public startOfWeek = (date: Dayjs) => { - return date.clone().startOf("week") as TDate; + return date.startOf("week") as TDate; }; public endOfWeek = (date: Dayjs) => { - return date.clone().endOf("week") as TDate; + return date.endOf("week") as TDate; }; public getNextMonth = (date: Dayjs) => { - return date.clone().add(1, "month") as TDate; + return date.add(1, "month") as TDate; }; public getPreviousMonth = (date: Dayjs) => { - return date.clone().subtract(1, "month") as TDate; + return date.subtract(1, "month") as TDate; }; public getMonthArray = (date: TDate) => { - const firstMonth = date.clone().startOf("year") as TDate; + const firstMonth = date.startOf("year") as TDate; const monthArray = [firstMonth]; while (monthArray.length < 12) { @@ -322,7 +322,7 @@ export default class DayjsUtils implements IUtils { - return date.clone().set("year", year) as TDate; + return date.set("year", year) as TDate; }; public mergeDateAndTime = (date: TDate, time: TDate) => { @@ -345,8 +345,8 @@ export default class DayjsUtils implements IUtils { - const start = this.dayjs(date).clone().startOf("month").startOf("week") as TDate; - const end = this.dayjs(date).clone().endOf("month").endOf("week") as TDate; + const start = this.dayjs(date).startOf("month").startOf("week") as TDate; + const end = this.dayjs(date).endOf("month").endOf("week") as TDate; let count = 0; let current = start; @@ -357,7 +357,7 @@ export default class DayjsUtils implements IUtils implements IUtils