public function get($id) { $rtn = null; try { $sem = $this->dbo->fetchById($id); $exp = CalemText::parseServerDateTime($sem['expire_time']); $rtn = new CalemSemaphore($id, $exp); } catch (CalemDboDataNotFoundException $e) { } return $rtn; }
/** * Figure out next time due */ public function updateNextDueTime($jobRow) { $schedDay = CalemScheduleInfo::decode($jobRow['release_day']); $schedTime = CalemScheduleInfo::decode($jobRow['release_time']); $dueTime = CalemText::parseServerDateTime($jobRow['time_due']); $newTime = $schedTime->getNextDueTime($dueTime, $schedDay); try { $this->dbo->setValue('time_due', CalemText::getServerDateTime($newTime)); $this->dbo->setIdForUpdate($jobRow['id']); $this->dbo->update(); } catch (Exception $e) { $this->logger->error("Error in updating job row=" . var_export($jobRow, true) . ", msg=" . $e->getMessage()); } }
/** * Format DateTime string */ public static function formatDateTimeString($str) { if (!$str) { return null; } $dt = CalemText::parseServerDateTime($str); //Got to neutral time format. $datefmt = CalemText::getDateTimeFormat(); if (substr($str, 11) == '00:00:00') { $rtn = gmdate($datefmt, $dt); } else { $rtn = date($datefmt, $dt); } return $rtn; }
public function getSemaphore() { try { $row = $this->semDbo->fetchById($this->conf['semaphore_id']); if ($row['expiration']) { $time = CalemText::parseServerDateTime($row['expiration']); } else { $time = 0; } if ($time > mktime()) { if ($this->logger->isInfoEnabled()) { $this->logger->info("Cannot start wo generation, semaphore is not expired: " . date('Y-m-d H:i:s', $time)); } return false; } $this->extendSemaphore(); } catch (CalemDboDataNotFoundException $ex) { $this->semDbo->setChangeBulk(array('id' => $this->conf['semaphore_id'], 'expiration' => CalemText::getServerDateTime($this->getSemExpiration()))); $this->semDbo->insert(); } return true; }