示例#1
0
/**
 * Prend un titre complet au format "dd/mm/yyyy - Title",
 * et le découpe en deux variables prêtes à être utilisées dans une requête.
 *
 * @return Un tableau de deux chaînes de caractères, avec la date formatée et le titre.
 */
function decoupage_full_title($full_title)
{
    $date = substr($full_title, 0, 10);
    $dateT = date_create();
    date_date_set($dateT, substr($date, 6, 4), substr($date, 3, 2), substr($date, 0, 2));
    $date = date_format($dateT, "Y-m-d");
    $title = substr($full_title, 13, strlen($full_title) - 1);
    return array($date, $title);
}
 public function index()
 {
     //@todo move this to init when init supports exceptions
     // Boilerplate special page permissions
     if ($this->wg->user->isBlocked()) {
         $this->wg->out->blockedPage();
         return false;
         // skip rendering
     }
     if (!$this->wg->user->isAllowed('specialgamingcalendar')) {
         $this->displayRestrictionError();
         return false;
     }
     if (wfReadOnly() && !wfAutomaticReadOnly()) {
         $this->wg->out->readOnlyPage();
         return false;
     }
     $this->response->addAsset('resources/wikia/libraries/jquery-ui/jquery-ui-1.8.14.custom.js');
     $this->response->addAsset('extensions/wikia/GamingCalendar/js/GamingCalendarSpecialPage.js');
     $this->response->addAsset('extensions/wikia/GamingCalendar/css/GamingCalendarSpecialPage.scss');
     $type = $this->getVal('type', null);
     $year = $this->getVal('year', null);
     $month = $this->getVal('month', null);
     $date = null;
     $entries = array();
     if (!empty($type) && !empty($year) && !empty($month)) {
         // get entries
         $date = date_create();
         date_date_set($date, $year, $month, 1);
         $entries = GamingCalendar::loadEntries(0, 5, $type, date_timestamp_get($date), false);
     }
     $typeName = GamingCalendar::getCalendarName($type);
     $this->setVal('typeName', $typeName);
     $this->setVal('type', $type);
     $this->setVal('year', $year);
     $this->setVal('month', $month);
     $this->setVal('date', $date ? date_timestamp_get($date) : '');
     $this->setVal('types', GamingCalendar::getCalendarTypes());
     $this->setVal('entries', $entries);
 }
示例#3
0
文件: 013.php 项目: badlamer/hhvm
<?php

date_default_timezone_set('UTC');
$dto = date_create("2006-12-12");
var_dump($dto);
var_dump($dto->format("Y.m.d H:i:s"));
var_dump(date_date_set());
var_dump($dto->format("Y.m.d H:i:s"));
var_dump(date_date_set($dto, 2006, 5));
var_dump($dto->format("Y.m.d H:i:s"));
var_dump(date_date_set($dto, 2006, 2, 15));
var_dump($dto->format("Y.m.d H:i:s"));
var_dump(date_date_set($dto, 2006, 24, 60));
var_dump($dto->format("Y.m.d H:i:s"));
echo "Done\n";
示例#4
0
 /**
  * Construct a date object out of it's time values If a timezone string
  * the date will be set into that zone - defaulting to the system's
  * default timezone of none is given.
  *
  * @param   int year
  * @param   int month
  * @param   int day
  * @param   int hour
  * @param   int minute
  * @param   int second
  * @param   util.TimeZone tz default NULL
  * @return  util.Date
  */
 public static function create($year, $month, $day, $hour, $minute, $second, TimeZone $tz = null)
 {
     $date = date_create();
     if ($tz) {
         date_timezone_set($date, $tz->getHandle());
     }
     if (false === @date_date_set($date, $year, $month, $day) || false === @date_time_set($date, $hour, $minute, $second)) {
         throw new IllegalArgumentException(sprintf('One or more given arguments are not valid: $year=%s, $month=%s, $day= %s, $hour=%s, $minute=%s, $second=%s', $year, $month, $day, $hour, $minute, $second));
     }
     return new self($date);
 }
示例#5
0
function ParseOzi($trackFile, &$trackData)
{
    if (!preg_match('/OziExplorer/i', $trackFile, $m)) {
        return 0;
    }
    $nbPts = 0;
    foreach (preg_split('/[\\n\\r]+/', $trackFile, null, PREG_SPLIT_NO_EMPTY) as $line) {
        if (preg_match('/^\\s+
                (?P<lat>[-\\d\\.]+)[,\\s]+
                (?P<lon>[-\\d\\.]+)[,\\s]+[01][,\\s]+
                (?P<elev>[-\\d\\.]+)[,\\s]+
                (?P<date>[\\d\\.]+).*$
                /xim', $line, $m)) {
            $trackData['lat'][$nbPts] = floatval($m['lat']);
            $trackData['lon'][$nbPts] = floatval($m['lon']);
            $trackData['elev'][$nbPts] = max(intval($m['elev'] * 0.3048), 0);
            $time = floatval($m['date']) - intval($m['date']);
            $time = $time * 24;
            $hour = intval($time);
            $time = ($time - $hour) * 60;
            $min = intval($time);
            $time = ($time - $min) * 60;
            $sec = intval($time);
            $trackData['time']['hour'][$nbPts] = $hour;
            $trackData['time']['min'][$nbPts] = $min;
            $trackData['time']['sec'][$nbPts] = $sec;
            $nbPts++;
        }
    }
    if ($nbPts > 5) {
        $date = date_create();
        date_date_set($date, 1899, 12, 30);
        date_modify($date, intval($m['date']) . ' days');
        $trackData['date']['day'] = intval(date_format($date, 'j'));
        $trackData['date']['month'] = intval(date_format($date, 'n'));
        $trackData['date']['year'] = intval(date_format($date, 'Y'));
    }
    return $nbPts;
}
    $date_debut = null;
    $date_fin = null;
    $id_eleve_array = null;
    $id_saisie_array = null;
    foreach ($traitement->getAbsenceEleveSaisies() as $saisie) {//$saisie = new AbsenceEleveSaisie();
	if ($date_debut == null || $saisie->getDebutAbs('U') < $date_debut->format('U')) {
	    $date_debut = clone $saisie->getDebutAbs(null);
	}
	if ($date_fin == null || $saisie->getFinAbs('U') > $date_fin->format('U')) {
	    $date_fin = clone $saisie->getFinAbs(null);
	}
	$id_eleve_array[] = $saisie->getEleveId();
	$id_saisie_array[] = $saisie->getId();
    }
    if ($date_debut != null) date_date_set($date_debut, $date_debut->format('Y'), $date_debut->format('m'), $date_debut->format('d') - 1);
    if ($date_fin != null) date_date_set($date_fin, $date_fin->format('Y'), $date_fin->format('m'), $date_fin->format('d') + 1);
    $query->filterByPlageTemps($date_debut, $date_fin)->filterByEleveId($id_eleve_array)->filterById($id_saisie_array, Criteria::NOT_IN);
}


$order = getFiltreRechercheParam('order');
if ($order == "asc_id") {
    $query->orderBy('Id', Criteria::ASC);
} else if ($order == "des_id") {
    $query->orderBy('Id', Criteria::DESC);
} else if ($order == "asc_utilisateur") {
    $query->useUtilisateurProfessionnelQuery()->orderBy('Nom', Criteria::ASC)->endUse();
} else if ($order == "des_utilisateur") {
    $query->useUtilisateurProfessionnelQuery()->orderBy('Nom', Criteria::DESC)->endUse();
} else if ($order == "asc_eleve") {
    $query->useEleveQuery()->orderBy('Nom', Criteria::ASC)->orderBy('Prenom', Criteria::ASC)->endUse();
示例#7
0
function amr_get_events_in_weeks_format($events, $weeks, $start)
{
    // should be using dummmyYMD?
    global $amr_globaltz;
    $wkst = ical_get_weekstart();
    // get the wp start of week
    if (isset($_GET['debugwks'])) {
        echo '<br />Separate ' . count($events) . ' events into weeks for ' . $weeks . ' weeks using wkst: ' . $wkst;
    }
    $weeksofevents = array();
    // prepare the months array so we show a calendar even if no events
    $dummydate = new Datetime();
    //if cloning dont need tz
    $dummydate = clone $start;
    $dummydate = amr_get_human_start_of_week($dummydate, $wkst);
    for ($i = 0; $i < $weeks; $i++) {
        $weekbeginning = $dummydate->format('Ymj');
        //numerical so do not need amr_date_format
        if (empty($firstweekbeginning)) {
            $firstweekbeginning = $weekbeginning;
        }
        if (isset($_GET['debugwks'])) {
            echo '<br />weekbeginning' . $weekbeginning;
        }
        $weeksofevents[$weekbeginning] = array();
        date_modify($dummydate, '+7 days');
    }
    // assign events to the box of their year and month
    if (!empty($events)) {
        foreach ($events as $event) {
            if (!empty($event['dummyYMD'])) {
                // ahh need the dummy date, not the Event Date
                date_date_set($dummydate, substr($event['dummyYMD'], 0, 4), substr($event['dummyYMD'], 4, 2), substr($event['dummyYMD'], 6, 2));
                if (isset($_GET['debugwks'])) {
                    echo '<br />date:' . $event['dummyYMD'];
                }
                $dummydate = amr_get_human_start_of_week($dummydate, $wkst);
                $weekbeginning = $dummydate->format('Ymj');
                if (isset($_GET['debugwks'])) {
                    echo '<br />start of week:' . $weekbeginning;
                }
                if (isset($weeksofevents[$weekbeginning])) {
                    $weeksofevents[$weekbeginning][] = $event;
                } else {
                    // the week beginning is not in our current set - might be a multi day that started the previous week or even earlier
                    if (isset($_GET['debugwks'])) {
                        echo '<br />No week begin of ' . $weekbeginning . ' for ? ' . $dummydate->format('c') . ' ' . $event['SUMMARY'];
                        //$weeksofevents[$weekbeginning][] = $event;  // assign our multi day to first week
                        //var_dump($event);
                    }
                }
            } else {
                if (isset($_GET['debugwks'])) {
                    echo '<br />event with no dummy date';
                    var_dump($event);
                }
            }
        }
    }
    if (isset($_GET['debugwks'])) {
        echo '<br />Have dates for:' . count($weeksofevents) . ' weeks';
        foreach ($weeksofevents as $i => $bunchevents) {
            echo '<br />' . $i . ' ' . count($bunchevents);
            foreach ($bunchevents as $i => $e) {
                echo '<br />&nbsp;&nbsp;' . $e['EventDate']->format('Ymd');
                //numerical so do not need amr_date_format
            }
        }
    }
    return $weeksofevents;
}
示例#8
0
        $dt_date_absence_eleve = new DateTime(str_replace("/", ".", $date_absence_eleve));
    } catch (Exception $x) {
        try {
            $dt_date_absence_eleve = new DateTime($date_absence_eleve);
        } catch (Exception $x) {
            $dt_date_absence_eleve = new DateTime('now');
        }
    }
} else {
    $dt_date_absence_eleve = new DateTime('now');
}
if ($nav_date == "precedent") {
    date_date_set($dt_date_absence_eleve, $dt_date_absence_eleve->format('Y'), $dt_date_absence_eleve->format('m'), $dt_date_absence_eleve->format('d') - 1);
}
if ($nav_date == "suivant") {
    date_date_set($dt_date_absence_eleve, $dt_date_absence_eleve->format('Y'), $dt_date_absence_eleve->format('m'), $dt_date_absence_eleve->format('d') + 1);
}

//==============================================
$style_specifique[] = "mod_abs2/lib/abs_style";
$javascript_specifique[] = "mod_abs2/lib/include";
$titre_page = "Absences du jour";
$utilisation_jsdivdrag = "non";
$_SESSION['cacher_header'] = "y";
$dojo = true;

$javascript_specifique[] = "lib/tablekit";
$utilisation_tablekit="ok";
require_once("../lib/header.inc.php");
//**************** FIN EN-TETE *****************
示例#9
0
 /**
  * Get results for relative BYDAY values.
  *
  * BYDAYs with parameters like -1SU (last Sun) or
  * 2TH (second Thur) need to be processed one month or
  * year at a time.
  */
 protected function get_relative_bydays($relative_days)
 {
     $finished = FALSE;
     $this->current_day = clone $this->start_date;
     while (!$finished) {
         foreach ($relative_days as $day) {
             // Find the BYDAY date in the current period.
             switch ($this->rrule['FREQ']) {
                 case 'MONTHLY':
                     if ($this->set_month_day($day['day'], $day['direction_count'], $day['direction'])) {
                         $this->add_current_day();
                     }
                     break;
                 case 'YEARLY':
                     if ($this->set_year_day($day['day'], $day['direction_count'], $day['direction'])) {
                         $this->add_current_day();
                     }
                     break;
             }
         }
         $finished = $this->is_finished();
         // Reset to beginning of period before jumping to next period.
         // Needed especially when working with values like 'last
         // Saturday' to be sure we don't skip months like February.
         $year = $this->current_day->format('Y');
         $month = $this->current_day->format('n');
         switch ($this->rrule['FREQ']) {
             case 'MONTHLY':
                 date_date_set($this->current_day, $year, $month, 1);
                 break;
             case 'YEARLY':
                 date_date_set($this->current_day, $year, 1, 1);
                 break;
         }
         // Jump to the next period.
         $this->current_day->add($this->jump);
     }
 }
/**
 * Helper function to round minutes and seconds to requested value.
 */
function date_increment_round(&$date, $increment)
{
    // Round minutes and seconds, if necessary.
    if (is_object($date) && $increment > 1) {
        $day = intval(date_format($date, 'j'));
        $hour = intval(date_format($date, 'H'));
        $second = intval(round(intval(date_format($date, 's')) / $increment) * $increment);
        $minute = intval(date_format($date, 'i'));
        if ($second == 60) {
            $minute += 1;
            $second = 0;
        }
        $minute = intval(round($minute / $increment) * $increment);
        if ($minute == 60) {
            $hour += 1;
            $minute = 0;
        }
        date_time_set($date, $hour, $minute, $second);
        if ($hour == 24) {
            $day += 1;
            $hour = 0;
            $year = date_format($date, 'Y');
            $month = date_format($date, 'n');
            date_date_set($date, $year, $month, $day);
        }
    }
    return $date;
}
示例#11
0
 /**
  * Rounds minutes and seconds to nearest requested value.
  *
  * @param $date
  *
  * @param $increment
  *
  * @return
  */
 protected static function incrementRound(&$date, $increment)
 {
     // Round minutes and seconds, if necessary.
     if ($date instanceof DrupalDateTime && $increment > 1) {
         $day = intval(date_format($date, 'j'));
         $hour = intval(date_format($date, 'H'));
         $second = intval(round(intval(date_format($date, 's')) / $increment) * $increment);
         $minute = intval(date_format($date, 'i'));
         if ($second == 60) {
             $minute += 1;
             $second = 0;
         }
         $minute = intval(round($minute / $increment) * $increment);
         if ($minute == 60) {
             $hour += 1;
             $minute = 0;
         }
         date_time_set($date, $hour, $minute, $second);
         if ($hour == 24) {
             $day += 1;
             $year = date_format($date, 'Y');
             $month = date_format($date, 'n');
             date_date_set($date, $year, $month, $day);
         }
     }
     return $date;
 }
 function loadPlansFromCsvFiles($dir)
 {
     var_dump('loading daily and mensual plans for the services...');
     var_dump($dir);
     $em = $this->manager;
     $entries = scandir($dir);
     $i = 0;
     foreach ($entries as $e) {
         $i++;
         var_dump('parsing files in folder ' . $i);
         $subdir = $dir . '\\' . $e;
         if (is_dir($subdir) && $e != '.' && $e != '..') {
             foreach (scandir($subdir) as $file) {
                 $csvFile = $subdir . '\\' . $file;
                 if (is_file($csvFile) && pathinfo($csvFile)['extension'] == "csv") {
                     $fileHandle = fopen($csvFile, "r");
                     $row = 0;
                     $date = "";
                     while (($data = fgetcsv($fileHandle, 1000, ",")) != false) {
                         if ($row == 3) {
                             // extract day here
                             $date = date_parse($data[5]);
                             //var_dump ("Loading plan for day: ".$date['day'].'/'.$date['month']);
                         }
                         if ($row >= 6) {
                             if (is_numeric($data[0])) {
                                 $code = $data[1];
                                 $service = $em->getRepository('sisconeeAppBundle:Servicio')->findOneByCodClienteEE($code);
                                 if ($service == null) {
                                     continue;
                                 }
                                 $lecturaDiariaActual = $em->getRepository('sisconeeAppBundle:LecturaDiariaServicio')->getLectura($date['day'], $date['month'], $date['year'], $service->getId());
                                 if ($lecturaDiariaActual == null) {
                                     $planDia = $data[6];
                                     $consumoDia = $data[7];
                                     $lecturaDiariaActual = new LecturaDiariaServicio();
                                     $lecturaDiariaActual->setPlan($planDia);
                                     $lecturaDiariaActual->setConsumo($consumoDia);
                                     $lecturaDiariaActual->setIdServicio($service);
                                     $dateDT = date_create();
                                     date_date_set($dateDT, $date['year'], $date['month'], $date['day']);
                                     $lecturaDiariaActual->setFecha($dateDT);
                                     $em->persist($lecturaDiariaActual);
                                     //plandiario
                                     $this->manager->flush();
                                     //var_dump ('saving service '.$service->getId());
                                 } else {
                                     //var_dump("Existe " . date_format($lecturaDiariaActual->getFecha(), "m:d:y"));
                                 }
                                 $lecturaMensual = $em->getRepository('sisconeeAppBundle:PlanAnualEntidad')->getPlanOfAServiceInAMonthYear($service, $date['month'], $date['year']);
                                 if ($lecturaMensual == null) {
                                     $planMensualValue = $data[5];
                                     $planMensual = new PlanmensualServicio();
                                     $planMensual->setPlan($planMensualValue);
                                     $planMensual->setServicio($service);
                                     $planMensual->setMes($date['month']);
                                     $planMensual->setAnno($date['year']);
                                     $em->persist($planMensual);
                                     //planmensual
                                     $this->manager->flush();
                                 }
                             }
                         }
                         $row++;
                     }
                     $this->manager->flush();
                 }
             }
         }
     }
 }
