protected function getRequest($options) { $builder = OSSRequestBuilder::factory(); if (isset($options[OSSOptions::MODIFIED_SINCE_CONSTRAINT])) { $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE_IF_MODIFIED_SINCE, DateUtils::formatDate($options[OSSOptions::MODIFIED_SINCE_CONSTRAINT])); } if (isset($options[OSSOptions::UNMODIFIED_SINCE_CONSTRAINT])) { $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE_IF_UNMODIFIED_SINCE, DateUtils::formatDate($options[OSSOptions::UNMODIFIED_SINCE_CONSTRAINT])); } if (isset($options[OSSOptions::MATCHING_ETAG_CONSTRAINTS])) { $constraints = $options[OSSOptions::MATCHING_ETAG_CONSTRAINTS]; $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE_IF_MATCH, join(', ', $constraints)); } if (isset($options[OSSOptions::NO_MATCHING_ETAG_CONSTRAINTS])) { $constraints = $options[OSSOptions::NO_MATCHING_ETAG_CONSTRAINTS]; $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE_IF_NONE_MATCH, join(', ', $constraints)); } $builder->addHeader(OSSHeaders::COPY_OBJECT_SOURCE, "/" . $options[OSSOptions::SOURCE_BUCKET] . "/" . $options[OSSOptions::SOURCE_KEY]); if (OSSUtils::containsMetaOptions($options)) { $builder->addObjectMetadataHeaders($options); $builder->addHeader(OSSHeaders::COPY_OBJECT_METADATA_DIRECTIVE, 'REPLACE'); } else { $builder->addHeader(OSSHeaders::COPY_OBJECT_METADATA_DIRECTIVE, 'COPY'); } return $builder->setEndpoint($options[OSSOptions::ENDPOINT])->setBucket($options[OSSOptions::DEST_BUCKET])->setKey($options[OSSOptions::DEST_KEY])->setMethod(HttpMethods::PUT)->build(); }
function get_menu_midi_content() { global $mysql; global $locale; $content = ''; $sql = "SELECT * FROM t_output_menu_midi WHERE type = 3 OR type = 4 ORDER BY 'id' ASC"; $query = $mysql->sql_query($sql); $ul_open = false; $current_type = ''; $cpt = 0; if ($query && mysqli_num_rows($query) > 0) { $content .= '<div id="menu" class="entryscreen">'; $content .= ' <img src="medias/interface/backgrounds/menu.jpg" alt="Restaurant L\'Échaudé - Menu" />'; $content .= ' <div class="circle blue">'; $content .= ' <div id="menu-midi" class="blue">'; $content .= ' <h2>' . $locale->pt('HOME_MENU_MIDI_TITLE') . ' <span>' . DateUtils::format_date(date('Y-m-d'), $locale->current_language) . '</span></h2>'; while ($result = mysqli_fetch_assoc($query)) { switch ($result['type']) { case 4: // item du jour $cpt++; if ($ul_open == false) { $content .= '<ul>'; $ul_open = true; } if ($result['price'] != '') { $price = '<span class="price">' . $result['price'] . '</span>'; } $content .= '<li><span class="label">' . $result['txt_fr'] . '</span>' . $price . '</li>'; $current_type = $result['type']; break; case 3: // titres if ($ul_open == true) { $content .= '</ul>'; $ul_open = false; } $content .= '<br />'; $current_type = $result['type']; break; } $price = ''; } if ($ul_open == true) { $content .= '</ul>'; } $content .= ' <a id="btn-menu-complet" href="menus#menu-midi">' . $locale->pt('HOME_MENU_MIDI_COMPLET') . '</a>'; $content .= ' </div>'; $content .= ' </div>'; $content .= '</div>'; if ($cpt == 0) { $content = ''; } } return $content; }
public static function getNumericDate($date, $format) { $day = ""; $month = ""; $year = ""; if (!DateUtils::parseDate($date, $format, $day, $month, $year)) { return false; } return intval(str_pad($year, 4, '0', STR_PAD_LEFT) . str_pad($year, 2, '0', STR_PAD_LEFT) . str_pad($year, 2, '0', STR_PAD_LEFT)); }
/** * Affiche la date courante avec format spécial si FR * @param $language String language (fr, en). */ public static function afficher_date($language = 'fr') { if ($language == "fr") { $a_jours = DateUtils::get_jours($language); $a_mois = DateUtils::get_months($language); $date_fr = $a_jours[date("w")] . " le " . date("j") . " " . $a_mois[date("n") - 1] . " " . date("Y"); echo $date_fr; } else { echo date("l F j") . ", " . date("Y"); } }
public static function parse($filePath, $folderSeq) { //$content = file("../files/AQMS.WQD"); //$folderSeq = 9; //$filePath = "G:/accgagal.txt"; $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); $lineRow = 0; for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $lineVals = explode(',', $line); $totalChannels = (count($lineVals) - 3) / 3; $reportNo = $lineVals[1]; if ($reportNo != "1") { continue; } $dateStr = $lineVals[2]; $dated = new DateTime($dateStr); $channels = array(); $varLocation = 3; for ($channelNo = 1; $channelNo <= $totalChannels; $channelNo++) { $channelNumber = $lineVals[$varLocation++]; $channelValue = $lineVals[$varLocation++]; $channelStatus = $lineVals[$varLocation]; $channelInfo = array(); $channelInfo['value'] = $channelValue; $channelInfo['status'] = $channelStatus; $channels[$channelNumber] = $channelInfo; $varLocation++; } $WQDData->setReportNo($reportNo); $WQDData->setFolderSeq($folderSeq); $WQDData->setDataDate(DateUtils::getSQLDateFromDateObj($dated)); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum(0); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }
/** * Formats any date needed for accessible. * * @param int $dateParam timestamp int. * @param boolean $setCompleteFormat specify a format. * @return string formatted date. */ public static function getFormattedDate($dateParam, $setCompleteFormat = false) { if (!isset($dateParam) || !is_int($dateParam)) { return ''; } $timeReceived = date('H:i', $dateParam); $dayReceived = date('d/m/Y', $dateParam); $weekDayReceived = DateUtils::getWeekDay($dateParam); if ($setCompleteFormat) { return $weekDayReceived . ', ' . $dayReceived . ', ' . $timeReceived; } if ($dateParam >= strtotime('today 00:00')) { return date('\\h\\o\\j\\e, H:i', $dateParam); } elseif ($dateParam >= strtotime('yesterday 00:00')) { return 'ontem, ' . $timeReceived; } elseif ($dateParam >= strtotime('-6 day 00:00')) { return $weekDayReceived . ', ' . $timeReceived; } else { return date('d/m/Y', $dateParam); } }
public function SaveAction($form_id) { $id = $form_id + 0; $item = req('item'); try { $this->Validate($id, $item); #load old record if necessary #$item_old = $this->model->one($id); $itemdb = FormUtils::form2dbhash($item, $this->save_fields); FormUtils::form2dbhash_checkboxes($itemdb, $item, 'is_checkbox'); $itemdb['dict_link_auto_id'] = $this->model_related->add_or_update_quick($item['dict_link_auto_id_iname']); $itemdb['dict_link_multi'] = FormUtils::multi2ids(req('dict_link_multi')); #TODO $itemdb['fdate_combo'] = FormUtils::date4combo($item, 'fdate_combo'); $itemdb['ftime'] = DateUtils::timestr2int($item['ftime_str']); #ftime - convert from HH:MM to int (0-24h in seconds) $id = $this->model_add_or_update($id, $itemdb); fw::redirect($this->base_url . '/' . $id . '/edit'); } catch (ApplicationException $ex) { $this->set_form_error($ex->getMessage()); $this->route_redirect("ShowForm"); } }
public static function parse($filePath, $folderSeq) { $gagalFolderSeq = array(33, 40, 35); //$content = file("D:/dat.lsi"); //$folderSeq = 33; $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $line = rtrim($line, ','); $lineVals = explode(',', $line); $totalChannels = count($lineVals) - 2; $totalChannels = $totalChannels / 2; $reportNo = $lineVals[0]; if ($reportNo != "1") { continue; } $dateStr = $lineVals[1]; $dateStr = preg_replace('~\\x{00a0}~u', ' ', $dateStr); $dateStr = trim(html_entity_decode($dateStr)); if (in_array($folderSeq, $gagalFolderSeq)) { $dateStr = ParserStackLsi::convertDate($dateStr); } //$dateStr = ParserStackLsi::convertDate($dateStr); $dated = new DateTime($dateStr); $channels = array(); $varLocation = 2; for ($channelNo = 1; $channelNo <= $totalChannels; $channelNo++) { $channelValue = $lineVals[$varLocation]; $channelStatus = $lineVals[$varLocation + 1]; if ($channelStatus == "1" || $channelStatus == "Ok") { $channelStatus = "128"; } if ($channelStatus == "Abnormal") { $channelStatus = "0"; } $channelInfo = array(); $channelInfo['value'] = round($channelValue, 2); $channelInfo['status'] = $channelStatus; $channels[$channelNo] = $channelInfo; $varLocation++; $varLocation++; } $WQDData->setReportNo($reportNo); $WQDData->setFolderSeq($folderSeq); $WQDData->setDataDate(DateUtils::getSQLDateFromDateObj($dated)); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum(0); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }
public static function getNumericDayOfWeek() { return DateUtils::getTime('%w'); }
public function getMySqlCheckOutDate() { return DateUtils::getMySqlDate($this->checkInDate, $this->dateFormat); }
/** * Devuelve un arreglo con opciones por defecto para ser utilizadas por el componente {@see SelectorDatepickerWidget} * para habilitar un calendario dinámico en campos de texto. Los valores por defecto configuran al calendario * para que esté en español, la fecha esté en formato ISO, muestre combos de meses y años y genere una función reutilizable. * El argumento $tipo puede tener tres opciones: * 'fecha': todas las fechas, selector jQuery 'input.fecha' * 'pasado': solo fechas antes de hoy, selector 'input.fecha-pasado' * 'futuro': solo fechas luego de hoy, selector 'input.fecha-futuro' * @param string $tipo * @param array $adicionales Opciones extra que se combinarán con las opciones por defecto * @return array Opciones para el widget de fechas */ public static function defaultDateOptions($tipo = 'fecha', $adicionales = array()) { $dateoptions = array('selector' => 'input.fecha', 'function' => 'date_set', 'language' => 'es', 'options' => array('dateFormat' => 'yy-mm-dd', 'changeMonth' => true, 'changeYear' => true, 'buttonImage' => Yii::app()->baseurl . '/images/icons/calendar.png', 'buttonImageOnly' => true, 'showOn' => 'both', 'buttonText' => 'Ver Calendario')); if ($tipo == 'pasado') { $dateoptions['function'] = 'date_set_pasado'; $dateoptions['selector'] = 'input.fecha-pasado'; $dateoptions['options']['maxDate'] = DateUtils::now(); } if ($tipo == 'futuro') { $dateoptions['function'] = 'date_set_futuro'; $dateoptions['selector'] = 'input.fecha-futuro'; $dateoptions['options']['minDate'] = DateUtils::now(); } if ($tipo == 'tabla') { $dateoptions['function'] = 'date_set_futuro'; $dateoptions['selector'] = 'input.fecha-futuro'; $dateoptions['options']['minDate'] = DateUtils::now(); $dateoptions['options']['maxDate'] = DateUtils::future(); } if ($adicionales) { $dateoptions = array_merge($dateoptions, $adicionales); } return $dateoptions; }
/** * @deprecated use DateUtils::getDate * @param null $now * @return string */ public static function getDate($now = null) { return DateUtils::getDate($now); }
/** * @dataProvider alignToSecondsDataProvider **/ public function testAlignToSeconds(Timestamp $stamp, $expected) { $this->assertEquals(DateUtils::alignToSeconds($stamp, 42)->toString(), $expected); }
/** * @covers DateUtils::parseDate */ public function testParseDate() { $actual = \DateUtils::parseDate("2015-05-01 10:34:23", "Europe/Paris"); $excepted = 1430469263; $this->assertEquals($excepted, $actual); }
public function generateFile() { echo "APPCB Generator starts...\n"; $CCDS = ChannelConfigurationDataStore::getInstance(); $FDS = FolderDataStore::getInstance(); $WQDS = WQDDataDataStore::getInstance(); $folders = $FDS->FindByLocationSeqs("7,10"); echo "<br>--------TotalFolders:" . count($folders); foreach ($folders as $folder) { $stationName = $folder->getFolderName(); $stationNumber = substr($stationName, 7); $districtCode = "kham"; $industryCode = "ITCPBCM"; //if($folder->getSeq() == 20){ if ($folder->getLocationSeq() == 10) { $stationNumber = 1; if ($folder->getSeq() == 26) { $stationNumber = 2; } else { if ($folder->getSeq() == 27) { $stationNumber = 3; } else { if ($folder->getSeq() == 28) { $stationNumber = 4; } else { if ($folder->getSeq() == 29) { $stationNumber = 5; } } } } $districtCode = "hyde"; $industryCode = "APPCB"; } $folSeq = $folder->getSeq(); $latestDataRows = $WQDS->getChannelsLatestInfo($folSeq); echo "FolderSeq:" . $folSeq . " FolderName:" . $folder->getFolderName() . "<br>\n"; //echo ("<br>\nTotal Rows found:". count($latestDataRows)); echo "<br>\n ToDateFromLatestData " . $latestDataRows['dated']; if (count($latestDataRows) > 0) { $channelConfigs = $CCDS->FindByFolder($folSeq); $toDateStr = $latestDataRows['dated']; $toDate = new DateTime($toDateStr); $fromDate = new DateTime($toDateStr); $fromDate->setTime(0, 0, 0); $fromDateStr = DateUtils::getSQLDateFromDateObj($fromDate); echo "<br>From:" . $fromDateStr . "<br>\n"; echo "To:" . $toDateStr . "<br>\n"; $dataArray = $WQDS->getAllDataByFol($fromDateStr, $toDateStr, $folSeq); $channelNoArr = self::getChannelNumberNameArray(self::$channelsList, $channelConfigs); $addDatesData = array(); foreach ($dataArray as $data) { $channelData = array(); $dated = $data['wqdfiledatadated']; $chValues = array(); $chStatuses = array(); foreach ($channelNoArr as $key => $value) { $vl = (double) $data["ch" . $key . "value"]; if ($vl < 0) { $vl = "n.o"; } array_push($chValues, $vl); array_push($chStatuses, (double) $data["ch" . $key . "status"]); } $allDatesData[strtotime($dated)]['channelValue'] = $chValues; $allDatesData[strtotime($dated)]['channelStatuses'] = $chStatuses; } $channelArr = array(); foreach ($channelNoArr as $chName) { array_push($channelArr, $chName); } $dataSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, "1hour"); $dataRows = $WQDS->getAverageDataByDataArrayDataSlices("1hour", $allDatesData, $dataSlices, $channelArr, "normal", array()); } else { echo " \n<br>Null FromDate"; } if (count($dataRows) > 1) { $repStr = ""; foreach ($dataRows as $dateStr => $row) { $chNameValueArr = array(); foreach ($row as $rowId => $rowVal) { $chNameValueArr[$channelArr[$rowId]] = $rowVal; } $repStr .= $districtCode; $repStr .= "," . $industryCode; $repStr .= "," . $stationNumber . ","; $dated = new DateTime($dateStr); $repStr .= $dated->format("m/d/Y h:i:s A"); $channelsList = self::$channelsList; foreach ($channelsList as $chName) { if ($chNameValueArr[$chName] != null) { $repStr .= "," . $chNameValueArr[$chName]; } else { $repStr .= ",NA"; } } $repStr .= "\r\n"; } echo $repStr; //$fileName = "khmmitcl".$folder->getFolderName(). date("Ymd") .".txt"; //$fileName = "air". date("Ymd") .".txt"; $fileName = "air" . $fromDate->format("Ymd") . ".txt"; $repFileName = "/home/envirote/public_html/Generated/APPCB/" . $folSeq . "/" . $fileName; //$repFileName ="d:". $folSeq ."/" . $fileName; if (!file_exists(dirname($repFileName))) { mkdir(dirname($repFileName), 0777, true); } $fh = fopen($repFileName, 'w') or die("can't open file"); fwrite($fh, $repStr); fclose($fh); } unset($channelArr); unset($latestDataRows); unset($channelConfigs); unset($channelNoArr); unset($dataSlices); unset($dataRows); unset($chNameValueArr); unset($allDatesData); unset($channelsList); } //for loop ends }
public function render($view_file, $values = array()) { global $currentUser; return Entity::render($view_file, array_merge($values, array("avatar_url" => "/data/images/profiles/users/" . ($this['avatar'] ? $this['avatar'] : "default.png"), "parsed_message" => $this->getParsedMessage(), "parsed_signature" => Text::MessageToHtml($this['signature']), "view_profile_url" => "#", "formatted_post_date" => DateUtils::GetNice($this['post_date']), "edited" => $this['edit_by'] != '0', "edit_by" => $this['edit_by'], "edit_user" => $this['edit_user'], "edit_date" => DateUtils::GetNice($this['edit_date']), "is_mod" => $currentUser->isModOfForum($this['argument']), "can_edit" => $currentUser->isModOfForum($this['argument']) || $currentUser["id"] == $this['user_id']))); }
public function generateFile() { echo "MANIKGARH Generator starts...\n"; $CCDS = ChannelConfigurationDataStore::getInstance(); $FDS = FolderDataStore::getInstance(); $WQDS = WQDDataDataStore::getInstance(); $folders = $FDS->FindByLocationSeqs("11"); echo "<br>--------TotalFolders:" . count($folders); foreach ($folders as $folder) { $folSeq = $folder->getSeq(); //$latestDataRows = $WQDS->getChannelsLatestInfo($folSeq); echo "FolderSeq:" . $folSeq . " FolderName:" . $folder->getFolderName() . "<br>\n"; echo "<br>\n ToDateFromLatestData " . $latestDataRows['dated']; $channelConfigs = $CCDS->FindByFolder($folSeq); $toDateStr = date('Y/m/d H:00:00'); $fromDateStr = date('Y/m/d H:00:00', strtotime('-1 hour')); //$toDateStr = "2014/02/15 18:00:00"; // $fromDateStr = "2014/02/15 17:00:00"; $toDate = new DateTime($toDateStr); $fromDate = new DateTime($fromDateStr); echo "<br>From:" . $fromDateStr . "<br>\n"; echo "To:" . $toDateStr . "<br>\n"; $dataArray = $WQDS->getAllDataByFol($fromDateStr, $toDateStr, $folSeq); $channelNoArr = self::getChannelNumberNameArray(self::$channelsList, $channelConfigs); $addDatesData = array(); foreach ($dataArray as $data) { $channelData = array(); $dated = $data['wqdfiledatadated']; $chValues = array(); $chStatuses = array(); foreach ($channelNoArr as $key => $value) { $vl = (double) $data["ch" . $key . "value"]; if ($vl < 0) { $vl = "n.o"; } array_push($chValues, $vl); array_push($chStatuses, (double) $data["ch" . $key . "status"]); } $allDatesData[strtotime($dated)]['channelValue'] = $chValues; $allDatesData[strtotime($dated)]['channelStatuses'] = $chStatuses; } $channelArr = array(); foreach ($channelNoArr as $chName) { array_push($channelArr, $chName); } $dataSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, "15min"); $dataRows = $WQDS->getAverageDataByDataArrayDataSlices("15min", $allDatesData, $dataSlices, $channelArr, "normal", array()); $repStr = ""; if (count($dataRows) > 1) { $repStr = ""; foreach ($dataRows as $dateStr => $row) { $chNameValueArr = array(); foreach ($row as $rowId => $rowVal) { $chNameValueArr[$channelArr[$rowId]] = $rowVal; } $dated = new DateTime($dateStr); $repStr .= $dated->format("Y-m-d H:i:s"); $channelsList = self::$channelsList; foreach ($channelsList as $chName) { if ($chNameValueArr[$chName] != null) { $repStr .= "," . $chNameValueArr[$chName]; } else { $repStr .= ",NA"; } } $repStr .= "\r\n"; } echo $repStr; $currDate = new DateTime(); $fileName = "MHCHDMANIKGARHC011_" . $dated->format("YmdHis") . ".csv"; $repFileName = "/home/envirote/public_html/Generated/Manikgarh/" . $folSeq . "/" . $fileName; //$repFileName = $fileName; if (!file_exists(dirname($repFileName))) { mkdir(dirname($repFileName), 0777, true); } $fh = fopen($repFileName, 'w') or die("can't open file"); fwrite($fh, $repStr); fclose($fh); } unset($channelArr); unset($latestDataRows); unset($channelConfigs); unset($channelNoArr); unset($dataSlices); unset($dataRows); unset($chNameValueArr); unset($allDatesData); unset($channelsList); } //for loop ends }
/** * Get a unix timestamp representing 12AM of the first day of the week of the * given date in the the given timezone. * Assumes that the first day of the week is Monday. * Note: Requires (PHP 5 >= 5.1.0) * * @param long $date unix timestamp. * @param String $timezone time zone code. * @return long unix timestamp */ public static function getBeginningOfWeek($timestamp, $timezone) { $dt = DateUtils::makeDateFromTimestamp($timestamp, $timezone); // 1=Monday,... 7=Sunday $dayOfWeek = intval($dt->format('N')); // (PHP 5 >= 5.1.0) $daysDiff = $dayOfWeek - 1; $dt->modify("-{$daysDiff} day"); $dt->setTime(0, 0, 0); return self::dateTimeToTimestamp($dt); }
public function getWindRoseReport($GET) { $infoType = $GET['infoTypeRadio']; $periodType = $GET['periodTypeRadio']; $fromDateStr = $GET['fromDate']; $toDateStr = $GET['toDate']; $timeBase = $GET['timeBase']; $timeBaseQuick = $GET['timeBaseQuick']; $quickReportType = $GET['quickReportType']; if ($quickReportType != "null") { $timeBase = $timeBaseQuick; } $timeBaseFromGet = $timeBase; $folSeqArray = array(); //holds all folderseqs foreach ($GET as $key => $value) { if (strpos($key, "channelNos_") !== false) { $folSeq = (double) substr($key, 11); array_push($folSeqArray, $folSeq); } } if (count($folSeqArray) == 0) { return null; } $folSeq = $folSeqArray[0]; //calculating from to dates from provided $_GET $fromToDates = DateUtils::getDatesArrayForStationReports($quickReportType, $fromDateStr, $toDateStr); // $dateSlices = DateUtils::getDateSlicesByInterval($fromDate,$toDate,$timeBase); $WSChannelNo = 0; $WDChannelNo = 0; $CCDS = ChannelConfigurationDataStore::getInstance(); $ChannelsInfo = $CCDS->FindByFolder($folSeq); foreach ($ChannelsInfo as $channel) { if ($channel->getChannelName() == "Wind Speed") { $WSChannelNo = $channel->getChannelNumber(); } else { if ($channel->getChannelName() == "Wind Direction") { $WDChannelNo = $channel->getChannelNumber(); } } } $fromDate = new DateTime($fromToDates['fromDate']); $toDate = new DateTime($fromToDates['toDate']); $toDate->setTime(23, 59, 59); $fromDate = $fromDate->format("Y/m/d H:i:s"); $toDate = $toDate->format("Y/m/d H:i:s"); $WQDS = WQDDataDataStore::getInstance(); if (strpos($timeBase, 'hours') !== false) { $timeBase = "1hour"; } $WSArrayDB = $WQDS->getChannel($fromDate, $toDate, $folSeq, $WSChannelNo, $timeBase); $WDArrayDB = $WQDS->getChannel($fromDate, $toDate, $folSeq, $WDChannelNo, $timeBase); if ($WSArrayDB == null || $WDArrayDB == null) { return null; } $WS = array(); $WD = array(); $i = 0; $WSDateInterval = $WSArrayDB[0][0]; foreach ($WSArrayDB as $ws) { if (strtotime($ws[0]) == strtotime($WSDateInterval)) { $WS[$i++] = floatval($ws[1]); $WSDateInterval = DateUtils::getIncrementedDateStr($WSDateInterval, $timeBaseFromGet); } } $i = 0; $WDDateInterval = $WDArrayDB[0][0]; foreach ($WDArrayDB as $wd) { if (strtotime($wd[0]) == strtotime($WDDateInterval)) { $WD[$i++] = floatval($wd[1]); $WDDateInterval = DateUtils::getIncrementedDateStr($WDDateInterval, $timeBaseFromGet); } } $direction_array["N"][] = null; $direction_array["NNE"][] = null; $direction_array["NE"][] = null; $direction_array["ENE"][] = null; $direction_array["E"][] = null; $direction_array["ESE"][] = null; $direction_array["SE"][] = null; $direction_array["SSE"][] = null; $direction_array["S"][] = null; $direction_array["SSW"][] = null; $direction_array["SW"][] = null; $direction_array["WSW"][] = null; $direction_array["W"][] = null; $direction_array["WNW"][] = null; $direction_array["NW"][] = null; $direction_array["NNW"][] = null; for ($ii = 0; $ii < count($WD); $ii++) { switch ($WD[$ii]) { case $WD[$ii] >= 348.75 or $WD[$ii] < 11.25: $direction_array["N"][] = $WS[$ii]; break; case $WD[$ii] >= 11.25 and $WD[$ii] < 33.75: $direction_array["NNE"][] = $WS[$ii]; break; case $WD[$ii] >= 33.75 and $WD[$ii] < 56.25: $direction_array["NE"][] = $WS[$ii]; break; case $WD[$ii] >= 56.25 and $WD[$ii] < 78.75: $direction_array["ENE"][] = $WS[$ii]; break; case $WD[$ii] >= 78.75 and $WD[$ii] < 101.25: $direction_array["E"][] = $WS[$ii]; break; case $WD[$ii] >= 101.25 and $WD[$ii] < 123.75: $direction_array["ESE"][] = $WS[$ii]; break; case $WD[$ii] >= 123.75 and $WD[$ii] < 146.25: $direction_array["SE"][] = $WS[$ii]; break; case $WD[$ii] >= 146.25 and $WD[$ii] < 168.75: $direction_array["SSE"][] = $WS[$ii]; break; case $WD[$ii] >= 168.75 and $WD[$ii] < 191.25: $direction_array["S"][] = $WS[$ii]; break; case $WD[$ii] >= 191.25 and $WD[$ii] < 213.75: $direction_array["SSW"][] = $WS[$ii]; break; case $WD[$ii] >= 213.75 and $WD[$ii] < 236.25: $direction_array["SW"][] = $WS[$ii]; break; case $WD[$ii] >= 236.25 and $WD[$ii] < 258.75: $direction_array["WSW"][] = $WS[$ii]; break; case $WD[$ii] >= 258.75 and $WD[$ii] < 281.25: $direction_array["W"][] = $WS[$ii]; break; case $WD[$ii] >= 281.25 and $WD[$ii] < 303.75: $direction_array["WNW"][] = $WS[$ii]; break; case $WD[$ii] >= 303.75 and $WD[$ii] < 326.25: $direction_array["NW"][] = $WS[$ii]; break; case $WD[$ii] >= 326.25 and $WD[$ii] < 348.75: $direction_array["NNW"][] = $WS[$ii]; break; } } $direction_keys = array_keys($direction_array); $max_wind = round(max($WS), 0); $num_data = count($WS); $wind_range_max = $max_wind < 20 ? 25 : $max_wind; $data_range_array = array(1, 5, 10, 15, 20, $wind_range_max); foreach ($direction_keys as $direction) { for ($ii = 0; $ii <= 5; $ii++) { $count_data[$ii] = 0; } $raw_data = $direction_array[$direction]; foreach ($raw_data as $temp_speed) { if ($temp_speed >= 0 and $temp_speed < $data_range_array[0]) { $count_data[0]++; } elseif ($temp_speed >= $data_range_array[0] and $temp_speed < $data_range_array[1]) { $count_data[1]++; } elseif ($temp_speed >= $data_range_array[1] and $temp_speed < $data_range_array[2]) { $count_data[2]++; } elseif ($temp_speed >= $data_range_array[2] and $temp_speed < $data_range_array[3]) { $count_data[3]++; } elseif ($temp_speed >= $data_range_array[3] and $temp_speed < $data_range_array[4]) { $count_data[4]++; } elseif ($temp_speed >= $data_range_array[4]) { $count_data[5]++; } } for ($ii = 0; $ii <= 5; $ii++) { $plot_data[$direction][$ii] = 0; } for ($ii = 0; $ii <= 5; $ii++) { $plot_data[$direction][$ii] = round($count_data[$ii] / $num_data * 100, 2); } } return $plot_data; }
default: $order_by = MessageService::DATE; $order_type = "DESC"; break; } //Creo il MessageService e prendo i messaggi $ms = new MessageService($currentUser['id']); $messages = $ms->getFolder($folder, $page, $order_type, $order_by); //Array contenente i dati del json $array = array(); //Creo i dati della paginazione $pag = new Pagination($ms->getFolderCountMessages($folder), MessageService::MESSAGE_FOR_PAGE, $page); $array['pagination'] = $pag->getNavigator("default.html", "javascript:Messages.goToPage(#PAGE#);"); $array['messages'] = array(); foreach ($messages as $m) { $date = DateUtils::GetNice($m['date_tm']); $q = DB::FindOne("SELECT user FROM users WHERE id = " . $m[$to_field] . " LIMIT 1"); $to_from = $m->isMultiple() && $folder == MessageService::SENT ? 'Tutti i membri' : $q['user']; $delete_restore = ''; if ($folder == MessageService::INBOX) { $delete_restore = 'C'; } else { if ($folder == MessageService::DELETED) { $delete_restore = 'R'; } } $array['messages'][] = array("date" => $date, "to_from" => $to_from, "delete_restore" => $delete_restore, "id" => $m['id'], "subject" => $m->getRaw('subject'), "viewed" => $m['viewed'] == 1, "important" => $m['important'] == 1); } $response->set('value', $array); $response->setSuccess(true); $response->send();
public function isValid() { global $systemConfiguration; $this->errors = array(); if (strlen(trim($this->dateFormat)) == 0) { $this->setError(SEARCH_CRITERIA_DATE_FORMAT_INVALID); return false; } if (strlen(trim($this->checkInDate)) == 0) { $this->setError(SEARCH_CRITERIA_CHECK_IN_REQ); return false; } else { if (!DateUtils::isValidDate($this->checkInDate, $systemConfiguration->getDateFormat())) { $this->setError(SEARCH_CRITERIA_CHECK_IN_INVALID); return false; } } $currentDate = getdate(); if (!DateUtils::getNumericDate($this->checkInDate, $systemConfiguration->getDateFormat()) < intval($currentDate['year'] . $currentDate['mon'] . $currentDate['mday'])) { $this->setError(SEARCH_CRITERIA_CHECK_IN_BEFORE_TODAY); return false; } if (strlen(trim($this->checkOutDate)) == 0) { $this->setError(SEARCH_CRITERIA_CHECK_OUT_REQ); return false; } else { if (!DateUtils::isValidDate($this->checkOutDate, $systemConfiguration->getDateFormat())) { $this->setError(SEARCH_CRITERIA_CHECK_OUT_INVALID); return false; } } if (intval(DateUtils::getNumericDate($this->checkInDate)) > intval(DateUtils::getNumericDate($this->checkOutDate))) { $this->setError(SEARCH_CRITERIA_IN_BEFORE_OUT); return false; } else { if ($this->getNightCountPrivate(true) < $systemConfiguration->getMinimumNightCount()) { $this->setError(SEARCH_CRITERIA_MIN_BOOKING_PART_1 . $systemConfiguration->getMinimumNightCount() . SEARCH_CRITERIA_MIN_BOOKING_PART_2); return false; } } if (strlen(trim($this->adultsCount)) == 0) { $this->setError(SEARCH_CRITERIA_ADULTS_REQ); return false; } else { if (!is_int($this->adultsCount)) { $this->setError(SEARCH_CRITERIA_ADULTS_INVALID); return false; } else { if (intval($this->adultsCount) <= 0) { $this->setError(SEARCH_CRITERIA_ADULTS_INVALID); return false; } } } if (strlen(trim($this->childrenCount)) == 0) { $this->setError(SEARCH_CRITERIA_ADULTS_REQ); return false; } else { if (!is_int($this->childrenCount)) { $this->setError(SEARCH_CRITERIA_ADULTS_INVALID); return false; } } return sizeof($this->errors) == 0; }
public static function parse($filePath, $folderSeq) { //$content = file("../files/AQMS.WQD"); $content = file($filePath); $numLines = count($content); $lineRow = 0; for ($i = 0; $i < $numLines; $i++) { if (trim($content[$i]) == "") { } else { $lineRow = $i; $i = $numLines; } } //$channelNumbers = explode(',', trim($content[$lineRow])); // $lineRow = $lineRow +1; // $channelNames = explode(',', trim($content[$lineRow])); // $totalChannels = count($channelNumbers); $arrayCount = 0; $WQDDataArray = new ArrayObject(); $numLines = count($content); $lineRow = $lineRow + 1; for ($i = $lineRow; $i < $numLines; $i++) { $WQDData = new WQDData(); $line = trim($content[$i]); $lineVals = explode(',', $line); $totalChannels = (count($lineVals) - 3) / 3; $reportNo = $lineVals[1]; if ($reportNo != "1") { continue; } $dateStr = $lineVals[2]; $dated = new DateTime($dateStr); //calculating first channel value $channels = array(); $varLocation = 4; for ($channelNo = 1; $channelNo <= $totalChannels; $channelNo++) { $channelValue = $lineVals[$varLocation++]; $channelStatus = $lineVals[$varLocation++]; $channelInfo = array(); $channelInfo['value'] = $channelValue; $channelInfo['status'] = $channelStatus; $channels[$channelNo] = $channelInfo; $varLocation++; } //foreach($channelNumbers as $channel){ // if($varLocation != 1){ // $channelValue = $lineVals[$varLocation]; // $channelStatus = $lineVals[$varLocation+1]; // $varLocation = $varLocation +2; // }else{ // $varLocation++; // } // $channelInfo = array(); // $channelInfo['value'] = $channelValue; // $channelInfo['status'] = $channelStatus; // $channels[$channel] = $channelInfo; // } //$checkSum = $lineVals[$varLocation]; $WQDData->setReportNo($reportNo); $WQDData->setFolderSeq($folderSeq); $WQDData->setDataDate(DateUtils::getSQLDateFromDateObj($dated)); $WQDData->setChannels($channels); $WQDData->setTotalChannels($totalChannels); $WQDData->setChecksum(0); $WQDDataArray[$arrayCount] = $WQDData; $arrayCount = $arrayCount + 1; } return $WQDDataArray; }
private function prepareAllFiltersCommand(&$command) { if ($this->fromDate != "") { $command->andWhere("ticket_events.event_recorded_date >= '" . DateUtils::getSQLDateStringFromDateStr($this->fromDate) . "'"); } if ($this->toDate != "") { $command->andWhere("ticket_events.event_recorded_date <= '" . DateUtils::getSQLDateStringFromDateStr($this->toDate) . "'"); } if (isset($this->exclusiveDomainID) && $this->exclusiveDomainID > 0) { $command->andWhere("ticket.subdomain_id IS NULL AND ticket.domain_id = " . $this->exclusiveDomainID); } if (isset($this->agregatedDomainID) && $this->agregatedDomainID > 0) { $command->andWhere("ticket.domain_id = " . $this->agregatedDomainID); } if (isset($this->subdomainID) && $this->subdomainID > 0) { $command->andWhere("ticket.subdomain_id = " . $this->subdomainID); } if (isset($this->assigned_domain_mentor_id) && $this->assigned_domain_mentor_id > 0) { $command->andWhere("ticket.assign_user_id = " . $this->assigned_domain_mentor_id); } else { if (isset($this->assigned_project_mentor_id) && $this->assigned_project_mentor_id > 0) { $command->andWhere("ticket.assign_user_id = " . $this->assigned_project_mentor_id); } else { if (isset($this->assigned_personal_mentor_id) && $this->assigned_personal_mentor_id > 0) { $command->andWhere("ticket.assign_user_id = " . $this->assigned_personal_mentor_id); } } } if (isset($this->mentee_id) && $this->mentee_id > 0) { $command->andWhere("ticket.creator_user_id = " . $this->mentee_id); } if (isset($this->assigned_project_id) && $this->assigned_project_id > 0) { $command->andWhere("ticket.assigned_project_id = " . $this->assigned_project_id); } if (isset($this->mentee_id) && $this->mentee_id > 0) { $command->andWhere("ticket.creator_user_id = " . $this->mentee_id); } }
from_or_to : stringa 'A' o 'Da' date : data dell'invio del messaggio (formattata in maniera leggibile) discursive_date: data dell'invio del messaggio (gg/mm/yy HH:mm) important : true o false se il messaggio è importante o no message_html : testo del messaggio (formattato in HTML) message_plain : testo del messaggio (non formattato) reply : true o false se bisonga mostrare il bottone rispondi o no from_to_user : nome dell'utente che ha inviato o ricevuto il messaggio */ require_once "__inc__.php"; $response = new RestfulResponse("json"); $r = ''; $id = $_POST['id']; validate_num($id); $ms = new MessageService($currentUser['id']); $m = $ms->getMessage($id); if ($m['to_id'] == $currentUser['id']) { $ms->viewed($id); } $from_to = 'A'; $user = '******'; $write = ""; if ($m['to_id'] == $currentUser['id']) { $from_to = 'Da'; $user = '******'; } $user = DB::FindOne("SELECT user FROM users WHERE id=" . $m[$user] . " LIMIT 1"); $array = array("subject" => $m->getRaw('subject'), "from_or_to" => $from_to, "date" => DateUtils::GetNice($m['date_tm']), "discursive_date" => DateUtils::GetDiscursive($m['date_tm']), "important" => $m->isImportant(), "multiple" => $m->isMultiple(), "message_html" => Text::MessageToHtml($m->getRaw('message')), "message_plain" => $m->getRaw('message'), "reply" => $m['to_id'] == $currentUser['id'], "from_to_user" => $user['user']); $response->set('value', $array); $response->setSuccess(true); $response->send();
foreach ($folders as $folder) { $folSeq = $folder->getSeq(); $toDate = new DateTime(); $toDateStr = DateUtils::getSQLDateFromDateObj($toDate); $fromDate = new DateTime(); $latestDataRows = $WQDS->getChannelsLatestInfo($folSeq); if (count($latestDataRows) > 0) { $toDateStr = $latestDataRows['dated']; $fromDate = new DateTime($latestDataRows['dated']); } echo "To:" . $fromDate->format('Y-m-d H:i:s') . "<br>\n"; echo "FolderSeq:" . $folSeq . " FolderName:" . $folder->getFolderName() . "<br>\n"; $fromDate->modify('-1 day'); echo "From:" . $fromDate->format('Y-m-d H:i:s') . "<br>\n"; // $fromDate->add(DateInterval::createFromDateString('-1Day')); $fromDateStr = DateUtils::getSQLDateFromDateObj($fromDate); $dataRows = $WQDS->getAllDataByFol($fromDateStr, $toDateStr, $folSeq); if (count($dataRows) > 1) { $channelConfigs = $CCDS->FindByFolder($folSeq); $totalChannels = count($channelConfigs); $repStr = " CO O3 NO NO2 NOx NH3 SO2 Ben Tol PXY\r\n"; $repStr .= " mg/m³µg/m³ µg/m³ µg/m³ µg/m³µg/m³ µg/m³ µg/m³ µg/m³ µg/m³\r\n"; $matRepStr = " PM2.5 PM10 AT RH WS WD VWS BP SR\r\n"; $matRepStr .= " µg/m³ µg/m³ °C % m/s deg m/s mmHg W/m²\r\n"; foreach ($dataRows as $row) { $dated = new DateTime($row['wqdfiledatadated']); $repStr .= " " . $dated->format("d/m/y H:i"); $matRepStr .= "" . $dated->format("d/m/Y H:i"); foreach ($channelConfigs as $channelConfiguration) { $chNo = $channelConfiguration->getChannelNumber(); $chUnit = $channelConfiguration->getChannelUnit();
private function getDataJSON($fromDate, $toDate, $folSeq, $timeInterval, $channelNoArr, $periodType, $exemptions, $stationType) { if (strpos($timeInterval, 'hours') !== false) { $timeInterval = "1hour"; } $CCDS = ChannelConfigurationDataStore::getInstance(); $ChannelsInfo = $CCDS->FindByFolderAndChannelNos($folSeq, $channelNoArr); $chArr = new ArrayObject(); $chNumbersArr = array(); foreach ($ChannelsInfo as $channel) { $channelUnit = $channel->getChannelUnit(); $channelName = $channel->getChannelName(); if (ConvertorUtils::getPrescribedUnit($channelName) != null) { $channelUnit = ConvertorUtils::getPrescribedUnit($channelName); } $channelUnit = mb_check_encoding($channelUnit, 'UTF-8') ? $channelUnit : utf8_encode($channelUnit); $chArr[$channelName] = $channelUnit; array_push($chNumbersArr, $channel->getChannelNumber()); } $jsonData['channels'] = $chArr; $WQDS = WQDDataDataStore::getInstance(); $WQDStackDS = WQDStackDataStore::getInstance(); $allDatesData = array(); $dataArray = null; //make special stack call here to the different datastore with same api structure $dataArray = null; if ($stationType == "stack" || $stationType == "effluent") { $dataArray = $WQDStackDS->getChannels($fromDate, $toDate, $folSeq, $channelNoArr, $timeInterval); } else { $dataArray = $WQDS->getChannels($fromDate, $toDate, $folSeq, $channelNoArr, $timeInterval); } foreach ($dataArray as $data) { $channelData = array(); $dated = $data['wqdfiledatadated']; $chValues = array(); $chStatuses = array(); $cnt = (count($data) - 2) / 4; // divided by 2 becos array produces both channelname and int values for ($i = 0; $i < $cnt; $i++) { $vl = (double) $data["ch" . $channelNoArr[$i] . "value"]; if ($vl < 0 || $vl == NULL) { $vl = "n.o"; } $isDateExempted = false; foreach ($exemptions as $exem) { $exemption = new Exemption(); $exemption = $exem; $isDateExempted = DateUtils::isDateInBetween($exemption->getFromDateRange(), $exemption->getToDateRange(), $dated); if ($isDateExempted) { $chNo = $channelNoArr[$i]; $exemptedChannelsNos = $exemption->getChannelNumbers(); if (in_array($chNo, $exemptedChannelsNos)) { $vl = StringUtils::$exemptedString; } } } array_push($chValues, $vl); array_push($chStatuses, (double) $data["ch" . $channelNoArr[$i] . "status"]); } //$channelData['values'] = $chValues; $allDatesData[strtotime($dated)]['channelValue'] = $chValues; $allDatesData[strtotime($dated)]['channelStatuses'] = $chStatuses; //array_push($allDatesData,$channelData); } $jsonData['data'] = $allDatesData; return $jsonData; }
/** * Initialize $UTC_TIMEZONE */ public static function __init() { DateUtils::$UTC_TIMEZONE = new \DateTimeZone("UTC"); }