Skip to content

Commit

Permalink
Converts some utils.php functions to UTC.
Browse files Browse the repository at this point in the history
Converts unixtime() to use gmmktime() instead of mktime().
Converts unix2mythtime() to use gmtime() instead of time().
Adds "UTC" parameter to myth2unixtime()'s strtotime().
Removes unix2gmtmythtime(time) since it now does exactly what unix2mythtime() does.
  • Loading branch information
daniel-kristjansson committed May 31, 2012
1 parent 8c43d8d commit ee941be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
22 changes: 7 additions & 15 deletions includes/utils.php
Expand Up @@ -161,12 +161,12 @@ function nice_length($length) {
* Converts an sql timestamp into unixtime
/**/
function unixtime($sql_timestamp) {
return mktime(substr($sql_timestamp, 8, 2), // hour
substr($sql_timestamp, 10, 2), // minute
substr($sql_timestamp, 12, 2), // second
substr($sql_timestamp, 4, 2), // month
substr($sql_timestamp, 6, 2), // day
substr($sql_timestamp, 0, 4)); // year
return gmmktime(substr($sql_timestamp, 8, 2), // hour
substr($sql_timestamp, 10, 2), // minute
substr($sql_timestamp, 12, 2), // second
substr($sql_timestamp, 4, 2), // month
substr($sql_timestamp, 6, 2), // day
substr($sql_timestamp, 0, 4)); // year
}

/**
Expand Down Expand Up @@ -315,20 +315,12 @@ function fequals($lhs, $rhs) {
function myth2unixtime($mythtime) {
if (strlen($mythtime) < 1)
return '';
return strtotime(str_replace('T', ' ', $mythtime));
return strtotime(str_replace('T', ' ', $mythtime), "UTC");
}

/**
* Converts a unix timestamp into a myth timestamp
/**/
function unix2mythtime($time) {
return date('Y-m-d\TH:i:s', $time);
}

/**
* Converts a unix timestamp into a myth timestamp
/**/
function unix2gmtmythtime($time) {
return gmdate('Y-m-d\TH:i:s', $time);
}

2 changes: 1 addition & 1 deletion modules/tv/classes/Program.php
Expand Up @@ -488,7 +488,7 @@ public function thumb_url($width=160, $height=120, $secs_in=-1) {
public static function get_preview_pixmap($hostname, $chanid, $starttime, $width=160, $height=120, $secs_in=null) {

return MythBackend::find($hostname)->httpRequest('Content/GetPreviewImage', array('ChanId' => $chanid,
'StartTime' => unix2gmtmythtime($starttime),
'StartTime' => unix2mythtime($starttime),
'Height' => $height,
'Width' => $width));
}
Expand Down

0 comments on commit ee941be

Please sign in to comment.