Пример #1
0
function adddays($tm, $days)
{
    $time = $tm;
    if ($days > 0) {
        $time[2] += $days;
        while ($time[2] > getMonthDays($time[0], $time[1])) {
            $time[2] -= getMonthDays($time[0], $time[1]);
            $time[1]++;
            if ($time[1] == 13) {
                $time[1] = 1;
                $time[0]++;
            }
        }
    } else {
        $time[2] += $days;
        while ($time[2] < 1) {
            //	getMonthDays accepts 0 as a month ( December )!
            $time[2] += getMonthDays($time[0], $time[1] - 1);
            $time[1]--;
            if ($time[1] == 0) {
                $time[1] = 12;
                $time[0]--;
            }
        }
    }
    return $time;
}
Пример #2
0
function obtenerDiasHabiles($mes, $anio)
{
    $date = "{$anio}-{$mes}-01";
    $max = getMonthDays($mes, $anio);
    $i = 0;
    $laborables = array();
    for ($i = 0; $i < $max; $i++) {
        $fechanueva = strtotime(date("Y-m-d", strtotime($date)) . " +{$i} day");
        $valday = date('w', $fechanueva);
        if ($valday != 0 && $valday != 6) {
            $laborables[] = date("Y-m-d", $fechanueva);
        }
    }
    return $laborables;
}
Пример #3
0
<?php

error_reporting(E_ALL);
set_time_limit(0);
date_default_timezone_set('Europe/Istanbul');
require 'lib/ripper.php';
require_once __DIR__ . '/vendor/autoload.php';
$app = new Silex\Application();
$app->register(new Silex\Provider\DoctrineServiceProvider(), array('db.options' => array('driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => 'shout', 'user' => 'root', 'password' => '', 'charset' => 'utf8mb4')));
$app['debug'] = true;
$app->get('/start/{hour}', function ($hour) use($app) {
    $workdays = getMonthDays('workdays');
    $weekends = getMonthDays('weekends');
    $date = date('Y/n/d');
    if (in_array(date('d'), $workdays)) {
        $table = 'workdays';
    } else {
        $table = 'weekends';
    }
    $get_name = date('l', strtotime($date));
    //get week day
    $day_name = substr($get_name, 0, 3);
    // Trim day name to 3 chars
    $day_name = strtolower($day_name);
    // Trim day name to 3 chars
    $date = new DateTime('now');
    $date->setTime($hour, 00);
    $hour = $date->format('H:i:s') . "\n";
    $sql = "SELECT m.shout_id, m.program_id, p.name as program_name,s.name as shout_name , m.started_at, s.url,p.is_mon,p.is_tue,p.is_wed,p.is_thu,p.is_fri,p.is_sat,p.is_sun FROM {$table} as m INNER JOIN programs  as  p ON m.program_id=p.id INNER JOIN shouts as s ON m.shout_id = s.id WHERE s.status = 1 AND p.is_{$day_name} = 1 AND m.started_at = '{$hour}'";
    $data = $app['db']->fetchAll($sql);
    foreach ($data as $d) {