Example #1
0
</th>
                        </tr>
                        <tr>
                            <th>По</th>
                            <th>Вт</th>
                            <th>Ср</th>
                            <th>Чт</th>
                            <th>Пе</th>
                            <th>Сб</th>
                            <th class="last-day">Не</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
        $monthDays = cal_days_in_month(CAL_GREGORIAN, $monthIndex + 1, $currentYear);
        $dayOfWeek = getDayOfWeek($monthIndex + 1, $currentYear);
        for ($innerRow = 0, $daysCounter = 0; $innerRow < MAX_WEEKS_COUNT; $innerRow++) {
            ?>
                            <tr>
                                <?php 
            for ($innerCol = 0; $innerCol < DAYS_PER_WEEK; $innerCol++, $daysCounter++) {
                ?>
                                    <td>
                                        <?php 
                $currentDay = $daysCounter - $dayOfWeek + 2;
                if ($currentDay >= 1 && $currentDay <= $monthDays) {
                    echo $currentDay;
                }
                ?>
                                    </td>
                                <?php 
Example #2
0
    }
}
// main processing
$query = "SELECT * FROM `events` WHERE startMonth > 0 or length(reference) > 0 ORDER BY `startMonth` ASC";
$result = fetch_all($query);
foreach ($result as $key => $value) {
    // initializa event date
    $eventDate = getdate();
    if ($value['reference'] != 'YEAR' && $value['reference'] != 'MONTH') {
        $typeOfEvent = substr($value['reference'], 0, 2);
        // this is the part where the event is based on another event or holiday
        if ($typeOfEvent == 'e9') {
            $eventDate = getDateByReference($value['reference'], $value['_id']);
        } else {
            if ($value['ref_code'] == 'LAST') {
                $getJulianDate = "SELECT max(juliandate) FROM fiscalcalendar WHERE fmonth = " . $value['fmonth'] . " and fyear = " . $value['fyear'] . " and dayofweek = " . getDayOfWeek($value['dayofweek']);
                $eventDate = fecth_record($getJulianDate);
            }
        }
        // determine the duration
        switch ($value['ref_code']) {
            case 'WEEK':
                $setDuration = 7;
                break;
            case 'WEEKEND':
                $setDuration = 3;
                break;
        }
        if ($typeOfEvent == 'e9') {
            $setDuration = $value['ref_code'];
        }
Example #3
0
             if ($ibgro == "2n.gif" and date("d", strtotime($fechin)) == date("d", strtotime($row['arrival']))) {
                 $ibgro = "2b.gif";
             }
             if ($ibgro == "n1.gif" and date("d", strtotime($fechin)) == date("d", strtotime($row['departure']))) {
                 $ibgro = "2a.gif";
             }
             if ($ibgro == "1n.gif" and date("d", strtotime($fechin)) == date("d", strtotime($row['arrival']))) {
                 $ibgro = "1b.gif";
             }
         }
     }
 }
 if ($a == 0) {
     $ibgro = "blanco.gif";
 }
 $diax = intval(getDayOfWeek(date("d", strtotime($fet)), date("m", strtotime($fet)), date("Y", strtotime($fet))));
 if ($ibgro == "blanco.gif") {
     echo "\t" . "\t" . "<TD  background='../images/" . $ibgro . "' align='center'  bgcolor='#FFFFFF'>" . $iCurrent . "<BR></TD>" . "\r";
 } else {
     echo "\t" . "\t" . "<TD  background='../images/" . $ibgro . "' align='center'  bgcolor='#FFFFFF'><a class='thumbnail' href='javascript:void(0);' onclick='seleres(" . '"' . $idreserva . '"' . ");'>" . $iCurrent . "</a><BR></TD>" . "\r";
 }
 // if we're at the endof a row { write /TR
 if ($iPosition == 7) {
     echo "\t" . "</TR>" . "\r";
     $iPosition = 0;
 }
 // Increment variables
 $iCurrent++;
 $iPosition++;
 $idreserva = "";
 $idreserva = "";
