Skip to content

Commit

Permalink
fix: fixed the timezone issue in unit test #2623
Browse files Browse the repository at this point in the history
  • Loading branch information
chandrashekhara.n authored and chejimmy committed Mar 21, 2024
1 parent 84a51f5 commit a8200dc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/dashboard/src/components/util/dateTimeUtil.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import {
} from './dateTimeUtil';

it('should format the Date to full Date and Time value', () => {
const rawDate = new Date(
1665583620000 + new Date().getTimezoneOffset() * 60000
);
expect(getFormattedDateTime(rawDate)).toEqual(`10/12/22 14:07:00`);
const rawDate = new Date(1665583620000);

// Adjust for daylight saving time
const timezoneOffset = rawDate.getTimezoneOffset();
const adjustedDate = new Date(rawDate.getTime() + timezoneOffset * 60000);

expect(getFormattedDateTime(adjustedDate)).toEqual('10/12/22 14:07:00');
});

it('should format the epoch seconds to Date and Time value', () => {
Expand Down

0 comments on commit a8200dc

Please sign in to comment.