Esempio n. 1
0
 public function helpDatetime()
 {
     print_r('<pre>');
     print_r(dtBreak('2013-07-01 01:12:13'));
 }
Esempio n. 2
0
 function update36Hour($sDatetime, $aOptions)
 {
     /* update10day will fill the temperature difference, percent_rain
      * and the actual_ids column in wu_10day.
      * $sDate is a string in the form of 'Y-m-d'
      * $aOptions
      * @$sDate
      */
     //$this->load->model('wu');
     $this->load->helper('vitaly');
     $aDTbreak = dtBreak($sDatetime);
     $sCurrentDate = $aDTbreak['date']['full'];
     $iCurrentTime = (int) $aDTbreak['time']['H'];
     $aAggdate = $this->aggDay($sCurrentDate);
     if ($aAggdate && array_key_exists($iCurrentTime, $aAggdate['hour'])) {
         //Only write to those that have at least 2 measurements in the hour
         $aCurrentHour = $aAggdate['hour'][$iCurrentTime];
         if ($aOptions['check_complete']) {
             $bComplete = $aCurrentHour['count'] > 1;
         } else {
             $bComplete = TRUE;
         }
         //begin building query
         $sQuery = "UPDATE `wu_hourly` SET";
         if ($aOptions['diff_f_temp'] && $bComplete) {
             $sQuery .= "`diff_f_temp` = (`f_temp`-'" . $aCurrentHour['temp'] . "'), ";
         }
         if ($aOptions['actual_ids']) {
             $sQuery .= "`actual_ids` = '" . $aCurrentHour['ref_ids'] . "', ";
         }
         if ($aOptions['percent_pop'] && $bComplete) {
             $percent = $aCurrentHour['percip']['count'] / $aCurrentHour['count'];
             $sQuery .= "`percent_pop` = " . $percent . ", ";
         }
         //trim last ", "
         $sQuery = substr($sQuery, 0, -2);
         $sQuery .= " WHERE `datetime` = '" . $sDatetime . "'";
         if ($bComplete) {
             $this->db->query($sQuery);
             return $aCurrentHour;
         } else {
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }