Merge branch '2.5.x' of github.com:sourcefabric/Airtime into 2.5.x
This commit is contained in:
commit
f2fe04ba1d
|
@ -112,71 +112,6 @@ class Application_Common_DateHelper
|
||||||
return $now;
|
return $now;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the internal timestamp of the object.
|
|
||||||
*/
|
|
||||||
function setDate($dateString)
|
|
||||||
{
|
|
||||||
$dateTime = new DateTime($dateString, new DateTimeZone("UTC"));
|
|
||||||
$this->_dateTime = $dateTime->getTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the epoch timestamp difference from "now" to the beginning of today.
|
|
||||||
*/
|
|
||||||
function getNowDayStartDiff()
|
|
||||||
{
|
|
||||||
$dayStartTs = ((int)($this->_dateTime/86400))*86400;
|
|
||||||
return $this->_dateTime - $dayStartTs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the epoch timestamp difference from "now" to the end of today.
|
|
||||||
*/
|
|
||||||
function getNowDayEndDiff()
|
|
||||||
{
|
|
||||||
$dayEndTs = ((int)(($this->_dateTime+86400)/86400))*86400;
|
|
||||||
return $dayEndTs - $this->_dateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEpochTime()
|
|
||||||
{
|
|
||||||
return $this->_dateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function TimeDiff($time1, $time2)
|
|
||||||
{
|
|
||||||
return strtotime($time2) - strtotime($time1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function TimeAdd($time1, $time2)
|
|
||||||
{
|
|
||||||
return strtotime($time2) + strtotime($time1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function ConvertMSToHHMMSSmm($time)
|
|
||||||
{
|
|
||||||
$hours = floor($time / 3600000);
|
|
||||||
$time -= 3600000*$hours;
|
|
||||||
|
|
||||||
$minutes = floor($time / 60000);
|
|
||||||
$time -= 60000*$minutes;
|
|
||||||
|
|
||||||
$seconds = floor($time / 1000);
|
|
||||||
$time -= 1000*$seconds;
|
|
||||||
|
|
||||||
$ms = $time;
|
|
||||||
|
|
||||||
if (strlen($hours) == 1)
|
|
||||||
$hours = "0".$hours;
|
|
||||||
if (strlen($minutes) == 1)
|
|
||||||
$minutes = "0".$minutes;
|
|
||||||
if (strlen($seconds) == 1)
|
|
||||||
$seconds = "0".$seconds;
|
|
||||||
|
|
||||||
return $hours.":".$minutes.":".$seconds.".".$ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function formats a time by removing seconds
|
* This function formats a time by removing seconds
|
||||||
*
|
*
|
||||||
|
@ -202,16 +137,6 @@ class Application_Common_DateHelper
|
||||||
return $p_dateTime;
|
return $p_dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDateFromTimestamp($p_dateTime){
|
|
||||||
$explode = explode(" ", $p_dateTime);
|
|
||||||
return $explode[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTimeFromTimestamp($p_dateTime){
|
|
||||||
$explode = explode(" ", $p_dateTime);
|
|
||||||
return $explode[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Given a track length in the format HH:MM:SS.mm, we want to
|
/* Given a track length in the format HH:MM:SS.mm, we want to
|
||||||
* convert this to seconds. This is useful for Liquidsoap which
|
* convert this to seconds. This is useful for Liquidsoap which
|
||||||
* likes input parameters give in seconds.
|
* likes input parameters give in seconds.
|
||||||
|
@ -240,30 +165,6 @@ class Application_Common_DateHelper
|
||||||
$totalSeconds = ($hours*3600 + $minutes*60 + $seconds).".$ms";
|
$totalSeconds = ($hours*3600 + $minutes*60 + $seconds).".$ms";
|
||||||
return round($totalSeconds, 3);
|
return round($totalSeconds, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function ConvertToUtcDateTime($p_dateString, $timezone=null){
|
|
||||||
if (isset($timezone)) {
|
|
||||||
$dateTime = new DateTime($p_dateString, new DateTimeZone($timezone));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$dateTime = new DateTime($p_dateString, new DateTimeZone(Application_Model_Preference::GetTimezone()));
|
|
||||||
}
|
|
||||||
$dateTime->setTimezone(new DateTimeZone("UTC"));
|
|
||||||
|
|
||||||
return $dateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Example input: "00:02:32.746562". Output is a DateInterval object
|
|
||||||
* representing that 2 minute, 32.746562 second interval.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function getDateIntervalFromString($p_interval){
|
|
||||||
list($hour_min_sec, $subsec) = explode(".", $p_interval);
|
|
||||||
list($hour, $min, $sec) = explode(":", $hour_min_sec);
|
|
||||||
|
|
||||||
return new DateInterval("PT{$hour}H{$min}M{$sec}S");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true or false depending on input is wether in
|
* returns true or false depending on input is wether in
|
||||||
|
|
|
@ -594,33 +594,6 @@ SQL;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the difference between two times in the format .
|
|
||||||
* "HH:MM:SS.mmmmmm" Note: currently only supports calculating .
|
|
||||||
* millisec differences .
|
|
||||||
*
|
|
||||||
* @param string $p_time1
|
|
||||||
* @param string $p_time2
|
|
||||||
* @return double
|
|
||||||
*/
|
|
||||||
private static function TimeDiff($p_time1, $p_time2)
|
|
||||||
{
|
|
||||||
$parts1 = explode(".", $p_time1);
|
|
||||||
$parts2 = explode(".", $p_time2);
|
|
||||||
$diff = 0;
|
|
||||||
if ( (count($parts1) > 1) && (count($parts2) > 1) ) {
|
|
||||||
$millisec1 = substr($parts1[1], 0, 3);
|
|
||||||
$millisec1 = str_pad($millisec1, 3, "0");
|
|
||||||
$millisec1 = intval($millisec1);
|
|
||||||
$millisec2 = substr($parts2[1], 0, 3);
|
|
||||||
$millisec2 = str_pad($millisec2, 3, "0");
|
|
||||||
$millisec2 = intval($millisec2);
|
|
||||||
$diff = abs($millisec1 - $millisec2)/1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of schedule items from cc_schedule table. Tries
|
* Returns an array of schedule items from cc_schedule table. Tries
|
||||||
* to return at least 3 items (if they are available). The parameters
|
* to return at least 3 items (if they are available). The parameters
|
||||||
|
|
|
@ -282,13 +282,13 @@ class Application_Model_ShowBuilder
|
||||||
$row["starts"] = $schedStartDT->format("H:i:s");
|
$row["starts"] = $schedStartDT->format("H:i:s");
|
||||||
$row["ends"] = $schedEndDT->format("H:i:s");
|
$row["ends"] = $schedEndDT->format("H:i:s");
|
||||||
|
|
||||||
$cue_out = Application_Common_DateHelper::calculateLengthInSeconds($p_item['cue_out']);
|
$cue_out = Application_Common_DateHelper::playlistTimeToSeconds($p_item['cue_out']);
|
||||||
$cue_in = Application_Common_DateHelper::calculateLengthInSeconds($p_item['cue_in']);
|
$cue_in = Application_Common_DateHelper::playlistTimeToSeconds($p_item['cue_in']);
|
||||||
|
|
||||||
$run_time = $cue_out-$cue_in;
|
$run_time = $cue_out-$cue_in;
|
||||||
|
|
||||||
$formatter = new LengthFormatter(Application_Common_DateHelper::ConvertMSToHHMMSSmm($run_time*1000));
|
$formatter = new LengthFormatter(Application_Common_DateHelper::secondsToPlaylistTime($run_time));
|
||||||
$row['runtime'] = $formatter->format();
|
$row['runtime'] = $formatter->format();
|
||||||
|
|
||||||
$row["title"] = htmlspecialchars($p_item["file_track_title"]);
|
$row["title"] = htmlspecialchars($p_item["file_track_title"]);
|
||||||
$row["creator"] = htmlspecialchars($p_item["file_artist_name"]);
|
$row["creator"] = htmlspecialchars($p_item["file_artist_name"]);
|
||||||
|
|
|
@ -998,8 +998,13 @@ SQL;
|
||||||
$datePeriod = $this->getDatePeriod($start, $timezone, $last_show,
|
$datePeriod = $this->getDatePeriod($start, $timezone, $last_show,
|
||||||
$repeatInterval, $populateUntil);
|
$repeatInterval, $populateUntil);
|
||||||
|
|
||||||
$utcLastShowDateTime = $last_show ?
|
if ($last_show) {
|
||||||
Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
$utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
|
||||||
|
$utcLastShowDateTime->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$utcLastShowDateTime = null;
|
||||||
|
}
|
||||||
|
|
||||||
$previousDate = clone $start;
|
$previousDate = clone $start;
|
||||||
|
|
||||||
|
@ -1093,8 +1098,13 @@ SQL;
|
||||||
|
|
||||||
$this->repeatType = $showDay->getDbRepeatType();
|
$this->repeatType = $showDay->getDbRepeatType();
|
||||||
|
|
||||||
$utcLastShowDateTime = $last_show ?
|
if ($last_show) {
|
||||||
Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
$utcLastShowDateTime = new DateTime($last_show, new DateTimeZone($timezone));
|
||||||
|
$utcLastShowDateTime->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$utcLastShowDateTime = null;
|
||||||
|
}
|
||||||
|
|
||||||
while ($start->getTimestamp() < $end->getTimestamp()) {
|
while ($start->getTimestamp() < $end->getTimestamp()) {
|
||||||
list($utcStartDateTime, $utcEndDateTime) = $this->createUTCStartEndDateTime(
|
list($utcStartDateTime, $utcEndDateTime) = $this->createUTCStartEndDateTime(
|
||||||
|
|
Loading…
Reference in New Issue