Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update DateFormatter.ts (#2159)
Leendert de Borstff11e799f4df
diff --git a/apps/browser-extension/src/utils/DateFormatter.ts b/apps/browser-extension/src/utils/DateFormatter.tsindex 36ed8800b..462e69842 100644--- a/apps/browser-extension/src/utils/DateFormatter.ts+++ b/apps/browser-extension/src/utils/DateFormatter.ts@@ -40,3 +40,14 @@ export function toBirthDateFormat(date: Date): string {const datePart = isoString.substring(0, 10); // yyyy-MM-ddreturn `${datePart} 00:00:00`;}++/**+ * Formats a date-time returned by the API (UTC by default) for display in the user's own locale and timezone.+ * @param value - The date-time string as returned by the API+ * @returns The date-time formatted for the current locale, or the raw value when it cannot be parsed+ */+export function toLocalDisplayFormat(value: string): string {+ const normalized = /^\d{4}-\d{2}-\d{2}[T ][\d:.]+$/.test(value) ? `${value.replace(' ', 'T')}Z` : value;+ const date = new Date(normalized);+ return isNaN(date.getTime()) ? value : date.toLocaleString();+}