$string['databasesetup'] = "Setting up database";
$string['databasesuccess'] = "Database was successfully upgraded";
$string['databaseupgrades'] = "Upgrading database";
+$string['day'] = "day";
+$string['days'] = "days";
$string['defaultcoursefullname'] = "Course Fullname 101";
$string['defaultcourseshortname'] = "CF101";
$string['defaultcoursestudent'] = "Student";
$string['helpquestions'] = "How to ask questions";
$string['hide'] = "Hide";
$string['home'] = "Home";
+$string['hour'] = "hour";
+$string['hours'] = "hours";
$string['htmlformat'] = "Pretty HTML format";
$string['icqnumber'] = "ICQ number";
$string['idnumber'] = "ID number";
$string['maximumchars'] = "Maximum of \$a characters";
$string['maximumgrade'] = "Maximum grade";
$string['maxsize'] = "Max size: \$a";
+$string['min'] = "min";
+$string['mins'] = "mins";
$string['miscellaneous'] = "Miscellaneous"; // Default course category
$string['missingcategory'] = "You need to choose a category";
$string['missingcity'] = "Missing city/town";
$string['search'] = "Search";
$string['searchagain'] = "Search again";
$string['searchresults'] = "Search results";
+$string['sec'] = "sec";
+$string['secs'] = "secs";
$string['section'] = "Section";
$string['selectacountry'] = "Select a country";
$string['senddetails'] = "Send my details via email";
return mktime((int)$hour,(int)$minute,(int)$second,(int)$month,(int)$day,(int)$year);
}
-function format_time($totalsecs) {
+function format_time($totalsecs, $str=NULL) {
// Given an amount of time in seconds, prints it
// nicely as months, days, hours etc as needed
$totalsecs = abs($totalsecs);
- $days = floor($totalsecs/86400);
+ if (!$str) { // Create the str structure the slow way
+ $str->day = get_string("day");
+ $str->days = get_string("days");
+ $str->hour = get_string("hour");
+ $str->hours = get_string("hours");
+ $str->min = get_string("min");
+ $str->mins = get_string("mins");
+ $str->sec = get_string("sec");
+ $str->secs = get_string("secs");
+ }
+
+ $days = floor($totalsecs/86400);
$remainder = $totalsecs - ($days*86400);
- $hours = floor($remainder/3600);
+ $hours = floor($remainder/3600);
$remainder = $remainder - ($hours*3600);
- $mins = floor($remainder/60);
- $secs = $remainder - ($mins*60);
-
- if ($secs != 1) $ss = "s";
- if ($mins != 1) $ms = "s";
- if ($hours != 1) $hs = "s";
- if ($days != 1) $ds = "s";
-
- if ($days) $odays = "$days day$ds";
- if ($hours) $ohours = "$hours hr$hs";
- if ($mins) $omins = "$mins min$ms";
- if ($secs) $osecs = "$secs sec$ss";
+ $mins = floor($remainder/60);
+ $secs = $remainder - ($mins*60);
+
+ $ss = ($secs == 1) ? $str->sec : $str->secs;
+ $sm = ($mins == 1) ? $str->min : $str->mins;
+ $sh = ($hours == 1) ? $str->hour : $str->hours;
+ $sd = ($days == 1) ? $str->day : $str->days;
+
+ if ($days) $odays = "$days $sd";
+ if ($hours) $ohours = "$hours $sh";
+ if ($mins) $omins = "$mins $sm";
+ if ($secs) $osecs = "$secs $ss";
if ($days) return "$odays $ohours";
if ($hours) return "$ohours $omins";
$string->role = get_string("role");
$string->never = get_string("never");
$string->name = get_string("name");
+ $string->day = get_string("day");
+ $string->days = get_string("days");
+ $string->hour = get_string("hour");
+ $string->hours = get_string("hours");
+ $string->min = get_string("min");
+ $string->mins = get_string("mins");
+ $string->sec = get_string("sec");
+ $string->secs = get_string("secs");
if ( $teachers = get_course_teachers($course->id)) {
echo "<H2 align=center>$course->teachers</H2>";
foreach ($students as $student) {
if ($student->lastaccess) {
- $lastaccess = format_time(time() - $student->lastaccess);
+ $lastaccess = format_time(time() - $student->lastaccess, $string);
} else {
$lastaccess = $string->never;
}
echo "$string->location: $user->city, ".$COUNTRIES["$user->country"]."<BR>";
if ($user->lastaccess) {
echo "$string->lastaccess: ".userdate($user->lastaccess);
- echo "  (".format_time(time() - $user->lastaccess).")";
+ echo "  (".format_time(time() - $user->lastaccess, $string).")";
} else {
echo "$string->lastaccess: $string->never";
}