]> git.mjollnir.org Git - moodle.git/commitdiff
Use a site-defined timezone if one is defined
authormoodler <moodler>
Thu, 12 Feb 2004 05:55:04 +0000 (05:55 +0000)
committermoodler <moodler>
Thu, 12 Feb 2004 05:55:04 +0000 (05:55 +0000)
lib/moodlelib.php

index c7646753718f8cafe5291579e876faa1088a7850..398df3d31b9d773117b111789fdca60d06dd955e 100644 (file)
@@ -234,7 +234,7 @@ function userdate($date, $format="", $timezone=99, $fixday = true) {
 /// If parammeter fixday = true (default), then take off leading 
 /// zero from %d, else mantain it.
 
-    global $USER;
+    global $USER, $CFG;
 
     if ($format == "") {
         $format = get_string("strftimedaydatetime");
@@ -245,11 +245,14 @@ function userdate($date, $format="", $timezone=99, $fixday = true) {
         $fixday = ($formatnoday != $format);
     }
 
-    if ($timezone == 99) {
-        if (isset($USER->timezone)) {
+    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;
         }
     }
+
     if (abs($timezone) > 13) {
         if ($fixday) {
             $datestring = strftime($formatnoday, $date);