Skip to content

Fix: Timeline Date Bug #5329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2022
Merged
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
8 changes: 8 additions & 0 deletions site/src/components/Timeline/Timeline.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createDisplayDate } from "./TimelineDateRow"

describe("createDisplayDate", () => {
it("returns correctly for Saturdays", () => {
const date = new Date("Sat Dec 03 2022 00:00:00 GMT-0500")
expect(createDisplayDate(date)).toEqual("last Saturday")
})
})
10 changes: 6 additions & 4 deletions site/src/components/Timeline/TimelineDateRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ export interface TimelineDateRow {
date: Date
}

// We only want the message related to the date since the time is displayed
// inside of the build row
export const createDisplayDate = (date: Date): string =>
formatRelative(date, new Date()).split(" at ")[0]

export const TimelineDateRow: FC<TimelineDateRow> = ({ date }) => {
const styles = useStyles()
// We only want the message related to the date since the time is displayed
// inside of the build row
const displayDate = formatRelative(date, new Date()).split("at")[0]

return (
<TableRow className={styles.dateRow}>
<TableCell className={styles.dateCell} title={date.toLocaleDateString()}>
{displayDate}
{createDisplayDate(date)}
</TableCell>
</TableRow>
)
Expand Down