mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
Fixed a tricky little bug with usergetmidnight() when no timezone was defined.
This commit is contained in:
parent
a2ab3b0511
commit
4606d9bb9f
@ -352,10 +352,18 @@ function usertime($date, $timezone=99) {
|
||||
function usergetmidnight($date, $timezone=99) {
|
||||
// Given a time, return the GMT timestamp of the most recent midnight
|
||||
// for the current user.
|
||||
|
||||
global $USER;
|
||||
|
||||
if ($timezone == 99) {
|
||||
$timezone = (float)$USER->timezone;
|
||||
}
|
||||
|
||||
$userdate = usergetdate($date, $timezone);
|
||||
|
||||
if (abs($timezone) > 12) {
|
||||
return mktime(0, 0, 0, $userdate["mon"], $userdate["mday"], $userdate["year"]);
|
||||
}
|
||||
|
||||
$timemidnight = gmmktime (0, 0, 0, $userdate["mon"], $userdate["mday"], $userdate["year"]);
|
||||
return usertime($timemidnight, $timezone); // Time of midnight of this user's day, in GMT
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user