示例#13
0
 public static function getRangeFromDateString($string)
 {
     $formats = ['Y/m/d', 'Y/m', 'Y'];
     $deltas = ['+1 day', '+1 month', '+1 year'];
     $to = null;
     while ($format = array_pop($formats)) {
         $delta = array_pop($deltas);
         $from = date_create_from_format($format, $string);
         if ($from !== false) {
             // Rewind to start of range
             $month = 1;
             $day = 1;
             switch ($format) {
                 case 'Y/m/d':
                     $day = (int) $from->format('d');
                 case 'Y/m':
                     $month = (int) $from->format('m');
                 case 'Y':
                     $year = (int) $from->format('Y');
             }
             date_date_set($from, $year, $month, $day);
             date_time_set($from, 0, 0, 0);
             // Create end of the the range
             $to = date_modify(clone $from, $delta);
             break;
         }
     }
     if (!$from || !$to) {
         throw new \InvalidArgumentException(sprintf('Invalid date "%s".', $string));
     }
     return ['from' => $from->format(Mapping::DATE_FORMAT_CAPTION_PHP), 'to' => $to->format(Mapping::DATE_FORMAT_CAPTION_PHP)];
 }
示例#14
0
 /** https://core.trac.wordpress.org/ticket/25768
  *
  * Modified from the original patch to use the currently set
  * timezone from PHP, like PHP's date(), and to make the code
  * more readable.
  *
  * @param      $j
  * @param      $req_format
  * @param bool $i
  * @param bool $gmt
  * @return bool|string
  */
 function fix_date_i18n($j, $req_format, $i = false, $gmt = false)
 {
     /* @var $wp_locale WP_Locale */
     global $wp_locale;
     $timestamp = $i;
     // get current timestamp if $i is false
     if (false === $timestamp) {
         if ($gmt) {
             $timestamp = time();
         } else {
             $timestamp = current_time('timestamp');
         }
     }
     // get components of the date (timestamp) as array
     $date_components = getdate($timestamp);
     // numeric representation of a month, with leading zeros
     $date_month = $wp_locale->get_month($date_components['mon']);
     $date_month_abbrev = $wp_locale->get_month_abbrev($date_month);
     // numeric representation of the day of the week
     $date_weekday = $wp_locale->get_weekday($date_components['wday']);
     $date_weekday_abbrev = $wp_locale->get_weekday_abbrev($date_weekday);
     // get if hour is Ante meridiem or Post meridiem
     $meridiem = $date_components['hours'] >= 12 ? 'pm' : 'am';
     // lowercase Ante meridiem and Post meridiem hours
     $date_meridiem = $wp_locale->get_meridiem($meridiem);
     // uppercase Ante meridiem and Post meridiem
     $date_meridiem_capital = $wp_locale->get_meridiem(strtoupper($meridiem));
     // escape literals
     $date_weekday_abbrev = backslashit($date_weekday_abbrev);
     $date_month = backslashit($date_month);
     $date_weekday = backslashit($date_weekday);
     $date_month_abbrev = backslashit($date_month_abbrev);
     $date_meridiem = backslashit($date_meridiem);
     $date_meridiem_capital = backslashit($date_meridiem_capital);
     // the translated format string
     $translated_date_format_string = '';
     // the 2 arrays map a format literal to its translation (e. g. 'F' to the escaped month translation)
     $translate_formats = array('D', 'F', 'l', 'M', 'a', 'A', 'c', 'r');
     $translations = array($date_weekday_abbrev, $date_month, $date_weekday, $date_month_abbrev, $date_meridiem, $date_meridiem_capital, 'Y-m-d\\TH:i:sP', sprintf('%s, d %s Y H:i:s O', $date_weekday_abbrev, $date_month_abbrev));
     // find each format literal that needs translation and replace it by its translation
     // respects the escaping
     // iterate $req_format from ending to beginning
     for ($i = strlen($req_format) - 1; $i > -1; $i--) {
         // test if current char is format literal that needs translation
         $translate_formats_index = array_search($req_format[$i], $translate_formats);
         if ($translate_formats_index !== false) {
             // counts the slashes (the escape char) in front of the current char
             $slashes_counter = 0;
             // count all slashes left-hand side of the current char
             for ($j = $i - 1; $j > -1; $j--) {
                 if ($req_format[$j] == '\\') {
                     $slashes_counter++;
                 } else {
                     break;
                 }
             }
             // number of slashes is even
             if ($slashes_counter % 2 == 0) {
                 // current char is not escaped, therefore it is a format literal
                 $translated_date_format_string = $translations[$translate_formats_index] . $translated_date_format_string;
             } else {
                 // current char is escaped, therefore it is not a format literal, just add it unchanged
                 $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
             }
         } else {
             // current char is no a format literal, just add it unchanged
             $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
         }
     }
     $req_format = $translated_date_format_string;
     if ($gmt) {
         // get GMT date string
         $date_formatted = gmdate($req_format, $timestamp);
     } else {
         // get Wordpress time zone
         // $timezone_string = get_option('timezone_string');
         // Haha, just kidding. Let's get the currently set timezone, as God and Rasmus intended
         $timezone_string = date_default_timezone_get();
         if ($timezone_string) {
             // create time zone object
             $timezone_object = timezone_open($timezone_string);
             // create date object from time zone object
             $local_date_object = date_create(null, $timezone_object);
             // set time and date of $local_date_object to $timestamp
             $date_components = isset($date_components) ? $date_components : getdate($timestamp);
             date_date_set($local_date_object, $date_components['year'], $date_components['mon'], $date_components['mday']);
             date_time_set($local_date_object, $date_components['hours'], $date_components['minutes'], $date_components['seconds']);
             // format date according to the Wordpress time zone
             $date_formatted = date_format($local_date_object, $req_format);
         } else {
             // fall back if no Wordpress time zone set
             $date_formatted = date($req_format, $i);
         }
     }
     return $date_formatted;
 }
示例#15
0
    public function import($statOnly = '')
    {
        $dateFilter = '`data_ora_rich` > CURDATE() - INTERVAL 2 MONTH';
        if ($statOnly != '') {
            $config = clone $this->db->config;
            $configDb = $this->db->config->database->toArray();
            $configDb['options']['buffer_results'] = false;
            $this->db = new \Zend\Db\Adapter\Adapter($configDb);
            $this->db->config = $config;
            $dateFilter = 'TRUE';
            if ($this->db->config->storeExpiryStatFile->Catasto != '') {
                $statHandler = fopen($this->db->config->storeExpiryStatFile->Catasto, 'w');
            }
        }
        $archiviRichieste = array(array('dir' => 'risposteBaseDirMass', 'sql' => '
SELECT aps_prod_backup.eps_richiesta_mass.id_richiesta,
aps_prod_backup.eps_richiesta_mass.id_mov_contab,
aps_prod_backup.eps_richiesta_mass.id_richiesta_cache,
aps_prod_backup.eps_richiesta_mass.stringa_richiesta,
aps_prod_backup.eps_richiesta_mass.data_ora_rich,
aps_prod_backup.eps_richiesta_mass.data_ora_evas,
aps_prod.eps_operazione.cod_operazione as cod_operazione ,
aps_prod_backup.eps_mov_contab_mass.cod_causale as cod_causale ,
aps_prod_backup.eps_mov_contab_mass.importo as importo ,
aps_prod_backup.eps_mov_contab_mass.id_mov_contab_gen as id_mov_contab_gen ,
aps_prod.eps_prodotto.cod_prodotto as cod_prodotto ,
aps_prod.eps_cliente.cod_cliente as cod_cliente ,
aps_prod.eps_istanza.cod_istanza as cod_istanza
FROM aps_prod_backup.eps_richiesta_mass
LEFT JOIN aps_prod.eps_operazione ON aps_prod.eps_operazione.id_operazione=aps_prod_backup.eps_richiesta_mass.id_operazione
LEFT JOIN aps_prod_backup.eps_mov_contab_mass ON aps_prod_backup.eps_mov_contab_mass.id_mov_contab=aps_prod_backup.eps_richiesta_mass.id_mov_contab
LEFT JOIN aps_prod.eps_prodotto ON aps_prod.eps_prodotto.id_prodotto =aps_prod_backup.eps_mov_contab_mass.id_prodotto
LEFT JOIN aps_prod.eps_cliente ON aps_prod.eps_cliente.id_cliente=aps_prod_backup.eps_mov_contab_mass.id_cliente
LEFT JOIN aps_prod.eps_istanza ON aps_prod.eps_istanza.id_istanza=aps_prod.eps_cliente.id_istanza
WHERE
' . $dateFilter . ' AND (
   aps_prod.eps_operazione.cod_operazione = "omicf" OR 
   aps_prod.eps_operazione.cod_operazione = "omi" OR 
   aps_prod.eps_operazione.cod_operazione = "sintecf" OR
   aps_prod.eps_operazione.cod_operazione = "sintesi" OR
   aps_prod.eps_operazione.cod_operazione = "sintesi3" OR
   aps_prod.eps_operazione.cod_operazione = "visucf" OR
   aps_prod.eps_operazione.cod_operazione = "visura" OR
   aps_prod.eps_operazione.cod_operazione = "visura3"
)
                    '), array('dir' => 'risposteBaseDir', 'sql' => '
SELECT aps_prod_backup.eps_richiesta.id_richiesta,
aps_prod_backup.eps_richiesta.id_mov_contab,
aps_prod_backup.eps_richiesta.id_richiesta_cache,
aps_prod_backup.eps_richiesta.stringa_richiesta,
aps_prod_backup.eps_richiesta.data_ora_rich,
aps_prod_backup.eps_richiesta.data_ora_evas,
aps_prod.eps_operazione.cod_operazione as cod_operazione ,
aps_prod_backup.eps_mov_contab.cod_causale as cod_causale ,
aps_prod_backup.eps_mov_contab.importo as importo ,
aps_prod_backup.eps_mov_contab.id_mov_contab_gen as id_mov_contab_gen ,
aps_prod.eps_prodotto.cod_prodotto as cod_prodotto ,
aps_prod.eps_cliente.cod_cliente as cod_cliente ,
aps_prod.eps_istanza.cod_istanza as cod_istanza

FROM aps_prod_backup.eps_richiesta
LEFT JOIN aps_prod.eps_operazione ON aps_prod.eps_operazione.id_operazione=aps_prod_backup.eps_richiesta.id_operazione
LEFT JOIN aps_prod_backup.eps_mov_contab ON aps_prod_backup.eps_mov_contab.id_mov_contab=aps_prod_backup.eps_richiesta.id_mov_contab
LEFT JOIN aps_prod.eps_prodotto ON aps_prod.eps_prodotto.id_prodotto =aps_prod_backup.eps_mov_contab.id_prodotto
LEFT JOIN aps_prod.eps_cliente ON aps_prod.eps_cliente.id_cliente=aps_prod_backup.eps_mov_contab.id_cliente
LEFT JOIN aps_prod.eps_istanza ON aps_prod.eps_istanza.id_istanza=aps_prod.eps_cliente.id_istanza
WHERE  
' . $dateFilter . ' AND (
   aps_prod.eps_operazione.cod_operazione = "sintecf" OR aps_prod.eps_operazione.cod_operazione = "omicf" OR 
   aps_prod.eps_operazione.cod_operazione = "sintesi" OR aps_prod.eps_operazione.cod_operazione = "omi" OR 
   aps_prod.eps_operazione.cod_operazione = "sintecf" OR aps_prod.eps_operazione.cod_operazione = "sintecf" OR 
   aps_prod.eps_operazione.cod_operazione = "sintesi" OR aps_prod.eps_operazione.cod_operazione = "sintesi" OR 
   aps_prod.eps_operazione.cod_operazione = "sintesi3" OR aps_prod.eps_operazione.cod_operazione = "sintesi3" OR
   aps_prod.eps_operazione.cod_operazione = "sintecf" OR aps_prod.eps_operazione.cod_operazione = "visucf" OR
   aps_prod.eps_operazione.cod_operazione = "sintesi" OR aps_prod.eps_operazione.cod_operazione = "visura" OR 
   aps_prod.eps_operazione.cod_operazione = "sintesi3" OR aps_prod.eps_operazione.cod_operazione = "visura3" 
)
                    '));
        foreach ($archiviRichieste as $archivioRichieste) {
            $richieste = $this->db->query($archivioRichieste['sql'], \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
            $count = 0;
            $rCompany = new \crm\Company($this->db);
            $company = new \crm\Company($this->db);
            $person = new \crm\Person($this->db);
            $rPerson = new \crm\Person($this->db);
            while (is_object($richiesta = $richieste->current())) {
                echo "\r" . $count++ . '/' . ($richieste->count() - 1) . str_repeat(' ', 5);
                $dati = array();
                $sId = str_pad($richiesta->id_richiesta, 9, '0', STR_PAD_LEFT);
                $dM = 'M' . substr($sId, 0, 3);
                $dK = 'K' . substr($sId, 3, 3);
                $nomeFile = $this->db->config->{$archivioRichieste['dir']} . "/{$dM}/{$dK}/F{$sId}.xml";
                if (!is_file($nomeFile)) {
                    $richieste->next();
                    continue;
                }
                $dati['id_mov_contab'] = $richiesta->id_mov_contab;
                $dati['massiva'] = $archivioRichieste['dir'] == 'risposteBaseDir' ? 0 : 1;
                $dati['id_richiesta'] = $richiesta->id_richiesta;
                $dati['test_nome_file'] = "\"" . str_replace('"', '\\"', basename($nomeFile)) . "\"";
                $dati['errore'] = '';
                $dati['data_ora_rich'] = $richiesta->data_ora_rich;
                $dati['data_ora_evas'] = $richiesta->data_ora_evas;
                $dati['cod_operazione'] = $richiesta->cod_operazione;
                $dati['cod_prodotto'] = $richiesta->cod_prodotto;
                $dati['cod_cliente'] = $richiesta->cod_cliente;
                $dati['cod_istanza'] = $richiesta->cod_istanza;
                $dati['importo'] = $richiesta->importo;
                $dati['differita'] = 1;
                $dati['stornata'] = 0;
                if ($richiesta->importo == 0 && $richiesta->id_richiesta_cache == 0) {
                    $dati['stornata'] = 1;
                }
                set_error_handler(create_function('', ''));
                $filecontent = file_get_contents($nomeFile);
                $filecontent = iconv('ISO-8859-1', 'UTF-8//IGNORE', $filecontent);
                libxml_use_internal_errors(true);
                try {
                    $sXML = new \SimpleXMLElement($filecontent);
                } catch (Exception $e) {
                    var_dump(libxml_get_errors());
                    var_dump(file_get_contents($nomeFile));
                }
                $dati['dataADTI'] = (string) $sXML->xpath('/ADTIReport/time/data/anno')[0];
                $dati['dataADTI'] .= '-';
                $dati['dataADTI'] .= str_pad((string) $sXML->xpath('/ADTIReport/time/data/mese')[0], 2, '0', STR_PAD_LEFT);
                $dati['dataADTI'] .= '-';
                $dati['dataADTI'] .= str_pad((string) $sXML->xpath('/ADTIReport/time/data/giorno')[0], 2, '0', STR_PAD_LEFT);
                $dati['dataADTI'] .= ' ';
                $dati['dataADTI'] .= str_pad((string) $sXML->xpath('/ADTIReport/time/ora/ore')[0], 2, '0', STR_PAD_LEFT);
                $dati['dataADTI'] .= ':';
                $dati['dataADTI'] .= str_pad((string) $sXML->xpath('/ADTIReport/time/ora/minuti')[0], 2, '0', STR_PAD_LEFT);
                $dati['dataADTI'] .= ':';
                $dati['dataADTI'] .= str_pad((string) $sXML->xpath('/ADTIReport/time/ora/secondi')[0], 2, '0', STR_PAD_LEFT);
                if (strlen($dati['dataADTI']) < 6) {
                    $dati['dataADTI'] = '';
                }
                restore_error_handler();
                if ($statOnly != '') {
                    array_walk($dati, create_function('&$item', '$item=str_replace("\\"","",$item);'));
                    if (isset($statHandler)) {
                        if (ftell($statHandler) == 0) {
                            fputcsv($statHandler, array_keys($dati));
                        }
                        fputcsv($statHandler, $dati);
                        fflush($statHandler);
                    }
                }
                $soggetto = $sXML->xpath('/ADTIReport/visuraCatastale/elencoInfoCatasto/infoCatasto/soggetto');
                if (sizeof($soggetto) < 1 || $statOnly != '') {
                    $richieste->next();
                    continue;
                }
                $soggetto = $soggetto[0];
                $dati['codFisc'] = (string) $soggetto->codiceFiscale;
                if (strlen($dati['codFisc']) == 16) {
                    preg_match("/^(\\w+)/", $soggetto->denominazione, $matches);
                    $cognome = $matches[1];
                    $nome = trim(str_replace($cognome, '', $soggetto->denominazione));
                    $dati['nome'] = $nome;
                    $dati['cognome'] = $cognome;
                    $person->setData(array());
                    $person->loadFromId($dati['codFisc']);
                    $cDati = $person->getData();
                    if (is_array($cDati) && count($cDati) > 0) {
                        $person->setData(array_merge($cDati, array_filter($dati)));
                        $person->update();
                    } else {
                        $person->setData($dati);
                        $person->insert();
                    }
                } else {
                    if ($dati['codFisc'] != '') {
                        $dati['partIVA'] = $dati['codFisc'];
                        $dati['ragSoc'] = (string) $soggetto->denominazione;
                        $company->setData(array());
                        $company->loadFromId($dati['codFisc']);
                        $cDati = $company->getData();
                        if (is_array($cDati) && count($cDati) > 0) {
                            $company->setData(array_merge($cDati, array_filter($dati)));
                            $company->update();
                        } else {
                            $company->setData($dati);
                            $company->insert();
                        }
                    }
                }
                $correlati = $sXML->xpath('/ADTIReport/visuraCatastale/elencoInfoCatasto/infoCatasto/elencoUnitaImmobiliari/unitaImmobiliari/elencoIntestatari/intestatari/soggetto');
                if (!is_array($correlati)) {
                    $richieste->next();
                    continue;
                }
                foreach ($correlati as $correlato) {
                    $rDati = array();
                    $rDati['codFisc'] = (string) $correlato->codiceFiscale;
                    if (strlen($rDati['codFisc']) == 16) {
                        $rDati['nome'] = (string) $correlato->nominativo->nome;
                        $rDati['cognome'] = (string) $correlato->nominativo->cognome;
                        $rDati['dataNas'] = '';
                        if (is_object($correlato->datiNascita->data) && !is_null($correlato->datiNascita->data->anno)) {
                            $dateObject = date_date_set(new \DateTime(), (string) $correlato->datiNascita->data->anno, (string) $correlato->datiNascita->data->mese, (string) $correlato->datiNascita->data->giorno);
                            if (is_object($dateObject)) {
                                $rDati['dataNas'] = (string) date_format($dateObject, 'Y-m-d');
                            }
                        }
                        $rDati['luogoNas'] = '';
                        if (is_object($correlato->datiNascita->comune) && !is_null($correlato->datiNascita->comune->descrComune)) {
                            $rDati['luogoNas'] = trim(preg_replace('/\\(.*\\)/', '', (string) $correlato->datiNascita->comune->descrComune));
                        }
                        $rPerson->setData(array());
                        $rPerson->loadFromId($rDati['codFisc']);
                        $cDati = $rPerson->getData();
                        if (is_array($cDati) && count($cDati) > 0) {
                            $rPerson->setData(array_merge($cDati, array_filter($rDati)));
                            $rPerson->update();
                        } else {
                            $rPerson->setData($rDati);
                            $rPerson->insert();
                        }
                        if ($dati['codFisc'] == $rDati['codFisc']) {
                            continue;
                        }
                        if (strlen($dati['codFisc']) == 16) {
                            $person->addRelatedPerson($rPerson);
                        } else {
                            if ($dati['codFisc'] != '') {
                                $company->addRelatedExponent($rPerson);
                            }
                        }
                    } else {
                        if ($rDati['codFisc'] != '') {
                            $rDati['partIVA'] = $rDati['codFisc'];
                            $rDati['ragSoc'] = (string) $correlato->denominazione;
                            $rCompany->setData(array());
                            $rCompany->loadFromId($rDati['partIVA']);
                            $cDati = $rCompany->getData();
                            if (is_array($cDati) && count($cDati) > 0) {
                                $rCompany->setData(array_merge($cDati, array_filter($rDati)));
                                $rCompany->update();
                            } else {
                                $rCompany->setData($rDati);
                                $rCompany->insert();
                            }
                            if ($dati['codFisc'] == $rDati['codFisc']) {
                                continue;
                            }
                            if (strlen($dati['codFisc']) == 16) {
                                $rCompany->addRelatedExponent($person);
                            } else {
                                if ($dati['codFisc'] != '') {
                                    $rCompany->addRelatedCompany($company);
                                }
                            }
                        }
                    }
                }
                $richieste->next();
            }
        }
        if (isset($statHandler)) {
            fclose($statHandler);
        }
        echo PHP_EOL;
    }
示例#16
0
    $AllNP = $AllNP + $NPT[$i];
    echo "</th></tr>";
}
echo "<tr><th>ยอดรวม</th><th  style='text-align: right;'>";
echo "<span class=currency>" . $AllVS . "</span>";
echo "</th><th style='text-align: right;' >";
echo "<span class=currency>" . $AllPt . "</span>";
echo "</th><th style='text-align: right;'>";
echo "<span class=currency>" . $AllNP . "</span>";
echo "</th></tr>";
$lyear = $sy - 1;
$thisdate = date_create();
date_date_set($thisdate, $lyear, 10, 1);
$strdate = date_format($thisdate, 'Y-m-d');
$thisdate = date_create();
date_date_set($thisdate, $sy, 9, 30);
$stpdate = date_format($thisdate, 'Y-m-d');
echo "<tr><th> ยอดรวม ตั้งแต่ 1 ตุลาคม " . ($bsy - 1) . " - 30 กันยายน " . $bsy . "</th><th  style='text-align: right;'>";
$dtype = mysqli_query($link, "SELECT * FROM sell_account WHERE  vsdate>='{$strdate}' AND vsdate<='{$stpdate}' ");
while ($row = mysqli_fetch_array($dtype)) {
    $allvs = mysqli_num_rows($dtype);
    //all visit
}
$dtype = mysqli_query($link, "SELECT COUNT(DISTINCT ctmid) AS NumberOfCustomers FROM sell_account WHERE  vsdate>='{$strdate}' AND vsdate<='{$stpdate}' ");
while ($row = mysqli_fetch_array($dtype)) {
    $AllPt = $row['NumberOfCustomers'];
}
echo "<span class=currency>" . $allvs . "</span>";
echo "</th><th style='text-align: right;' >";
echo "<span class=currency>" . $AllPt . "</span>";
echo "</th><th style='text-align: right;'>";
示例#17
0
 /**
  * Adds a positive or negative amount of days
  *
  * @param   util.Date date 
  * @param   int count default 1
  * @return  util.Date
  */
 public static function addDays(Date $date, $count = 1)
 {
     $hdl = $date->getHandle();
     date_date_set($hdl, $date->getYear(), $date->getMonth(), $date->getDay() + $count);
     return new Date($hdl);
 }
示例#18
0
 /**
  * Identifies the number of ISO weeks in a year for a date.
  *
  * December 28 is always in the last ISO week of the year.
  *
  * @param mixed $date
  *   (optional) The current date object, or a date string. Defaults to NULL.
  *
  * @return integer
  *   The number of ISO weeks in a year.
  */
 public static function isoWeeksInYear($date = NULL)
 {
     if (empty($date)) {
         $date = new DateTime();
     } elseif (!is_object($date)) {
         $date = new DateTime($date);
     }
     if (is_object($date)) {
         date_date_set($date, $date->format('Y'), 12, 28);
         return $date->format('W');
     }
     return NULL;
 }
示例#19
0
<?php

/* Prototype  : DateTime date_date_set  ( DateTime $object  , int $year  , int $month  , int $day  )
 * Description: Resets the current date of the DateTime object to a different date. 
 * Source code: ext/date/php_date.c
 * Alias to functions: DateTime::setDate
 */
date_default_timezone_set("Europe/London");
echo "*** Testing date_date_set() : error conditions ***\n";
echo "\n-- Testing date_date_set() function with zero arguments --\n";
var_dump(date_date_set());
echo "\n-- Testing date_date_set() function with less than expected no. of arguments --\n";
$datetime = date_create("2009-01-30 19:34:10");
$year = 2009;
$month = 1;
$day = 30;
var_dump(date_date_set($datetime));
var_dump(date_date_set($datetime, $year));
var_dump(date_date_set($datetime, $year, $month));
echo "\n-- Testing date_date_set() function with more than expected no. of arguments --\n";
$extra_arg = 10;
var_dump(date_date_set($datetime, $year, $month, $day, $extra_arg));
?>
===DONE===
示例#20
0
<?php

/* Prototype  : DateTime date_date_set  ( DateTime $object  , int $year  , int $month  , int $day  )
 * Description: Resets the current date of the DateTime object to a different date. 
 * Source code: ext/date/php_date.c
 * Alias to functions: DateTime::setDate
 */
//Set the default time zone
date_default_timezone_set("Europe/London");
echo "*** Testing date_date_set() : basic functionality ***\n";
$datetime = date_create("2009-01-30 19:34:10");
echo date_format($datetime, DATE_RFC2822) . "\n";
date_date_set($datetime, 2008, 02, 01);
echo date_format($datetime, DATE_RFC2822) . "\n";
?>
===DONE===
示例#21
0
function ParseOzi($trackFile, &$trackData)
{
    // Regexp fields
    define('OZI_lat', 1);
    define('OZI_lon', 2);
    define('OZI_elev', 3);
    define('OZI_date', 4);
    if (!preg_match('/OziExplorer/i', $trackFile, $m)) {
        return 0;
    }
    preg_match_all('/^\\s+([-\\d\\.]+)[,\\s]+([-\\d\\.]+)[,\\s]+[01][,\\s]+([-\\d\\.]+)[,\\s]+([\\d\\.]+).*$/im', $trackFile, $m);
    $nbPts = $trackData['nbPt'] = count($m[0]);
    if ($nbPts > 5) {
        // Extract latitude, longitude, altitudes and time in second
        for ($i = 0; $i < $nbPts; $i++) {
            $trackData['lat'][$i] = floatval($m[OZI_lat][$i]);
            $trackData['lon'][$i] = floatval($m[OZI_lon][$i]);
            $trackData['elev'][$i] = max(intval($m[OZI_elev][$i] * 0.3048), 0);
            $time = floatval($m[OZI_date][$i]) - intval($m[OZI_date][$i]);
            $time = $time * 24;
            $hour = intval($time);
            $time = ($time - $hour) * 60;
            $min = intval($time);
            $time = ($time - $min) * 60;
            $sec = intval($time);
            $trackData['time']['hour'][$i] = $hour;
            $trackData['time']['min'][$i] = $min;
            $trackData['time']['sec'][$i] = $sec;
        }
        $date = date_create();
        date_date_set($date, 1980, 1, 1);
        date_modify($date, '+' . (intval($m[OZI_date][0]) - 29221) . ' days');
        $trackData['date']['day'] = intval(date_format($date, 'j'));
        $trackData['date']['month'] = intval(date_format($date, 'n'));
        $trackData['date']['year'] = intval(date_format($date, 'Y'));
    }
    return $nbPts;
}
示例#22
0
      <?php 
                                break;
                            default:
                                ?>
                    <td style="background:yellow;" title="Absence non encore traitée par le service de Vie Scolaire">...</td>
      <?php 
                                break;
                        }
                    }
                }
                ?>
          </tr>
    <?php 
            }
            //$date_actuelle = date_add($date_actuelle , $date_interval);
            date_date_set($date_actuelle, $date_actuelle->format('Y'), $date_actuelle->format('m'), $date_actuelle->format('d') - 1);
        }
        ?>
      </table>
  <?php 
    }
}
?>



      <p class="bold small">Impression faite le <?php 
