From 80ca9cac9df644922b8415e244af7c66c7fc8e27 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Fri, 5 Sep 2025 16:40:46 +0200 Subject: [PATCH] Use consistent US locales for dates https://3.basecamp.com/2914079/buckets/37331921/todos/9010176047#__recording_9040694230 --- .../controllers/local_time_controller.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/javascript/controllers/local_time_controller.js b/app/javascript/controllers/local_time_controller.js index ee7dfd3a3..35c57e56c 100644 --- a/app/javascript/controllers/local_time_controller.js +++ b/app/javascript/controllers/local_time_controller.js @@ -9,14 +9,14 @@ export default class extends Controller { #timer initialize() { - this.timeFormatter = new Intl.DateTimeFormat(undefined, { timeStyle: "short" }) - this.dateFormatter = new Intl.DateTimeFormat(undefined, { dateStyle: "long" }) - this.shortdateFormatter = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }) - this.datetimeFormatter = new Intl.DateTimeFormat(undefined, { timeStyle: "short", dateStyle: "short" }) + this.timeFormatter = new Intl.DateTimeFormat("en-US", { timeStyle: "short" }) + this.dateFormatter = new Intl.DateTimeFormat("en-US", { dateStyle: "long" }) + this.shortdateFormatter = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" }) + this.datetimeFormatter = new Intl.DateTimeFormat("en-US", { timeStyle: "short", dateStyle: "short" }) this.agoFormatter = new AgoFormatter() this.daysagoFormatter = new DaysAgoFormatter() - this.datewithweekdayFormatter = new Intl.DateTimeFormat(undefined, { weekday: "long", month: "long", day: "numeric" }) - this.datewithweekdayFormatter = new Intl.DateTimeFormat(undefined, { weekday: "long", month: "long", day: "numeric" }) + this.datewithweekdayFormatter = new Intl.DateTimeFormat("en-US", { weekday: "long", month: "long", day: "numeric" }) + this.datewithweekdayFormatter = new Intl.DateTimeFormat("en-US", { weekday: "long", month: "long", day: "numeric" }) this.indaysFormatter = new InDaysFormatter() this.agoorweekdayFormatter = new DaysAgoOrWeekdayFormatter() this.timeordateFormatter = new TimeOrDateFormatter() @@ -138,7 +138,7 @@ class DaysAgoOrWeekdayFormatter { if (days <= 1) { return new DaysAgoFormatter().format(date) } else { - return new Intl.DateTimeFormat(undefined, { weekday: "long", month: "long", day: "numeric" }).format(date) + return new Intl.DateTimeFormat("en-US", { weekday: "long", month: "long", day: "numeric" }).format(date) } } } @@ -158,9 +158,9 @@ class TimeOrDateFormatter { const days = differenceInDays(date, new Date()) if (days >= 1) { - return new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }).format(date) + return new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" }).format(date) } else { - return new Intl.DateTimeFormat(undefined, { timeStyle: "short" }).format(date) + return new Intl.DateTimeFormat("en-US", { timeStyle: "short" }).format(date) } } }