- Notifications
You must be signed in to change notification settings - Fork909
chore: replace date-fns by dayjs#18022
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
e372bf2
00cf1ab
2c987c4
31a3f83
ef40473
be6bbe7
fb90246
b9068a2
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
import dayjs from "dayjs"; | ||
import calendar from "dayjs/plugin/calendar"; | ||
dayjs.extend(calendar); | ||
export const createDisplayDate = ( | ||
date: Date, | ||
base: Date = new Date(), | ||
): string => { | ||
const lastWeek =dayjs(base).subtract(7, "day").toDate(); | ||
if (date >= lastWeek) { | ||
return dayjs(date).calendar(dayjs(base), { | ||
sameDay: "[Today]", | ||
lastDay: "[Yesterday]", | ||
lastWeek: "[last] dddd", | ||
sameElse: "MM/DD/YYYY", | ||
}); | ||
} | ||
return date.toLocaleDateString(); | ||
}; |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.