CC-2289:Differentiate between time and duration

- End date and time is added
- duration field is readonly now and is autocalculated
- now playing duration field format is changed( 0h 0m 0s )
- removed millisecond from start and end time in now playing
This commit is contained in:
james 2011-06-03 14:53:01 -04:00
parent 143e68bd56
commit 1dabbacca2
7 changed files with 207 additions and 32 deletions

View file

@ -433,6 +433,45 @@ class Show {
return $startTime;
}
}
/**
* Get the end date of the current show.
* Note that this is not the end date of repeated show
*
* @return string
* The end date in the format YYYY-MM-DD
*/
public function getEndDate(){
$startDate = $this->getStartDate();
$startTime = $this->getStartTime();
$duration = $this->getDuration();
$startDateTime = new DateTime($startDate.' '.$startTime);
$duration = explode(":", $duration);
$endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M'));
return $endDate->format('Y-m-d');
}
/**
* Get the end time of the current show.
*
* @return string
* The start time in the format HH:MM:SS
*/
public function getEndTime(){
$startDate = $this->getStartDate();
$startTime = $this->getStartTime();
$duration = $this->getDuration();
$startDateTime = new DateTime($startDate.' '.$startTime);
$duration = explode(":", $duration);
$endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M'));
return $endDate->format('H:i:s');
}
/**
* Indicate whether the starting point of the show is in the
@ -535,9 +574,14 @@ class Show {
}
}
public function getDuration(){
public function getDuration($format=false){
$showDay = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->findOne();
return $showDay->getDbDuration();
if(!$format){
return $showDay->getDbDuration();
}else{
$info = explode(':',$showDay->getDbDuration());
return ($info[0] != 0 ? intval($info[0]).'h'.' ' : '').($info[1] != 0 ? intval($info[1]).'m' : '');
}
}
public function getShowDays(){