Skip to content

Incorrect session time calculation during DST transition (clock shift) #896

@yonatankostov

Description

@yonatankostov

Summary

There is an issue with session time calculation in mod/attendance/locallib.php when daylight saving time (DST) changes occur. The current implementation calculates times starting from midnight, which causes incorrect session durations when the clock shifts (e.g., at 02:00).

Code Reference
$sesstarttime = $formdata->sestime['starthour'] * HOURSECS + $formdata->sestime['startminute'] * MINSECS;
$sesendtime = $formdata->sestime['endhour'] * HOURSECS + $formdata->sestime['endminute'] * MINSECS;
$sessiondate = $formdata->sessiondate + $sesstarttime;
$duration = $sesendtime - $sesstarttime;

Problem

The calculation assumes a continuous timeline from midnight (00:00). However, during DST transitions (e.g., when clocks move forward at 02:00), one hour is skipped

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions