Daylight Savings Time (DST) Bug

Daylight Savings Time (DST) Bug

by Mathieu Leblond -
Number of replies: 0

Noticed when adding slots for a extended period at once that crosses DST that one hour is added/loss depending on spring or fall change.

Had to add code to make sure it checks that start time is always equal to original start time and that it either adds to the buffer or removes the necessary time in question.

 

Document: /teacher.controller.php
Code Changes:

Line 310

if ( date("H:i", $startfrom) != date("H:i", $startfrom + ($d * DAYSECS))) {

$original_start_hour = date("H", $startfrom);

$original_start_min = date("i", $startfrom);

$dst_start_hour = date("H", $startfrom + ($d * DAYSECS));

$dst_start_min = date("i", $startfrom + ($d * DAYSECS));

 

$diff_hour = $original_start_hour - $dst_start_hour;

$diff_min = $original_start_min - $dst_start_min;

 

$add_time = $d * DAYSECS;

$add_time += $diff_hour * 3600;

$add_time += $diff_min * 60;

 

$slot->starttime = $startfrom + $add_time;

$data->timestart = $startfrom + $add_time;

}

else{

$slot->starttime = $startfrom + ($d * DAYSECS);

$data->timestart = $startfrom + ($d * DAYSECS);

}

Average of ratings: Useful (1)