mirror of
https://github.com/docmost/docmost.git
synced 2026-05-14 12:44:16 +08:00
a689cca7a0
* feat: labels (WIP) * full implementation
16 lines
468 B
TypeScript
16 lines
468 B
TypeScript
import { format, isThisYear, isToday, isYesterday } from "date-fns";
|
|
import i18n from "@/i18n.ts";
|
|
|
|
export function formatLabelListDate(date: Date): string {
|
|
if (isToday(date)) {
|
|
return i18n.t("Today, {{time}}", { time: format(date, "h:mma") });
|
|
}
|
|
if (isYesterday(date)) {
|
|
return i18n.t("Yesterday, {{time}}", { time: format(date, "h:mma") });
|
|
}
|
|
if (isThisYear(date)) {
|
|
return format(date, "MMM dd");
|
|
}
|
|
return format(date, "MMM dd, yyyy");
|
|
}
|