You are here

function timefield_integer_to_duration in Timefield 7

Same name and namespace in other branches
  1. 1.0.x timefield.module \timefield_integer_to_duration()

Helper function to return duration value from a timefield integer value, in specified format.

Parameters

integer $value: Time value in seconds

string $format: Out format options. Possible options are: -hours -minutes -seconds -time

@return string Integer cast to string or string depending on $format passed.

1 call to timefield_integer_to_duration()
timefield_handler_field_timefield_duration::render in views/timefield_handler_field_timefield_duration.inc
Render the field.

File

./timefield.module, line 1024
Defines a Field API field for time

Code

function timefield_integer_to_duration($value, $format) {
  switch ($format) {
    case 'hours':
      return (string) round($value / 60 / 60, 2);
      break;
    case 'minutes':
      return (string) round($value / 60, 2);
      break;
    case 'seconds':
      return (string) $value;
      break;
    case 'time':
      return date('g:i', mktime(NULL, NULL, $value));
      break;
  }
}