$timenow = time(); // GMT
// What day is it now for the user, and when is midnight that day (in GMT).
- $date = usergetdate($timenow);
- $timemidnight = gmmktime (0, 0, 0, $date["mon"], $date["mday"], $date["year"]);
- $timemidnight = usertime($timemidnight); // Time of midnight of this user's day, in GMT
+ $timemidnight = usergetmidnight($timenow);
// Put today up the top of the list
$dates = array("$timemidnight" => "Today, ".userdate($timenow, "j F Y") );
return $date - (int)($timezone * 3600);
}
+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);
+ $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
+
+}
+
function usertimezone($timezone=99) {
// returns a string that prints the user's timezone
global $USER;
echo "<FONT SIZE=1>";
if ($teacherlinks) {
- $tt = usergetdate(time());
- $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
+ $timemidnight = usergetmidnight(time());
echo "<A HREF=\"../course/user.php?id=$course->id&user=$user->id\">Contributions</A><BR>";
- echo "<A HREF=\"../course/log.php?id=$course->id&user=$user->id&date=$today\">Today's logs</A><BR>";
+ echo "<A HREF=\"../course/log.php?id=$course->id&user=$user->id&date=$timemidnight\">Today's logs</A><BR>";
echo "<A HREF=\"../course/log.php?id=$course->id&user=$user->id\">All logs</A><BR>";
if (isstudent($course->id, $user->id)) {
echo "<A HREF=\"../course/loginas.php?id=$course->id&user=$user->id\">Login as</A><BR>";