MCPcopy Create free account
hub / github.com/coder/coder / createDisplayDate

Function createDisplayDate

site/src/components/Timeline/utils.ts:7–25  ·  view source on GitHub ↗
(
	date: Date,
	base: Date = new Date(),
)

Source from the content-addressed store, hash-verified

5dayjs.extend(calendar);
6
7export const createDisplayDate = (
8 date: Date,
9 base: Date = new Date(),
10): string => {
11 const lastWeek = dayjs(base).subtract(7, "day").toDate();
12 if (date >= lastWeek) {
13 return dayjs(date).calendar(dayjs(base), {
14 sameDay: "[Today]",
15 lastDay: "[Yesterday]",
16 lastWeek: "[last] dddd",
17 sameElse: "MM/DD/YYYY",
18 });
19 }
20 return formatDate(date, {
21 hour: undefined,
22 minute: undefined,
23 second: undefined,
24 });
25};

Callers 2

utils.test.tsFile · 0.90
TimelineDateRowFunction · 0.90

Calls 1

formatDateFunction · 0.90

Tested by

no test coverage detected