echo date("d/m/Y - H:i");
?>
.</p>
    </div>
示例#23
0
文件: date.php 项目: badlamer/hhvm
<?php

date_default_timezone_set("America/Los_Angeles");
function format($dt)
{
    var_dump(date_format($dt, "Y-m-d H:i:s"));
}
format(date_create("2006-12-12"), "2006-12-12 00:00:00");
format(date_create("@1170288001"), "2007-02-01 00:00:01");
$dt = date_create("2006-12-12 12:34:56");
date_date_set($dt, 2007, 11, 23);
format($dt);
$dt = date_create("2008-08-08 00:00:00");
date_isodate_set($dt, 2007, 35, 3);
format($dt);
$dt = date_create("2006-12-12 00:00:00");
date_modify($dt, "+1 day");
format($dt);
var_dump(date_offset_get(date_create("2006-12-12")));
var_dump(date_offset_get(date_create("2008-08-08")));
$dt = date_create("2006-12-12 12:34:56");
date_time_set($dt, 23, 45, 12);
format($dt);
$d = strtotime("2008-09-10 12:34:56");
var_dump(date("l", $d));
var_dump(date("l jS \\of F Y h:i:s A", $d));
var_dump(date("l", mktime(0, 0, 0, 7, 1, 2000)));
var_dump(date(DATE_RFC822, $d));
var_dump(date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000)));
var_dump(date("l \\t\\h\\e jS", $d));
$tomorrow = mktime(0, 0, 0, (int) date("m", $d), (int) date("d", $d) + 1, (int) date("Y", $d));
示例#24
0
    //
    $size = $row['size'];
    //
}
$drugid = $_SESSION['drugid'];
$line = 12;
//number of table row per print out page
$rotab = 1;
//initial table row
if ($_SESSION['sm'] == '') {
    $_SESSION['sm'] = date("m");
    $_SESSION['sy'] = date("Y");
}
include '../libs/progdate.php';
$thisdate = date_create();
date_date_set($thisdate, $sy, $sm, $sd);
$ddate = date_format($thisdate, 'Y-m-d');
if ($_SESSION['page'] == '') {
    $_SESSION['page'] = 1;
    $_SESSION['i'] = 1;
    //initial pt no 1.
}
////////
if ($_POST['nopage'] == 'Next') {
    $_SESSION['page'] = $_SESSION['page'] + 1;
    $ntimeprst = $_SESSION['ntimeprst'];
    if ($_SESSION['page'] > 1) {
        $rotab = $_SESSION['i'] + 1;
    }
}
//$prescript this month
 private function saveDailyPlansForService($plans, $hpPlans, $serviceId, $month, $year)
 {
     $em = $this->getDoctrine()->getManager();
     $service = $em->getRepository('sisconeeAppBundle:Servicio')->findOneById($serviceId);
     $date = date_create();
     for ($d = 1; $d <= 31; $d++) {
         date_date_set($date, $year, $month, $d);
         date_time_set($date, 0, 0, 0);
         $this->updateDailyPlan($em, $service, $date, $plans[$d], $hpPlans[$d]);
     }
 }
 /**
  * Private implementation of date_repeat_calc().
  *
  * Compute dates that match the requested rule, within a specified date range.
  */
 public static function date_repeat_calc($rrule, $start, $end, $exceptions = array(), $timezone = NULL, $additions = array())
 {
     if (empty($timezone)) {
         $timezone = Yii::app()->getTimeZone();
     }
     // Make sure the 'EXCEPTIONS' string isn't appended to the rule.
     $parts = explode("\n", $rrule);
     if (count($parts)) {
         $rrule = $parts[0];
     }
     // Get the parsed array of rule values.
     $rrule = self::date_ical_parse_rrule('RRULE:', $rrule);
     // Create a date object for the start and end dates.
     $start_date = new DateObject($start, $timezone);
     $end_date = new DateObject($end, $timezone);
     // If the rule has an UNTIL, see if that is earlier than the end date.
     if (!empty($rrule['UNTIL'])) {
         $until_date = self::date_ical_date($rrule['UNTIL'], $timezone);
         if (date_format($until_date, 'U') < date_format($end_date, 'U')) {
             $end_date = $until_date;
         }
     }
     // Get an integer value for the interval, if none given, '1' is implied.
     $interval = max(1, isset($rrule['INTERVAL']) ? $rrule['INTERVAL'] : 1);
     $count = isset($rrule['COUNT']) ? $rrule['COUNT'] : NULL;
     if (empty($rrule['FREQ'])) {
         $rrule['FREQ'] = 'DAILY';
     }
     // Make sure DAILY frequency isn't used in places it won't work;
     if (!empty($rrule['BYMONTHDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) {
         $rrule['FREQ'] = 'MONTHLY';
     } else {
         if (!empty($rrule['BYDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
             $rrule['FREQ'] = 'WEEKLY';
         }
     }
     // Find the time period to jump forward between dates.
     switch ($rrule['FREQ']) {
         case 'DAILY':
             $jump = $interval . ' days';
             break;
         case 'WEEKLY':
             $jump = $interval . ' weeks';
             break;
         case 'MONTHLY':
             $jump = $interval . ' months';
             break;
         case 'YEARLY':
             $jump = $interval . ' years';
             break;
     }
     $rrule = self::date_repeat_adjust_rrule($rrule, $start_date);
     // The start date always goes into the results, whether or not it meets
     // the rules. RFC 2445 includes examples where the start date DOES NOT
     // meet the rules, but the expected results always include the start date.
     $days = array(date_format($start_date, DATE_FORMAT_DATETIME));
     // BYMONTHDAY will look for specific days of the month in one or more months.
     // This process is only valid when frequency is monthly or yearly.
     if (!empty($rrule['BYMONTHDAY'])) {
         $finished = FALSE;
         $current_day = clone $start_date;
         $direction_days = array();
         // Deconstruct the day in case it has a negative modifier.
         foreach ($rrule['BYMONTHDAY'] as $day) {
             preg_match("@(-)?([0-9]{1,2})@", $day, $regs);
             if (!empty($regs[2])) {
                 // Convert parameters into full day name, count, and direction.
                 $direction_days[$day] = array('direction' => !empty($regs[1]) ? $regs[1] : '+', 'direction_count' => $regs[2]);
             }
         }
         while (!$finished) {
             $period_finished = FALSE;
             while (!$period_finished) {
                 foreach ($rrule['BYMONTHDAY'] as $monthday) {
                     $day = $direction_days[$monthday];
                     $current_day = self::date_repeat_set_month_day($current_day, NULL, $day['direction_count'], $day['direction'], $timezone);
                     self::date_repeat_add_dates($days, $current_day, $start_date, $end_date, $exceptions, $rrule);
                     if ($finished = self::date_repeat_is_finished($current_day, $days, $count, $end_date)) {
                         $period_finished = TRUE;
                     }
                 }
                 // If it's monthly, keep looping through months, one INTERVAL at a time.
                 if ($rrule['FREQ'] == 'MONTHLY') {
                     if ($finished = self::date_repeat_is_finished($current_day, $days, $count, $end_date)) {
                         $period_finished = TRUE;
                     }
                     // Back up to first of month and jump.
                     $current_day = self::date_repeat_set_month_day($current_day, NULL, 1, '+', $timezone);
                     date_modify($current_day, '+' . $jump);
                 } else {
                     if (date_format($current_day, 'n') == 12) {
                         $period_finished = TRUE;
                     } else {
                         // Back up to first of month and jump.
                         $current_day = self::date_repeat_set_month_day($current_day, NULL, 1, '+', $timezone);
                         date_modify($current_day, '+1 month');
                     }
                 }
             }
             if ($rrule['FREQ'] == 'YEARLY') {
                 // Back up to first of year and jump.
                 $current_day = self::date_repeat_set_year_day($current_day, NULL, 1, '+', $timezone);
                 date_modify($current_day, '+' . $jump);
             }
             $finished = self::date_repeat_is_finished($current_day, $days, $count, $end_date);
         }
     } elseif (empty($rrule['BYDAY'])) {
         // $current_day will keep track of where we are in the calculation.
         $current_day = clone $start_date;
         $finished = FALSE;
         $months = !empty($rrule['BYMONTH']) ? $rrule['BYMONTH'] : array();
         while (!$finished) {
             self::date_repeat_add_dates($days, $current_day, $start_date, $end_date, $exceptions, $rrule);
             $finished = self::date_repeat_is_finished($current_day, $days, $count, $end_date);
             date_modify($current_day, '+' . $jump);
         }
     } else {
         // More complex searches for day names and criteria like '-1SU' or '2TU,2TH',
         // require that we interate through the whole time period checking each BYDAY.
         // Create helper array to pull day names out of iCal day strings.
         $day_names = self::date_repeat_dow_day_options(FALSE);
         $days_of_week = array_keys($day_names);
         // Parse out information about the BYDAYs and separate them
         // depending on whether they have directional parameters like -1SU or 2TH.
         $month_days = array();
         $week_days = array();
         // Find the right first day of the week to use, iCal rules say Monday
         // should be used if none is specified.
         $week_start_rule = !empty($rrule['WKST']) ? trim($rrule['WKST']) : 'MO';
         $week_start_day = $day_names[$week_start_rule];
         // Make sure the week days array is sorted into week order,
         // we use the $ordered_keys to get the right values into the key
         // and force the array to that order. Needed later when we
         // iterate through each week looking for days so we don't
         // jump to the next week when we hit a day out of order.
         $ordered = self::date_repeat_days_ordered($week_start_rule);
         $ordered_keys = array_flip($ordered);
         foreach ($rrule['BYDAY'] as $day) {
             preg_match("@(-)?([0-9]+)?([SU|MO|TU|WE|TH|FR|SA]{2})@", trim($day), $regs);
             if (!empty($regs[2])) {
                 // Convert parameters into full day name, count, and direction.
                 $direction_days[] = array('day' => $day_names[$regs[3]], 'direction' => !empty($regs[1]) ? $regs[1] : '+', 'direction_count' => $regs[2]);
             } else {
                 $week_days[$ordered_keys[$regs[3]]] = $day_names[$regs[3]];
             }
         }
         ksort($week_days);
         // BYDAYs with parameters like -1SU (last Sun) or 2TH (second Thur)
         // need to be processed one month or year at a time.
         if (!empty($direction_days) && in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) {
             $finished = FALSE;
             $current_day = clone $start_date;
             while (!$finished) {
                 foreach ($direction_days as $day) {
                     // Find the BYDAY date in the current month.
                     if ($rrule['FREQ'] == 'MONTHLY') {
                         $current_day = self::date_repeat_set_month_day($current_day, $day['day'], $day['direction_count'], $day['direction'], $timezone);
                     } else {
                         $current_day = self::date_repeat_set_year_day($current_day, $day['day'], $day['direction_count'], $day['direction'], $timezone);
                     }
                     self::date_repeat_add_dates($days, $current_day, $start_date, $end_date, $exceptions, $rrule);
                 }
                 $finished = self::date_repeat_is_finished($current_day, $days, $count, $end_date);
                 // Reset to beginning of period before jumping to next period.
                 // Needed especially when working with values like 'last Saturday'
                 // to be sure we don't skip months like February.
                 $year = date_format($current_day, 'Y');
                 $month = date_format($current_day, 'n');
                 if ($rrule['FREQ'] == 'MONTHLY') {
                     date_date_set($current_day, $year, $month, 1);
                 } else {
                     date_date_set($current_day, $year, 1, 1);
                 }
                 // Jump to the next period.
                 date_modify($current_day, '+' . $jump);
             }
         }
         // For BYDAYs without parameters,like TU,TH (every Tues and Thur),
         // we look for every one of those days during the frequency period.
         // Iterate through periods of a WEEK, MONTH, or YEAR, checking for
         // the days of the week that match our criteria for each week in the
         // period, then jumping ahead to the next week, month, or year,
         // an INTERVAL at a time.
         if (!empty($week_days) && in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
             $finished = FALSE;
             $current_day = clone $start_date;
             $format = $rrule['FREQ'] == 'YEARLY' ? 'Y' : 'n';
             $current_period = date_format($current_day, $format);
             // Back up to the beginning of the week in case we are somewhere in the
             // middle of the possible week days, needed so we don't prematurely
             // jump to the next week. Theself::date_repeat_add_dates() function will
             // keep dates outside the range from getting added.
             if (date_format($current_day, 'l') != $day_names[$day]) {
                 date_modify($current_day, '-1 ' . $week_start_day);
             }
             while (!$finished) {
                 $period_finished = FALSE;
                 while (!$period_finished) {
                     $moved = FALSE;
                     foreach ($week_days as $delta => $day) {
                         // Find the next occurence of each day in this week, only add it
                         // if we are still in the current month or year. Theself::date_repeat_add_dates
                         // function is insufficient to test whether to include this date
                         // if we are using a rule like 'every other month', so we must
                         // explicitly test it here.
                         // If we're already on the right day, don't jump or we
                         // will prematurely move into the next week.
                         if (date_format($current_day, 'l') != $day) {
                             date_modify($current_day, '+1 ' . $day);
                             $moved = TRUE;
                         }
                         if ($rrule['FREQ'] == 'WEEKLY' || date_format($current_day, $format) == $current_period) {
                             self::date_repeat_add_dates($days, $current_day, $start_date, $end_date, $exceptions, $rrule);
                         }
                     }
                     $finished = self::date_repeat_is_finished($current_day, $days, $count, $end_date);
                     // Make sure we don't get stuck in endless loop if the current
                     // day never got changed above.
                     if (!$moved) {
                         date_modify($current_day, '+1 day');
                     }
                     // If this is a WEEKLY frequency, stop after each week,
                     // otherwise, stop when we've moved outside the current period.
                     // Jump to the end of the week, then test the period.
                     if ($finished || $rrule['FREQ'] == 'WEEKLY') {
                         $period_finished = TRUE;
                     } elseif ($rrule['FREQ'] != 'WEEKLY' && date_format($current_day, $format) != $current_period) {
                         $period_finished = TRUE;
                     }
                 }
                 if ($finished) {
                     continue;
                 }
                 // We'll be at the end of a week, month, or year when
                 // we get to this point in the code.
                 // Go back to the beginning of this period before we jump, to
                 // ensure we jump to the first day of the next period.
                 switch ($rrule['FREQ']) {
                     case 'WEEKLY':
                         date_modify($current_day, '+1 ' . $week_start_day);
                         date_modify($current_day, '-1 week');
                         break;
                     case 'MONTHLY':
                         date_modify($current_day, '-' . (date_format($current_day, 'j') - 1) . ' days');
                         date_modify($current_day, '-1 month');
                         break;
                     case 'YEARLY':
                         date_modify($current_day, '-' . date_format($current_day, 'z') . ' days');
                         date_modify($current_day, '-1 year');
                         break;
                 }
                 // Jump ahead to the next period to be evaluated.
                 date_modify($current_day, '+' . $jump);
                 $current_period = date_format($current_day, $format);
                 $finished = self::date_repeat_is_finished($current_day, $days, $count, $end_date);
             }
         }
     }
     // add additional dates
     foreach ($additions as $addition) {
         $days[] = date_format($addition, DATE_FORMAT_DATETIME);
     }
     sort($days);
     return $days;
 }
示例#27
0
 /**
  * Devuelve la diferencia entre dos tiempos expresada en horas y minutos
  * Cuando la hora de fin es menor que la hora de inicio es asumido que ocurre un día después
  * @param \DateTime $inicio
  * @param \DateTime $fin
  * @return type
  */
 public function calculateDiff(\DateTime $inicio, \DateTime $fin)
 {
     date_date_set($inicio, 0, 0, 0);
     date_date_set($fin, 0, 0, 0);
     $diff = $inicio->diff($fin);
     $invert = $diff->invert;
     $h = $diff->h;
     $i = $diff->i;
     if ($invert == 1) {
         $h = 24 - $h;
         if ($i > 0) {
             $i = 60 - $i;
             $h = $h - 1;
         }
     }
     return array('h' => $h, 'i' => $i);
 }
示例#28
0
    public function __toString()
    {
        return "Class A object";
    }
}
class classWithoutToString
{
}
// heredoc string
$heredoc = <<<EOT
hello world
EOT;
// add arrays
$index_array = array(1, 2, 3);
$assoc_array = array('one' => 1, 'two' => 2);
// resource
$file_handle = fopen(__FILE__, 'r');
//array of values to iterate over
$inputs = array('int 0' => 0, 'int 1' => 1, 'int 12345' => 12345, 'int -12345' => -12345, 'float 10.5' => 10.5, 'float -10.5' => -10.5, 'float .5' => 0.5, 'empty array' => array(), 'int indexed array' => $index_array, 'associative array' => $assoc_array, 'nested arrays' => array('foo', $index_array, $assoc_array), 'uppercase NULL' => NULL, 'lowercase null' => null, 'lowercase true' => true, 'lowercase false' => false, 'uppercase TRUE' => TRUE, 'uppercase FALSE' => FALSE, 'empty string DQ' => "", 'empty string SQ' => '', 'string DQ' => "string", 'string SQ' => 'string', 'mixed case string' => "sTrInG", 'heredoc' => $heredoc, 'instance of classWithToString' => new classWithToString(), 'instance of classWithoutToString' => new classWithoutToString(), 'undefined var' => @$undefined_var, 'unset var' => @$unset_var, 'resource' => $file_handle);
$object = date_create("2009-02-27 08:34:10");
$day = 2;
$month = 7;
foreach ($inputs as $variation => $year) {
    echo "\n-- {$variation} --\n";
    var_dump(date_date_set($object, $year, $month, $day));
}
// closing the resource
fclose($file_handle);
?>
===DONE===
 static function to_date($date = NULL, $default_to_earliest = TRUE, $fully_expand = FALSE)
 {
     if ($date == '') {
         if ($fully_expand) {
             return date('Y-m-d', time());
         }
         return date('Y-m-d-H-i', time());
     }
     if ($date[0] == '+') {
         return date('Y-m-d', time() + substr($date, 1));
     } else {
         if ($date[0] == '-') {
             return date('Y-m-d', time() - substr($date, 1));
         } else {
             if (is_string($date) && preg_match('/this_year/i', $date)) {
                 $date = date('Y');
             }
         }
     }
     if (is_array($date)) {
         $date_parts = $date;
     } else {
         $date_parts = preg_split('/[-\\.\\/ ]/', $date, -1, PREG_SPLIT_NO_EMPTY);
     }
     // we utilise the fact that setting the day to 0 will result in the
     // last day of the month being set
     $date = array(1970, 12, 0);
     if ($default_to_earliest) {
         $date = array(1970, 1, 1);
     }
     if (@isset($date_parts[0])) {
         $date[0] = $date_parts[0];
     }
     if (@isset($date_parts[1])) {
         $date[1] = $date_parts[1];
     }
     if (@isset($date_parts[2])) {
         $date[2] = $date_parts[2];
     } else {
         if (!$default_to_earliest) {
             $date[1] += 1;
         }
     }
     $date_instance = date_create();
     date_date_set($date_instance, $date[0], $date[1], $date[2]);
     // deal with an extended format, ie hour and minutes
     if (count($date_parts) >= 5) {
         date_time_set($date_instance, $date_parts[3], $date_parts[4]);
         return date_format($date_instance, 'Y-m-d-H-i');
     }
     if ($fully_expand) {
         if (!$default_to_earliest) {
             date_time_set($date_instance, 23, 59);
         } else {
             date_time_set($date_instance, 00, 00);
         }
         return date_format($date_instance, 'Y-m-d-H-i');
     }
     return date_format($date_instance, 'Y-m-d');
 }