]> git.mjollnir.org Git - moodle.git/commitdiff
Slight changes to userdate() function. It now uses gmstrftime() instead of
authormartin <martin>
Tue, 2 Jul 2002 07:02:28 +0000 (07:02 +0000)
committermartin <martin>
Tue, 2 Jul 2002 07:02:28 +0000 (07:02 +0000)
gmdate to format times, thus allowing it to take advantage of locale, if set,
to print dates in the appropriate language.  Several userdate invocations
had to be changed, though, to use the different formatting specs.

course/index.php
course/lib.php
course/log.php
files/index.php
lib/moodlelib.php
lib/setup.php
mod/forum/lib.php
mod/survey/download.php
mod/survey/lib.php
mod/survey/report.php

index bb11588780d8695785fe3559065d5a7ab5315e0f..7c3bd4b7f138065a3e01c3e8aeb586e5b3fbbdac 100644 (file)
@@ -3,7 +3,9 @@
     require("../config.php");
     require("lib.php");
 
-    print_header("Courses", "Courses", "Courses", "");
+    $title = get_string("courses");
+
+    print_header($title, $title, $title, "");
 
     optional_variable($cat, 1);
 
index d09ee3cc760ce09b6a15c2ff3c86be1ed6772a8f..cf659275aecaaca92904557e87a549179f061c92 100644 (file)
@@ -64,7 +64,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
     $timemidnight = $today = usergetmidnight($timenow);
 
     // Put today up the top of the list
