Skip to content

Commit

Permalink
Fixing two bugs:
Browse files Browse the repository at this point in the history
1. When user was using "Server's local time", and the server was set up to
   use DST, generated timestamps must have been wrong in DST periods (I
   haven't backtracked to test this, but the code reads this way).

2. On Eloy's Mac (let's not generalize without data), passing is_dst = 0 to
   gmmktime caused it to return WRONG results!

   The PHP docs clearly state that in_dst does NOT affect the return value,
   which is true for me but in Eloy's case it was a lie. Obviously PHP bug here.

Also, moved the if($applydst) check into the else branch because it would do
nothing at all if (abs($timezone) > 13) in any case.


I hope Eloy keeps finding more bugs because he promised me a beer for this fix ;-)
  • Loading branch information
defacer committed May 1, 2005
1 parent 290c327 commit 28c6682
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/moodlelib.php
Expand Up @@ -605,14 +605,13 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0,
$timezone = get_user_timezone_offset($timezone);

if (abs($timezone) > 13) {
$time = mktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year, 0);
$time = mktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year);
} else {
$time = gmmktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year, 0);
$time = gmmktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year);
$time = usertime($time, $timezone);
}

if($applydst) {
$time -= dst_offset_on($time);
if($applydst) {
$time -= dst_offset_on($time);
}
}

return $time;
Expand Down

0 comments on commit 28c6682

Please sign in to comment.