You are here

function recipe_duration_iso8601 in Recipe 7.2

Same name and namespace in other branches
  1. 8.2 recipe.module \recipe_duration_iso8601()
  2. 7 recipe.module \recipe_duration_iso8601()

Returns a duration string in ISO 8601 format.

Parameters

$duration: An integer or array with 'value' element representing a time duration.

Return value

string A string representing a time duration in ISO 8601 format.

1 call to recipe_duration_iso8601()
theme_recipe_summary in ./recipe.module
Returns HTML for displaying the recipe summary box.
1 string reference to 'recipe_duration_iso8601'
recipe_rdf_mapping in ./recipe.module
Implements hook_rdf_mapping().

File

./recipe.module, line 1413
Contains functions for Recipe node CRUD and display.

Code

function recipe_duration_iso8601($duration = 0) {
  if (is_array($duration) && isset($duration['value'])) {
    $duration = $duration['value'];
  }
  $hours = floor($duration / 60);
  $minutes = $duration % 60;
  $output = '';
  if ($hours > 0) {
    $output .= $hours . 'H';
  }
  if ($minutes > 0) {
    $output .= $minutes . 'M';
  }
  return empty($output) ? 'PT0M' : 'PT' . $output;
}