* util

* fix page position collation

* support fixed toolbar in templates editor

* date localization

* fix clipped emoji in templates editor

* fix page updated time object

* fix flickers

* fix: remove redundant breadcrumb from destination modal
This commit is contained in:
Philip Okugbe
2026-05-28 16:20:37 +01:00
committed by GitHub
parent 830b5b4d45
commit 33895b0607
38 changed files with 360 additions and 151 deletions
+14 -6
View File
@@ -1,17 +1,25 @@
import { formatDistanceStrict } from "date-fns";
import { format, isToday, isYesterday } from "date-fns";
import { formatDistanceStrict, isToday, isYesterday } from "date-fns";
import i18n from "@/i18n.ts";
import { formatLocalized, getDateFnsLocale } from "@/lib/date-locale.ts";
export function timeAgo(date: Date) {
return formatDistanceStrict(new Date(date), new Date(), { addSuffix: true });
return formatDistanceStrict(new Date(date), new Date(), {
addSuffix: true,
locale: getDateFnsLocale(),
});
}
export function formattedDate(date: Date) {
const locale = getDateFnsLocale();
if (isToday(date)) {
return i18n.t("Today, {{time}}", { time: format(date, "h:mma") });
return i18n.t("Today, {{time}}", {
time: formatLocalized(date, "h:mma", "p", locale),
});
} else if (isYesterday(date)) {
return i18n.t("Yesterday, {{time}}", { time: format(date, "h:mma") });
return i18n.t("Yesterday, {{time}}", {
time: formatLocalized(date, "h:mma", "p", locale),
});
} else {
return format(date, "MMM dd, yyyy, h:mma");
return formatLocalized(date, "MMM dd, yyyy, h:mma", "PPp", locale);
}
}