Skip to content

Commit

Permalink
I was going through the code here and found out that it's completely …
Browse files Browse the repository at this point in the history
…missing

the point, it could be much tighter and easier to understand. So here's the
candidate replacement code plus some assertions, I intend to let it run for
some time and if no assertion errors come up (they shouldn't) do the replace.

This was almost my very first Moodle code. Isn't experience wonderful? ;-)
  • Loading branch information
defacer committed Nov 6, 2005
1 parent 00b61a6 commit c0b507d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
$startwday += 7;
}

// TODO: THIS IS TEMPORARY CODE!
// [pj] I was just reading through this and realized that I when writing this code I was probably
// asking for trouble, as all these time manipulations seem to be unnecessary and a simple
// make_timestamp would accomplish the same thing. So here goes a test:
$test_start = make_timestamp($y, $m, 1);
$test_end = make_timestamp($y, $m, $display->maxdays, 23, 59, 59);
if($test_start != usertime($display->tstart) - dst_offset_on($display->tstart)) {
notify('Failed assertion in calendar/lib.php line 126; display->tstart = '.$display->tstart.', dst_offset = '.dst_offset_on($display->tstart).', usertime = '.usertime($display->tstart).', make_t = '.$test_start);
}
if($test_end != usertime($display->tend) - dst_offset_on($display->tend)) {
notify('Failed assertion in calendar/lib.php line 130; display->tend = '.$display->tend.', dst_offset = '.dst_offset_on($display->tend).', usertime = '.usertime($display->tend).', make_t = '.$test_end);
}


// Get the events matching our criteria. Don't forget to offset the timestamps for the user's TZ!
$whereclause = calendar_sql_where(
usertime($display->tstart) - dst_offset_on($display->tstart),
Expand Down

0 comments on commit c0b507d

Please sign in to comment.