Skip to content

[Bug] Calendar Hour not showing correct when converting from lower timezone to higher one (UTC+2 -> UTC+3) #3784

@Raducu-Alexandru

Description

@Raducu-Alexandru

Environment

MagicMirror² version: 2.31.0
Node version: 22.15.0
npm version: 10.9.2
Platform: Raspberry pi

Which start option are you using?

npm run start

Are you using PM2?

No

Module

calendar

Have you tried disabling other modules?

  • Yes
  • No

Have you searched if someone else has already reported the issue on the forum or in the issues?

  • Yes

What did you do?

Description:

When trying to convert the hour received from the .ics file, which is in the UTC format, the module converts it to one hour later (at least for my example)

Steps to reproduce the issue:

Load an .ics file with an event where the time is set in UTC and the timezone is UTC+2, and try to view it in a timezone with UTC+3

What did you expect to happen?

To show the hour correctly in UTC+3

What actually happened?

The hour was 1 hour in the future in UTC+3

Additional comments

Solution:

The file modules/default/calendar/calendarfetcherutils.js on line 687 has a line that is commented out for calculating the eventDiff in the case described above. Furthermore, the commented line is incomplete

Line:

//eventDiff = eventDiff; //- nowDiff

Correct line:

eventDiff = nowDiff - eventDiff;

Explanation for the solution:

When calculating the diff between a timezone of smaller and greater (UTC+2 to UTC+3) we need to only get the diff from the bigger - smaller (3 - 2 = 1), before resolving this line the startMoment on line 691 was calculated using the eventDiff from line 640, which was 2, so it added 2 hours instead of 1, to a time already in UTC+2, and by doing so it converted it to an UTC+4 instead of an UTC+3.

Participation

  • I am willing to submit a pull request for this change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions