You are here

function video_views_handler_field_playtime_seconds in Video 6

Same name and namespace in other branches
  1. 5 views_video.inc \video_views_handler_field_playtime_seconds()

Handler to to render the correct playtime for the video in a field

1 string reference to 'video_views_handler_field_playtime_seconds'
video_views_tables in ./views_video.inc
Implementation of hook_views_tables

File

./views_video.inc, line 202

Code

function video_views_handler_field_playtime_seconds($fieldinfo, $fielddata, $value, $data) {
  $seconds = $value;
  $hms = _video_sec2hms($seconds);

  // Pad the minutes / seconds with a leading "0", if
  // necessary
  if ($hms['hours'] > 0) {
    $hms['minutes'] = str_pad($hms['minutes'], 2, '0', STR_PAD_LEFT);
  }
  $hms['seconds'] = str_pad($hms['seconds'], 2, '0', STR_PAD_LEFT);
  $out = '';
  if ($hms['hours'] > 0) {
    $out .= $hms['hours'] . ":";
  }
  $out .= $hms['minutes'] . ":" . $hms['seconds'];
  return t($out);
}