Exemplo n.º 1
0
/**
 * This function provides the unix timestamps of the start and end of the requested date type.
 *
 * @uses startof()
 * @param string $type
 * @param int $timestamp
 * @return array or false if $type = all
 */
function fetch_timestamps($type, $timestamp_start, $timestamp_finish = 0)
{
    $start = startof($type, $timestamp_start);
    switch ($type) {
        case "all":
            return false;
            break;
        case "day":
        case "week":
        case "month":
        case "year":
            return array("start" => $start, "end" => strtotime("+1 " . $type, $start) - 1);
            break;
        case "academic":
            if (date("n", $start) >= 9) {
                return array("start" => strtotime("08:00:00 September 1st, " . date("y", $start)), "end" => strtotime("22:00:00 August 31st, " . date("y", strtotime("+1 year", $start))));
            } else {
                return array("start" => strtotime("08:00:00 September 1st, " . date("y", strtotime("-1 year", $start))), "end" => strtotime("22:00:00 August 31st, " . date("y", $start)));
            }
            break;
        case "custom":
            return array("start" => $timestamp_start, "end" => $timestamp_finish);
            break;
        default:
            return array("start" => $start, "end" => strtotime("+1 week", $start) - 1);
            break;
    }
}
Exemplo n.º 2
0
                 application_log("error", "Unable to schedule an occupant into apartment_id [" . $APARTMENT_ID . "]. Database said: " . $db->ErrorMsg());
             }
         }
         if ($ERROR) {
             $STEP = 1;
         }
         break;
     case 1:
     default:
         if (!isset($PROCESSED["inhabiting_start"])) {
             if (isset($_GET["dstamp"]) && ($tmp_input = clean_input($_GET["dstamp"], "int"))) {
                 $timestamp = $tmp_input;
             } else {
                 $timestamp = time();
             }
             $PROCESSED["inhabiting_start"] = startof("month", $timestamp);
             if (!isset($PROCESSED["inhabiting_finish"])) {
                 $PROCESSED["inhabiting_finish"] = strtotime("+1 week", $PROCESSED["inhabiting_start"]) - 1;
             }
         }
         break;
 }
 switch ($STEP) {
     case 2:
         if ($ERROR) {
             echo display_errors();
         }
         if ($NOTICE) {
             echo display_notices();
         }
         if ($SUCCESS) {