File tree 2 files changed +14
-4
lines changed
site/src/components/Timeline
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { createDisplayDate } from "./TimelineDateRow"
2
+
3
+ describe ( "createDisplayDate" , ( ) => {
4
+ it ( "returns correctly for Saturdays" , ( ) => {
5
+ const date = new Date ( "Sat Dec 03 2022 00:00:00 GMT-0500" )
6
+ expect ( createDisplayDate ( date ) ) . toEqual ( "last Saturday" )
7
+ } )
8
+ } )
Original file line number Diff line number Diff line change @@ -8,16 +8,18 @@ export interface TimelineDateRow {
8
8
date : Date
9
9
}
10
10
11
+ // We only want the message related to the date since the time is displayed
12
+ // inside of the build row
13
+ export const createDisplayDate = ( date : Date ) : string =>
14
+ formatRelative ( date , new Date ( ) ) . split ( " at " ) [ 0 ]
15
+
11
16
export const TimelineDateRow : FC < TimelineDateRow > = ( { date } ) => {
12
17
const styles = useStyles ( )
13
- // We only want the message related to the date since the time is displayed
14
- // inside of the build row
15
- const displayDate = formatRelative ( date , new Date ( ) ) . split ( "at" ) [ 0 ]
16
18
17
19
return (
18
20
< TableRow className = { styles . dateRow } >
19
21
< TableCell className = { styles . dateCell } title = { date . toLocaleDateString ( ) } >
20
- { displayDate }
22
+ { createDisplayDate ( date ) }
21
23
</ TableCell >
22
24
</ TableRow >
23
25
)
You can’t perform that action at this time.
0 commit comments