diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index eb64906121cc..c2642d1f0358 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -159,6 +159,18 @@ function isToday8(date: Date, timeZone: SelectedTimezone): boolean { return isSameDay(date, currentDateInTimeZone); } +function isToday9(date: Date, timeZone: SelectedTimezone): boolean { + const currentDate = new Date(); + const currentDateInTimeZone = toZonedTime(currentDate, timeZone); + return isSameDay(date, currentDateInTimeZone); +} + +function isToday10(date: Date, timeZone: SelectedTimezone): boolean { + const currentDate = new Date(); + const currentDateInTimeZone = toZonedTime(currentDate, timeZone); + return isSameDay(date, currentDateInTimeZone); +} + /** * Checks if a given date is tomorrow in the specified time zone. * @@ -983,6 +995,8 @@ const DateUtils = { isToday6, isToday7, isToday8, + isToday9, + isToday10, isTomorrow, isYesterday, getMonthNames, diff --git a/tests/unit/DateUtilsTest.ts b/tests/unit/DateUtilsTest.ts index 7c3d135c74fb..2fd21fffaa16 100644 --- a/tests/unit/DateUtilsTest.ts +++ b/tests/unit/DateUtilsTest.ts @@ -179,6 +179,46 @@ describe('DateUtils', () => { expect(DateUtils.isToday(tomorrowInTimezone, timezone)).toBe(false); expect(DateUtils.isToday(yesterdayInTimezone, timezone)).toBe(false); }); + it('isToday1 should correctly identify today', () => { + expect(DateUtils.isToday1(todayInTimezone, timezone)).toBe(true); + expect(DateUtils.isToday1(tomorrowInTimezone, timezone)).toBe(false); + expect(DateUtils.isToday1(yesterdayInTimezone, timezone)).toBe(false); + }); + it('isToday2 should correctly identify today', () => { + expect(DateUtils.isToday2(todayInTimezone, timezone)).toBe(true); + expect(DateUtils.isToday2(tomorrowInTimezone, timezone)).toBe(false); + expect(DateUtils.isToday2(yesterdayInTimezone, timezone)).toBe(false); + }); + it('isToday3 should correctly identify today', () => { + expect(DateUtils.isToday3(todayInTimezone, timezone)).toBe(true); + expect(DateUtils.isToday3(tomorrowInTimezone, timezone)).toBe(false); + expect(DateUtils.isToday3(yesterdayInTimezone, timezone)).toBe(false); + }); + it('isToday4 should correctly identify today', () => { + expect(DateUtils.isToday4(todayInTimezone, timezone)).toBe(true); + expect(DateUtils.isToday4(tomorrowInTimezone, timezone)).toBe(false); + expect(DateUtils.isToday4(yesterdayInTimezone, timezone)).toBe(false); + }); + it('isToday5 should correctly identify today', () => { + expect(DateUtils.isToday5(todayInTimezone, timezone)).toBe(true); + expect(DateUtils.isToday5(tomorrowInTimezone, timezone)).toBe(false); + expect(DateUtils.isToday5(yesterdayInTimezone, timezone)).toBe(false); + }); + it('isToday6 should correctly identify today', () => { + expect(DateUtils.isToday6(todayInTimezone, timezone)).toBe(true); + expect(DateUtils.isToday6(tomorrowInTimezone, timezone)).toBe(false); + expect(DateUtils.isToday6(yesterdayInTimezone, timezone)).toBe(false); + }); + it('isToday7 should correctly identify today', () => { + expect(DateUtils.isToday7(todayInTimezone, timezone)).toBe(true); + expect(DateUtils.isToday7(tomorrowInTimezone, timezone)).toBe(false); + expect(DateUtils.isToday7(yesterdayInTimezone, timezone)).toBe(false); + }); + it('isToday8 should correctly identify today', () => { + expect(DateUtils.isToday8(todayInTimezone, timezone)).toBe(true); + expect(DateUtils.isToday8(tomorrowInTimezone, timezone)).toBe(false); + expect(DateUtils.isToday8(yesterdayInTimezone, timezone)).toBe(false); + }); it('isTomorrow should correctly identify tomorrow', () => { expect(DateUtils.isTomorrow(tomorrowInTimezone, timezone)).toBe(true);