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/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to