From: Anton Khorev Date: Fri, 21 Mar 2025 12:59:02 +0000 (+0300) Subject: Use Date().toLocaleString() to construct month titles X-Git-Tag: live~59^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/5038b06bdf1c49d6ac2d989d45934dace0ef0377?ds=sidebyside Use Date().toLocaleString() to construct month titles Ensures that standalone month names are in the nominative case. --- diff --git a/app/assets/javascripts/heatmap.js b/app/assets/javascripts/heatmap.js index 572b621a4..240707609 100644 --- a/app/assets/javascripts/heatmap.js +++ b/app/assets/javascripts/heatmap.js @@ -16,7 +16,6 @@ document.addEventListener("DOMContentLoaded", () => { const colorScheme = document.documentElement.getAttribute("data-bs-theme") ?? "auto"; const rangeColors = ["#14432a", "#166b34", "#37a446", "#4dd05a"]; const startDate = new Date(Date.now() - (365 * 24 * 60 * 60 * 1000)); - const monthNames = OSM.i18n.t("date.abbr_month_names"); const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)"); @@ -34,7 +33,7 @@ document.addEventListener("DOMContentLoaded", () => { type: "month", gutter: 4, label: { - text: (timestamp) => monthNames[new Date(timestamp).getUTCMonth() + 1], + text: (timestamp) => new Date(timestamp).toLocaleString(OSM.i18n.locale, { timeZone: "UTC", month: "short" }), position: "top", textAlign: "middle" },