Skip to content

Graph dates off by one day due to timezone conversion bug #1

@matiasmoya

Description

@matiasmoya

Describe the bug
Dates displayed in the activity graph are consistently off by one day (showing the previous day) compared to the actual data provided. For example, if the activity data contains the date 2025-09-29, the graph displays 2025-09-28.

To Reproduce
Steps to reproduce the behavior:
0. Your system should be in a timezone behind UTC. (-3GMT in my case)

  1. Render the activity graph using sample data with a known date (e.g., 2025-09-29).
  2. Observe the rendered graph: the displayed date is one day before the provided date. (inspect element and read the title attribute for that td element)

Root Cause
The bug is caused by a timezone conversion issue in src/activity-graph-element.js. On line 147, the code uses currentDate.toLocaleDateString(lang) to display the date. This converts the UTC date to the local timezone, resulting in a date shift.

Suggested Fix
Replace:

currentDate.toLocaleDateString(lang)

with:

currentDate.toLocaleDateString(lang, { timeZone: 'UTC' })

This ensures the date is displayed in UTC and matches the actual activity data.

Relevant code snippet:

// src/activity-graph-element.js
const text = `${currentDate.toLocaleDateString(lang, { timeZone: 'UTC' })} – Activities: ${activityData[dateKey] || 0}`;

Expected behavior
Dates displayed in the graph should exactly match the dates provided in the activity data.

Additional context
Current behavior is reproducible in any timezone where local time is behind UTC.


I am submitting a PR with this fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions