Replace all timestamp strings with constant

This commit is contained in:
Duncan Sommerville 2015-06-26 14:42:52 -04:00
parent 9d60a3d130
commit 5fe70754bd
23 changed files with 137 additions and 132 deletions

View file

@ -314,7 +314,7 @@ class Application_Service_CalendarService
//check if we are moving a recorded show less than 1 hour before any of its own rebroadcasts.
$rebroadcasts = CcShowInstancesQuery::create()
->filterByDbOriginalShow($this->ccShow->getDbId())
->filterByDbStarts($minRebroadcastStart->format('Y-m-d H:i:s'), Criteria::LESS_THAN)
->filterByDbStarts($minRebroadcastStart->format(DEFAULT_TIMESTAMP_FORMAT), Criteria::LESS_THAN)
->find();
if (count($rebroadcasts) > 0) {

View file

@ -28,8 +28,8 @@ class Application_Service_HistoryService
$paramMap = array();
$sqlTypes = $this->getSqlTypes();
$start = $startDT->format("Y-m-d H:i:s");
$end = $endDT->format("Y-m-d H:i:s");
$start = $startDT->format(DEFAULT_TIMESTAMP_FORMAT);
$end = $endDT->format(DEFAULT_TIMESTAMP_FORMAT);
$template = $this->getConfiguredItemTemplate();
$fields = $template["fields"];
@ -292,13 +292,13 @@ class Application_Service_HistoryService
//need to display the results in the station's timezone.
$dateTime = new DateTime($result["starts"], $timezoneUTC);
$dateTime->setTimezone($timezoneLocal);
$result["starts"] = $dateTime->format("Y-m-d H:i:s");
$result["starts"] = $dateTime->format(DEFAULT_TIMESTAMP_FORMAT);
//if ends is null we don't want it to default to "now"
if (isset($result["ends"])) {
$dateTime = new DateTime($result["ends"], $timezoneUTC);
$dateTime->setTimezone($timezoneLocal);
$result["ends"] = $dateTime->format("Y-m-d H:i:s");
$result["ends"] = $dateTime->format(DEFAULT_TIMESTAMP_FORMAT);
}
if (isset($result[MDATA_KEY_DURATION])) {
@ -334,8 +334,8 @@ class Application_Service_HistoryService
$mainSqlQuery = "";
$paramMap = array();
$start = $startDT->format("Y-m-d H:i:s");
$end = $endDT->format("Y-m-d H:i:s");
$start = $startDT->format(DEFAULT_TIMESTAMP_FORMAT);
$end = $endDT->format(DEFAULT_TIMESTAMP_FORMAT);
$paramMap["starts"] = $start;
$paramMap["ends"] = $end;
@ -458,8 +458,8 @@ class Application_Service_HistoryService
}
$shows = Application_Model_Show::getShows($startDT, $endDT);
Logging::info($startDT->format("Y-m-d H:i:s"));
Logging::info($endDT->format("Y-m-d H:i:s"));
Logging::info($startDT->format(DEFAULT_TIMESTAMP_FORMAT));
Logging::info($endDT->format(DEFAULT_TIMESTAMP_FORMAT));
Logging::info($shows);
@ -508,11 +508,11 @@ class Application_Service_HistoryService
//need to display the results in the station's timezone.
$dateTime = new DateTime($result["starts"], $timezoneUTC);
$dateTime->setTimezone($timezoneLocal);
$result["starts"] = $dateTime->format("Y-m-d H:i:s");
$result["starts"] = $dateTime->format(DEFAULT_TIMESTAMP_FORMAT);
$dateTime = new DateTime($result["ends"], $timezoneUTC);
$dateTime->setTimezone($timezoneLocal);
$result["ends"] = $dateTime->format("Y-m-d H:i:s");
$result["ends"] = $dateTime->format(DEFAULT_TIMESTAMP_FORMAT);
}
@ -687,7 +687,7 @@ class Application_Service_HistoryService
$dateTime = new DateTime($value, $timezoneUTC);
$dateTime->setTimezone($timezoneLocal);
$value = $dateTime->format("Y-m-d H:i:s");
$value = $dateTime->format(DEFAULT_TIMESTAMP_FORMAT);
}
$formValues["$prefix{$key}"] = $value;
@ -795,11 +795,11 @@ class Application_Service_HistoryService
$dateTime = new DateTime($values[$prefix."starts"], $timezoneLocal);
$dateTime->setTimezone($timezoneUTC);
$historyRecord->setDbStarts($dateTime->format("Y-m-d H:i:s"));
$historyRecord->setDbStarts($dateTime->format(DEFAULT_TIMESTAMP_FORMAT));
$dateTime = new DateTime($values[$prefix."ends"], $timezoneLocal);
$dateTime->setTimezone($timezoneUTC);
$historyRecord->setDbEnds($dateTime->format("Y-m-d H:i:s"));
$historyRecord->setDbEnds($dateTime->format(DEFAULT_TIMESTAMP_FORMAT));
$templateValues = $values[$prefix."template"];
@ -1157,7 +1157,7 @@ class Application_Service_HistoryService
$fields[] = array("name" => MDATA_KEY_TITLE, "label"=> _("Title"), "type" => TEMPLATE_STRING, "isFileMd" => true); //these fields can be populated from an associated file.
$fields[] = array("name" => MDATA_KEY_CREATOR, "label"=> _("Creator"), "type" => TEMPLATE_STRING, "isFileMd" => true);
$template["name"] = "Log Sheet ".date("Y-m-d H:i:s")." Template";
$template["name"] = "Log Sheet ".date(DEFAULT_TIMESTAMP_FORMAT)." Template";
$template["fields"] = $fields;
return $template;
@ -1178,7 +1178,7 @@ class Application_Service_HistoryService
$fields[] = array("name" => MDATA_KEY_COMPOSER, "label"=> _("Composer"), "type" => TEMPLATE_STRING, "isFileMd" => true);
$fields[] = array("name" => MDATA_KEY_COPYRIGHT, "label"=> _("Copyright"), "type" => TEMPLATE_STRING, "isFileMd" => true);
$template["name"] = "File Summary ".date("Y-m-d H:i:s")." Template";
$template["name"] = "File Summary ".date(DEFAULT_TIMESTAMP_FORMAT)." Template";
$template["fields"] = $fields;
return $template;

View file

@ -177,7 +177,7 @@ class Application_Service_SchedulerService
$showInstanceWithMostRecentSchedule = CcShowInstancesQuery::create()
->filterByDbShowId($showId)
->filterByDbStarts($showsPopulatedUntil->format("Y-m-d H:i:s"), Criteria::LESS_THAN)
->filterByDbStarts($showsPopulatedUntil->format(DEFAULT_TIMESTAMP_FORMAT), Criteria::LESS_THAN)
->filterByDbId($instancsIdsToFill, Criteria::NOT_IN)
->orderByDbStarts(Criteria::DESC)
->limit(1)
@ -266,8 +266,8 @@ class Application_Service_SchedulerService
$item["stream_id"] = "null";
}
$values[] = "(" . "'{$nextStartDT->format("Y-m-d H:i:s")}', " .
"'{$endTimeDT->format("Y-m-d H:i:s")}', " .
$values[] = "(" . "'{$nextStartDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
"'{$endTimeDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
"'{$item["clip_length"]}', " .
"'{$item["fade_in"]}', " . "'{$item["fade_out"]}', " .
"'{$item["cue_in"]}', " . "'{$item["cue_out"]}', " .
@ -293,7 +293,7 @@ class Application_Service_SchedulerService
} //foreach linked instance
//update time_filled and last_scheduled in cc_show_instances
$now = gmdate("Y-m-d H:i:s");
$now = gmdate(DEFAULT_TIMESTAMP_FORMAT);
$whereClause = new Criteria();
$whereClause->add(CcShowInstancesPeer::ID, $instanceIdsToFill, Criteria::IN);
@ -350,7 +350,7 @@ class Application_Service_SchedulerService
$ccShowInstance
->setDbTimeFilled($timeFilled)
->setDbLastScheduled(gmdate("Y-m-d H:i:s"))
->setDbLastScheduled(gmdate(DEFAULT_TIMESTAMP_FORMAT))
->save();
}
}

View file

@ -210,7 +210,7 @@ class Application_Service_ShowFormService
'add_show_end_date_no_repeat' => $showEnd->format("Y-m-d"),
'add_show_end_time' => $showEnd->format("H:i"),
'add_show_duration' => $this->calculateDuration(
$showStart->format("Y-m-d H:i:s"), $showEnd->format("Y-m-d H:i:s"), $timezone),
$showStart->format(DEFAULT_TIMESTAMP_FORMAT), $showEnd->format(DEFAULT_TIMESTAMP_FORMAT), $timezone),
'add_show_timezone' => $timezone,
'add_show_repeats' => 0));

View file

@ -405,12 +405,12 @@ class Application_Service_ShowService
private function getShowDaysInRange($start, $end)
{
$endTimeString = $end->format("Y-m-d H:i:s");
$endTimeString = $end->format(DEFAULT_TIMESTAMP_FORMAT);
if (!is_null($start)) {
$startTimeString = $start->format("Y-m-d H:i:s");
$startTimeString = $start->format(DEFAULT_TIMESTAMP_FORMAT);
} else {
$today_timestamp = new DateTime("now", new DateTimeZone("UTC"));
$startTimeString = $today_timestamp->format("Y-m-d H:i:s");
$startTimeString = $today_timestamp->format(DEFAULT_TIMESTAMP_FORMAT);
}
$c = new Criteria();
@ -462,7 +462,7 @@ AND rebroadcast = 1;
SQL;
Application_Common_Database::prepareAndExecute( $sql, array(
':showId' => $this->ccShow->getDbId(),
':timestamp' => gmdate("Y-m-d H:i:s")), 'execute');
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT)), 'execute');
}
private function deleteAllShowDays($showId)
@ -678,7 +678,7 @@ WHERE date(starts) >= :endDate::DATE
AND show_id = :showId
SQL;
Application_Common_Database::prepareAndExecute($sql, array(
':endDate' => $endDate, ':timestamp' => gmdate("Y-m-d H:i:s"),
':endDate' => $endDate, ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
':showId' => $showId), 'execute');
}
@ -693,7 +693,7 @@ WHERE date(starts) < :newStartDate::DATE
SQL;
Application_Common_Database::prepareAndExecute($sql, array(
":newStartDate" => $newStartDate, ":timestamp" => gmdate("Y-m-d H:i:s"),
":newStartDate" => $newStartDate, ":timestamp" => gmdate(DEFAULT_TIMESTAMP_FORMAT),
":showId" => $showId), "execute");
}
@ -738,7 +738,7 @@ WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDays)
SQL;
Application_Common_Database::prepareAndExecute( $sql, array(
":timestamp" => gmdate("Y-m-d H:i:s"), ":showId" => $showId),
":timestamp" => gmdate(DEFAULT_TIMESTAMP_FORMAT), ":showId" => $showId),
"execute");
}
@ -777,7 +777,7 @@ SQL;
->find();
}
if (gmdate("Y-m-d H:i:s") <= $ccShowInstance->getDbEnds()) {
if (gmdate(DEFAULT_TIMESTAMP_FORMAT) <= $ccShowInstance->getDbEnds()) {
$this->deleteShowInstances($ccShowInstances, $showId);
} else {
throw new Exception("Cannot delete a show instance in the past");
@ -925,7 +925,7 @@ WHERE starts > :timestamp::TIMESTAMP
AND show_id = :showId
SQL;
Application_Common_Database::prepareAndExecute( $sql,
array( ':timestamp' => gmdate("Y-m-d H:i:s"),
array( ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
':showId' => $showId), 'execute');
}
@ -941,9 +941,9 @@ WHERE starts > :timestamp::TIMESTAMP
AND starts != :firstShow
SQL;
Application_Common_Database::prepareAndExecute( $sql,
array( ':timestamp' => gmdate("Y-m-d H:i:s"),
array( ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
':showId' => $showId,
':firstShow' => $firstShow->format("Y-m-d H:i:s")), 'execute');
':firstShow' => $firstShow->format(DEFAULT_TIMESTAMP_FORMAT)), 'execute');
}
/**
@ -1027,7 +1027,7 @@ SQL;
Application_Common_Database::prepareAndExecute($sql,
array(':diff1' => $diff, ':diff2' => $diff,
':showId' => $this->ccShow->getDbId(), ':timestamp' => gmdate("Y-m-d H:i:s")),
':showId' => $this->ccShow->getDbId(), ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT)),
'execute');
}
@ -1040,7 +1040,7 @@ SQL;
*/
private function createRebroadcastInstances($showDay, $showStartDate, $instanceId)
{
$currentUtcTimestamp = gmdate("Y-m-d H:i:s");
$currentUtcTimestamp = gmdate(DEFAULT_TIMESTAMP_FORMAT);
$showId = $this->ccShow->getDbId();
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id=:show_id";
@ -1055,7 +1055,7 @@ SQL;
list($utcStartDateTime, $utcEndDateTime) = $this->createUTCStartEndDateTime(
$showStartDate, $showDay->getDbDuration(), $offset);
if ($utcStartDateTime->format("Y-m-d H:i:s") > $currentUtcTimestamp) {
if ($utcStartDateTime->format(DEFAULT_TIMESTAMP_FORMAT) > $currentUtcTimestamp) {
$ccShowInstance = new CcShowInstances();
$ccShowInstance->setDbShowId($showId);
$ccShowInstance->setDbStarts($utcStartDateTime);
@ -1093,7 +1093,7 @@ SQL;
$origStartDateTime->setTimezone(new DateTimeZone("UTC"));
$ccShowInstance = $this->getInstance($origStartDateTime);
if (!$ccShowInstance) {
throw new Exception("Could not find show instance with start time: ".$origStartDateTime->format("Y-m-d H:i:s"));
throw new Exception("Could not find show instance with start time: ".$origStartDateTime->format(DEFAULT_TIMESTAMP_FORMAT));
}
}
@ -1182,7 +1182,7 @@ SQL;
/* When editing the start/end time of a repeating show, we don't want to
* change shows that are in the past so we check the end time.
*/
if ($newInstance || $ccShowInstance->getDbEnds() > gmdate("Y-m-d H:i:s")) {
if ($newInstance || $ccShowInstance->getDbEnds() > gmdate(DEFAULT_TIMESTAMP_FORMAT)) {
$ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($utcStartDateTime);
$ccShowInstance->setDbEnds($utcEndDateTime);
@ -1277,7 +1277,7 @@ SQL;
/* When editing the start/end time of a repeating show, we don't want to
* change shows that started in the past. So check the start time.
*/
if ($newInstance || $ccShowInstance->getDbStarts() > gmdate("Y-m-d H:i:s")) {
if ($newInstance || $ccShowInstance->getDbStarts() > gmdate(DEFAULT_TIMESTAMP_FORMAT)) {
$ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($utcStartDateTime);
$ccShowInstance->setDbEnds($utcEndDateTime);
@ -1481,7 +1481,7 @@ SQL;
$temp->setTimezone(new DateTimeZone("UTC"));
$ccShowInstance = CcShowInstancesQuery::create()
->filterByDbStarts($temp->format("Y-m-d H:i:s"), Criteria::EQUAL)
->filterByDbStarts($temp->format(DEFAULT_TIMESTAMP_FORMAT), Criteria::EQUAL)
->filterByDbShowId($this->ccShow->getDbId(), Criteria::EQUAL)
//->filterByDbModifiedInstance(false, Criteria::EQUAL)
->filterByDbRebroadcast(0, Criteria::EQUAL)