[openstreetmap/openstreetmap-website] Timezone mismatch between heatmap data and tooltips (Issue #6378)

mmd notifications at github.com
Sat Sep 6 08:00:26 UTC 2025


mmd-osm left a comment (openstreetmap/openstreetmap-website#6378)

I can reproduce the issue using Chrome Dev Tools -> ... -> Sensors. Both options below to fix the issue seemed to work ok.

#### Option 1: pass date as string

```javascript
diff --git a/app/assets/javascripts/heatmap.js b/app/assets/javascripts/heatmap.js
index 72d34042f..fc7ed85e5 100644
--- a/app/assets/javascripts/heatmap.js
+++ b/app/assets/javascripts/heatmap.js
@@ -39,7 +39,7 @@ $(document).on("turbo:frame-load", function () {
       continue;
     }
     const count = $day.data("count") ?? 0;
-    const tooltipText = getTooltipText(date, count);
+    const tooltipText = getTooltipText($day.data("date"), count);
     $day
       .css("grid-area", getWeekdayRow(date.getUTCDay()) + " / " + weekColumn)
       .attr("aria-label", tooltipText)
```

#### Option 2: use built in formatting, with explicit timezone

```javascript
diff --git a/app/assets/javascripts/heatmap.js b/app/assets/javascripts/heatmap.js
index 72d34042f..fdb7118f1 100644
--- a/app/assets/javascripts/heatmap.js
+++ b/app/assets/javascripts/heatmap.js
@@ -65,7 +65,11 @@ $(document).on("turbo:frame-load", function () {
   }
 
   function getTooltipText(date, value) {
-    const localizedDate = OSM.i18n.l("date.formats.heatmap", date);
+    const localizedDate = new Intl.DateTimeFormat(OSM.i18n.locale, {
+      month: "long",
+      day: "numeric",
+      timeZone: "UTC"
+    }).format(date);
 
     if (value > 0) {
       return OSM.i18n.t("javascripts.heatmap.tooltip.contributions", { count: value, date: localizedDate });
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/6378#issuecomment-3261551843
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/issues/6378/3261551843 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250906/1b88022a/attachment-0001.htm>


More information about the rails-dev mailing list