Add basic date & time formatters using navigator language (#404)

Adjacent to #400 — while this isn't yet a proper localization pass, at
least dates & times will now use the user's browser language/locale
settings. When used in Browsertrix, this should ensure dates are
formatted more consistently, at least when the user has a locale with a
language matching one of the supported languages in Browsertrix set in
their browser settings.

Also adds tabular numerals in a few places (e.g. lists of dates/times).
This commit is contained in:
Emma Segal-Grossman
2025-03-04 13:52:06 -05:00
committed by GitHub
parent 51c7eef4cd
commit 64dc599532
7 changed files with 62 additions and 26 deletions
+4 -1
View File
@@ -12,6 +12,7 @@ import { tsToDate } from "./pageutils";
import prettyBytes from "pretty-bytes";
import { property } from "lit/decorators.js";
import type { ItemType } from "./types";
import { dateTimeFormatter } from "./utils/dateTimeFormatter";
// ===========================================================================
export class RWPEmbedReceipt extends LitElement {
@@ -184,7 +185,9 @@ export class RWPEmbedReceipt extends LitElement {
? `https://crt.sh/?q=${certFingerprint}`
: "";
const dateStr = tsToDate(this.ts).toLocaleString();
const dateStr = this.ts
? dateTimeFormatter.format(tsToDate(this.ts) as Date)
: "";
return html`
<div class="dropdown mb-4 ${this.active ? "is-active" : ""}">