-    $dates = array("$timemidnight" => "Today, ".userdate($timenow, "j F Y") );
+    $dates = array("$timemidnight" => "Today, ".userdate($timenow, "%e %B %Y") );
 
     if (! $course->startdate) {
         $course->startdate = $course->timecreated;
@@ -74,7 +74,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
     while ($timemidnight > $course->startdate and $numdates < 365) {
         $timemidnight = $timemidnight - 86400;
         $timenow = $timenow - 86400;
-        $dates["$timemidnight"] = userdate($timenow, "l, j F Y");
+        $dates["$timemidnight"] = userdate($timenow, "%A, %e %B %Y");
         $numdates++;
     }
 
@@ -161,8 +161,8 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
         if (! $course->category) {
             echo "<TD><FONT SIZE=2><A HREF=\"view.php?id=$log->course\">".$courses[$log->course]."</A></TD>";
         }
-        echo "<TD ALIGN=right><FONT SIZE=2>".userdate($log->time, "l")."</TD>";
-        echo "<TD><FONT SIZE=2>".userdate($log->time, "j M Y, h:i A")."</TD>";
+        echo "<TD ALIGN=right><FONT SIZE=2>".userdate($log->time, "%A")."</TD>";
+        echo "<TD><FONT SIZE=2>".userdate($log->time, "%e %B %Y, %I:%M %p")."</TD>";
         echo "<TD><FONT SIZE=2><A TITLE=\"$log->ip\" HREF=\"../user/view.php?id=$log->user&course=$log->course\"><B>$log->firstname $log->lastname</B></TD>";
         echo "<TD><FONT SIZE=2>";
         link_to_popup_window( make_log_url($log->module,$log->url), "fromloglive","$log->module $log->action", 400, 600);
@@ -201,7 +201,7 @@ function print_course($course) {
     echo "<TABLE WIDTH=100%>";
     echo "<TR VALIGN=top>";
     echo "<TD VALIGN=top WIDTH=50%>";
-    echo "<P><FONT SIZE=3><B><A TITLE=\"Click to enter this course\" 
+    echo "<P><FONT SIZE=3><B><A TITLE=\"".get_string("entercourse")."\" 
               HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</A></B></FONT></P>";
     if ($teachers = get_records_sql("SELECT u.* FROM user u, user_teachers t 
                                      WHERE u.id = t.user AND t.course = '$course->id' 
index 580d4f6f9a5bc72e06bc5a31276f1c66557ffacf..d89f2c9f933675491ba762634be93f5e1296096c 100644 (file)
@@ -39,7 +39,7 @@
             $userinfo = "$u->firstname $u->lastname";
         }
         if ($date) {
-            $dateinfo = userdate($date, "l, j F Y");
+            $dateinfo = userdate($date, "%A, %e %B %Y");
         }
 
         print_header("$course->shortname: Logs", "$course->fullname", 
index 90c5efd7a376697354f61d5b1a5669baa20c2d74..09ae0c2d29019945c0520a98fd6ce749d95adc63 100644 (file)
@@ -535,7 +535,7 @@ function displaydir ($wdir) {
             $filename = $fullpath."/".$dir;
             $fileurl  = rawurlencode($wdir."/".$dir);
             $filesafe = rawurlencode($dir);
-            $filedate = userdate(filectime($filename), "d-m-Y H:i:s");
+            $filedate = userdate(filectime($filename), "%e %b %Y, %I:%M %p");
     
             echo "<TR>";
 
@@ -561,7 +561,7 @@ function displaydir ($wdir) {
             $fileurl     = "$wdir/$file";
             $filesafe    = rawurlencode($file);
             $fileurlsafe = rawurlencode($fileurl);
-            $filedate    = userdate(filectime($filename), "d-m-Y H:i:s");
+            $filedate    = userdate(filectime($filename), "%e %b %Y, %I:%M %p");
 
             echo "<TR>";
 
index ba4fdb12f1104e93c54ccdb2c100867e0711c47b..d38d5b48206b1ffa73898e845c0640f547b78645 100644 (file)
@@ -205,10 +205,12 @@ function update_module_icon($moduleid) {
 
 function userdate($date, $format="", $timezone=99) {
 // Returns a formatted string that represents a date in user time
+// WARNING: note that the format is for strftime(), not date().
+
     global $USER;
 
     if ($format == "") {
-        $format = "l, j F Y, g:i A";
+        $format = "%A, %e %B %Y, %I:%M %p";
     }
     if ($timezone == 99) {
         $timezone = (float)$USER->timezone;
@@ -216,7 +218,7 @@ function userdate($date, $format="", $timezone=99) {
     if (abs($timezone) > 12) {
         return date("$format", $date);
     }
-    return gmdate($format, $date + (int)($timezone * 3600));
+    return gmstrftime($format, $date + (int)($timezone * 3600));
 }
 
 function usergetdate($date, $timezone=99) {
@@ -1117,7 +1119,7 @@ function get_string($identifier, $module="", $a="", $b="", $c="") {
     if (!file_exists($langfile)) {                // try English instead
         $langfile = "$langpath/en/strings.php";
         if (!file_exists($langfile)) {
-            return "ERROR: No translation file found";
+            return "ERROR: No lang file";
         }
     }
 
@@ -1128,18 +1130,18 @@ function get_string($identifier, $module="", $a="", $b="", $c="") {
 
     } else {
         if ($lang == "en") {
-            return "ERROR: Translation string '$identifier' is missing!";
+            return "ERROR: '$identifier' is missing!";
 
         } else {   // Try looking in the english file.
             $langfile = "$langpath/en/strings.php";
             if (!file_exists($langfile)) {
-                return "ERROR: No translation file found";
+                return "ERROR: No lang file";
             }
             if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
                 eval($result);
                 return $resultstring;
             } else {
-                return "ERROR: Translation string '$identifier' is missing!";
+                return "ERROR: '$identifier' is missing!";
             }
         }
     }
index 6a12ff0473bf4bc2388f34d6fd0275fe312c9e83..d72642c952bb73a595b40b46c96d3d7ff8e5d425 100644 (file)
     $CFG->header      = "$CFG->dirroot/theme/$CFG->theme/header.html";
     $CFG->footer      = "$CFG->dirroot/theme/$CFG->theme/footer.html";
 
+// Set language/locale of printed times (must be supported by OS)
+
+    setlocale ("LC_TIME", $CFG->lang);
+
 // Load up theme variables (colours etc)
 
     require("$CFG->dirroot/theme/$CFG->theme/config.php");
index f8237892bf496f8f8877669c26a13d280beb6667..53631d6b71ce05191ea241781389dad34019af69 100644 (file)
@@ -162,7 +162,7 @@ function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style
             $ownpost = ($topic->userid == $USER->id);
             switch ($forum_style) {
                 case "minimal":
-                    echo "<P><FONT COLOR=#555555>".userdate($topic->modified, "j M H:i")."</FONT>";
+                    echo "<P><FONT COLOR=#555555>".userdate($topic->modified, "%e %B, %H:%M")."</FONT>";
                     echo "<BR>$topic->subject ";
                     echo "<A HREF=\"$CFG->wwwroot/mod/discuss/view.php?d=$topic->discuss\">more...</A>";
                     echo "</P>\n";
index e41057d27eefb8a93c75736a33cdf2e4d4db1d5b..dd8d6dda60208ccfb2ebf64284e43deb803c5616 100644 (file)
             $myxls->InsertText($u->lastname);
             $myxls->InsertText($u->email);
             $myxls->InsertText($u->idnumber);
-            $myxls->InsertText( userdate($results["$user"]["time"], "d-M-Y h:i:s A") );
+            $myxls->InsertText( userdate($results["$user"]["time"], "%d-%b-%Y %I:%M:%S %p") );
             $myxls->InsertText($notes);
     
             foreach ($order as $key => $qid) {
         if (! $u = get_record_sql("SELECT firstname,lastname,email,idnumber FROM user WHERE id = '$user'")) {
             error("Error finding student # $user");
         }
-        echo $survey->id."    ";
-        echo $survey->name."    ";
-        echo $user."    ";
-        echo $u->firstname."    ";
-        echo $u->lastname."    ";
-        echo $u->email."    ";
-        echo $u->idnumber."    ";
-        echo userdate($results["$user"]["time"], "d-M-Y h:i:s A")."    ";
+        echo $survey->id."\t";
+        echo $survey->name."\t";
+        echo $user."\t";
+        echo $u->firstname."\t";
+        echo $u->lastname."\t";
+        echo $u->email."\t";
+        echo $u->idnumber."\t";
+        echo userdate($results["$user"]["time"], "%d-%b-%Y %I:%M:%S %p")."\t";
 
         foreach ($order as $key => $qid) {
             $question = $questions["$qid"];
index ffe96ab5ecf55b70de9dbfe57b8399318086444e..c84473253fa7b2946a85fcbe5adf936547666ca4 100644 (file)
@@ -60,7 +60,7 @@ function print_all_responses($survey, $results) {
                  
         echo "<TR>";
         echo "<TD><A HREF=\"report.php?action=student&student=$a->id&id=$survey\">$a->firstname $a->lastname</A></TD>";
-        echo "<TD>".userdate($a->time, "j M Y, h:i A")."</TD>";
+        echo "<TD>".userdate($a->time, "%e %B %Y, %I:%M %p")."</TD>";
         echo "<TD align=right>$a->numanswers</TD>";
         echo "</TR>";
     }
index 9a9b252a201b555fef9f7df8318bffafcc42d237..30226e3a1d03171b11233b7cf35c7b146acaf2dc 100644 (file)
             print_user_picture($a->user, $course->id, $a->picture, false);
             echo "</TD>";
             echo "<TD><P><A HREF=\"report.php?id=$id&action=student&student=$a->user\">$a->firstname $a->lastname</A></TD>";
-            echo "<TD><P>".userdate($a->time, "j M Y h:i A")."</TD>";
+            echo "<TD><P>".userdate($a->time, "%e %B %Y, %I:%M %p")."</TD>";
             echo "<TD BGCOLOR=\"$THEME->cellcontent\"><P>";
             if ($a->answer1) {
                 echo "$a->answer1 - ".$answers[$a->answer1 - 1];