-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added date time formatter in resource explorer table #2140
- Loading branch information
1 parent
cea7c30
commit 10137b7
Showing
3 changed files
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { getFormattedDateTime } 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`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Format Date object to get date and time to display MM/DD/YY HH:MM:SS format | ||
export const getFormattedDateTime = (rawDate: Date) => { | ||
const date = rawDate.getMonth() + 1 + '/' + rawDate.getDate() + '/' + rawDate.getFullYear().toString().slice(-2); | ||
const time = rawDate.toTimeString().split(' ')[0]; | ||
const dateTime = date + ' ' + time; | ||
return dateTime; | ||
}; |