Skip to content

Commit

Permalink
fix attempt for auto-attendance logging. Set to use gmdate and gmmktime
Browse files Browse the repository at this point in the history
functions.
  • Loading branch information
jungwirr committed Oct 8, 2003
1 parent a8d28cb commit da5d1ef
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions mod/attendance/lib.php
Expand Up @@ -564,22 +564,6 @@ function get_attendance_for_week($id, $courseid) {
return get_records_sql($sql); return get_records_sql($sql);
} }


/**
* Determines if two dates are on the same day
*
* This function takes two unix timestamps and determines if they occur within the same 24 hours
* It does this by comparing the year, month, and day
*
* @param timestamp $d1 The first date to compare
* @param timestamp $d2 The second date to compare
* @return boolean whether the two dates occur on the same day
*/
function attendance_dates_same_day($d1,$d2) {
$da1 = getdate($d1);
$da2 = getdate($d2);
return (($da1["mday"]==$da2["mday"]) &&($da1["mon"]==$da2["mon"]) && ($da1["year"]==$da2["year"]));
}

/** /**
* Finds the beginning of the day for the date specified * Finds the beginning of the day for the date specified
* *
Expand All @@ -589,10 +573,13 @@ function attendance_dates_same_day($d1,$d2) {
* @return timestamp midnight for that day * @return timestamp midnight for that day
*/ */
function attendance_find_today($d) { function attendance_find_today($d) {
// add 24 hours to the current time - to solve end of month date issues // $da = getdate($d);
$da = getdate($d); $damon = gmdate("m",$d);
$daday = gmdate("d",$d);
$dayear = gmdate("Y",$d);
// now return midnight of that day // now return midnight of that day
return mktime(0,0,0,$da["mon"], $da["mday"], $da["year"]); // return mktime(0,0,0,$da["mon"], $da["mday"], $da["year"]);
return gmmktime(0,0,0,$damon, $daday, $dayear);
} }


/** /**
Expand Down

0 comments on commit da5d1ef

Please sign in to comment.