Example #4
0
$cellID = 0;
for ($i = 1; $i <= 12; $i++) {
    $current_full_month = date("m", mktime(0, 0, 0, $current_month, 1, $current_year));
    $days_in_month = date("t", mktime(0, 0, 0, $current_month, 1, $current_year));
    $paper_no = 0;
    echo "<div>";
    echo "<table class=\"monthgrid\">\n";
    $tmp_month = strtolower(date("F", mktime(0, 0, 0, $current_month, 1, $current_year)));
    echo "<tr><td class=\"month\"><a name=\"{$i}\"></a>" . $string[$tmp_month] . "</td></tr>\n";
    echo "<tr><td>";
    echo "<table style=\"width:100%; font-size:85%; margin-left:auto; margin-right:auto\">\n";
    echo "<tr><td class=\"dtext\">" . mb_substr($string['monday'], 0, 3, 'UTF-8') . "</td><td class=\"dtext\">" . mb_substr($string['tuesday'], 0, 3, 'UTF-8') . "</td><td class=\"dtext\">" . mb_substr($string['wednesday'], 0, 3, 'UTF-8') . "</td><td class=\"dtext\">" . mb_substr($string['thursday'], 0, 3, 'UTF-8') . "</td><td class=\"dtext\">" . mb_substr($string['friday'], 0, 3, 'UTF-8') . "</td></tr>";
    $day_no = 1;
    $cell_no = 1;
    $subtract = 0;
    $start_day = getDayOfWeek(1, $current_month, $current_year, 1);
    if ($start_day == 6) {
        $start_day = 1;
        $day_no = 3;
    } elseif ($start_day == 0) {
        $start_day = 1;
        $day_no = 2;
    }
    do {
        $week_no = NULL;
        $tmp_day_no = $day_no - $subtract;
        for ($col = 1; $col <= 5; $col++) {
            if ($tmp_day_no <= $days_in_month) {
                if ($week_no == NULL) {
                    $week_no = date("W", mktime(0, 0, 0, $current_month, $tmp_day_no, $current_year));
                }
Example #5
0
File: food.php Project: Aliide/food
        echo "<div class='dayContainer'>";
        echo "It's a no-food day, what if you went home to eat?";
        echo "</div></div>";
    }
}
function getDayOfWeek($pTimezone)
{
    $userDateTimeZone = new DateTimeZone($pTimezone);
    $UserDateTime = new DateTime("now", $userDateTimeZone);
    $offsetSeconds = $UserDateTime->getOffset();
    //echo $offsetSeconds;
    return gmdate("w", time() + $offsetSeconds) - 1;
}
// -----------------------------------------------------------------------------
// test it!
$dayOfWeek = getDayOfWeek('CET');
echo "<html><head><title>F * O * O * D</title>";
echo "<link rel='stylesheet' type='text/css' href='food.css'>";
echo '<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>';
echo "</head><body>";
echo "<div id='tableContainer'><div class='column'>";
// make sure to give alternatives for the weekend
if ($dayOfWeek > 4 || $dayOfWeek < 0) {
    printOut_noWork(false);
} else {
    printOut_miamarias($dayOfWeek, false);
    echo "</div><div class='column'>";
    printOut_meck($dayOfWeek, false);
    echo "</div><div class='column'>";
    printOut_niagara($dayOfWeek, false);
    echo "</div><div class='column'>";
function daysInMonthDataArray($month, $year)
{
    $array_return = array();
    for ($i = 1; $i <= daysInMonth($month, $year); $i++) {
        $j = $i <= 9 ? '0' . $i : $i;
        $array_return[$i] = $j . ' ' . getDayOfWeek($year, $month, $i);
    }
    return $array_return;
}
<?php

// make a function which returns the day of the week
function getDayOfWeek($dayAsInteger)
{
    // build days array
    $days = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
    // if $daysAsInteger is between 0 and 6, return the day, otherwise return false
    if ($dayAsInteger >= 0 && $dayAsInteger <= 6) {
        return $days[$dayAsInteger];
    } else {
        return false;
    }
}
// get day 4
echo getDayOfWeek(4);
// Thursday
function ISO8601toUnixTimestamp($str)
{
    if (preg_match('/^([0-9]{4})(-?([0-9]{2})(-?([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2}))?(Z|([-+])([0-9]{2})([0-9]{2}))?)?)?)?$/', $str, $match) == 1) {
        // $match[?]
        // $match[0]  : input($str)
        // $match[1]  : year
        // $match[2]  :
        // $match[3]  : month
        // $match[4]  :
        // $match[5]  : day of month
        // $match[6]  :
        // $match[7]  : hour
        // $match[8]  : minute
        // $match[9]  :
        // $match[10] : second
        // time difference below(regexp Z|[-+][0-9]{2}:[0-9]{2})
        // $match[11] : 'Z' or ''
        // $match[12] : +|-
        // $match[13] : hour of time difference
        // $match[14] : minute of time difference
        if (!isset($match[3])) {
            $match[3] = '01';
        }
        if (!isset($match[5])) {
            $match[5] = '01';
        }
        if (!isset($match[7])) {
            $match[7] = '00';
        }
        if (!isset($match[8])) {
            $match[8] = '00';
        }
        if (!isset($match[10]) || $match[10] == "") {
            $match[10] = '00';
        }
        $tm = gmmktime($match[7], $match[8], $match[10], $match[3], $match[5], $match[1]);
        if (false === $tm || -1 == $tm && version_compare(phpversion(), "5.1.0", "<")) {
            return false;
        }
        // gmmktime failed.
        // hh:mm:ss must be in 00:00:00 - 24:00:00
        if ($match[10] >= 60) {
            return false;
        }
        if ($match[8] >= 60) {
            return false;
        }
        if ($match[7] > 24 || $match[7] == 24 && ($match[8] != 0 || $match[10] != 0)) {
            return false;
        }
        // mm and dd must not overflow
        if (gmdate('Ymd', gmmktime(0, 0, 0, $match[3], $match[5], $match[1])) != $match[1] . $match[3] . $match[5]) {
            return false;
        }
        //correct a time difference to GMT
        if (isset($match[11]) && isset($match[12]) && isset($match[13]) && isset($match[14])) {
            if ($match[11] != 'Z' && $match[12] == '-') {
                $tm = $tm + ($match[13] * 3600 + $match[14] * 60);
            } else {
                if (isset($match[12]) && $match[11] != 'Z' && $match[12] == '+') {
                    $tm = $tm - ($match[13] * 3600 + $match[14] * 60);
                }
            }
        }
    } else {
        if (preg_match('/^([0-9]{4})(-W([0-5][0-9]))(-([1-7]))$/', $str, $match) == 1) {
            // Week dates format
            $y = $match[1];
            $w = $match[3];
            $d = $match[5];
            $tm = gmmktime(0, 0, 0, 1, 1, $match[1]) + (($w - 1) * 7 + $d - getDayOfWeek($y, 1, 1)) * 86400;
        } else {
            if (preg_match('/^([0-9]{4})(-?([0-3][0-9]{2}))$/', $str, $match) == 1) {
                // Ordinal dates format
                $tm = gmmktime(0, 0, 0, 1, 1, $match[1]) + ($match[3] - 1) * 86400;
            } else {
                return false;
            }
        }
    }
    return $tm;
}