Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libs/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -983,6 +995,8 @@ const DateUtils = {
isToday6,
isToday7,
isToday8,
isToday9,
isToday10,
isTomorrow,
isYesterday,
getMonthNames,
Expand Down
40 changes: 40 additions & 0 deletions tests/unit/DateUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading