
In the process of correcting the calendar's behavior for users who are not logged in at all, I came across this code in userdate():
if ($timezone == 99) { // Work out the best timezone to use
if (isset($USER->timezone)) { // A user is logged in
$timezone = (float)$USER->timezone;
} else if (isset($CFG->timezone)) { // Use site's default timezone
$timezone = (float)$CFG->timezone;
}
}
That is the "correct" behavior, and is in accordance with the explanatory text for "timezone" in Configuration -> Variables, which reads:
You can set the default timezone here. This is the only the DEFAULT timezone for displaying dates - each user can override this by setting their own in their profile. "Server time" here will make Moodle default to the server's operating system setting, but "Server time" in the user profile will make the user default to this timezone setting.
However, looking at the functions:
make_timestamp()You see the same (wrong?) code:
usergetdate()
usertime()
usergetmidnight()
usertimezone()
if ($timezone == 99) {
$timezone = (float)$USER->timezone;
}
which doesn't return the site's timezone (which in turn, if unset would imply the server's timezone) but GMT. At the very least, this is inconsistent. Most probably, it's also a bug. If you can spare the time, I 'd like to know how this issue is supposed to be resolved because calendar depends on the behavior of all these.
Cheers,
Jon