]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed a tricky little bug with usergetmidnight() when no timezone was defined.
authormartin <martin>
Thu, 8 Aug 2002 17:28:30 +0000 (17:28 +0000)
committermartin <martin>
Thu, 8 Aug 2002 17:28:30 +0000 (17:28 +0000)
lib/moodlelib.php

index 10fffe59190542928b7301fade84fe1f3162489e..9672f4820461a64b96ad4eeece269ae74c67130e 100644 (file)
@@ -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