Example #1
0
 /**
  * Get the total time.
  *
  * @since 1.3.0
  *
  * @param  string      $format     Optional. The duration format to return. Specify 'machine'
  *                                 for microdata-friendly format. Default: 'human'.
  * @return string|bool $total_time The formatted total time or false on failure.
  */
 public function get_total_time($format = 'human')
 {
     $durations_api = new Simmer_Recipe_Durations();
     $total_time = $durations_api->get_duration('total', $this->id);
     if ($total_time) {
         if ('machine' == $format) {
             $total_time = $durations_api->format_machine_duration($total_time);
         } else {
             $total_time = $durations_api->format_human_duration($total_time);
         }
     }
     /**
      * Filter the total time.
      *
      * @since 1.3.0
      *
      * @param string|bool $total_time The returned time string or false if none set.
      * @param int         $recipe_id  The recipe ID.
      */
     $total_time = apply_filters('simmer_get_recipe_total_time', $total_time, $this->id);
     return $total_time;
 }
Example #2
0
<?php

/**
 * The ingredients meta box HTML.
 *
 * @package Simmer\Ingredients
 */
?>

<?php 
wp_nonce_field('simmer_save_recipe_meta', 'simmer_nonce');
?>

<?php 
// Build the formatted times.
$durations_api = new Simmer_Recipe_Durations();
$prep_time = (int) $durations_api->get_duration('prep', $recipe->ID);
$cook_time = (int) $durations_api->get_duration('cook', $recipe->ID);
$total_time = (int) $durations_api->get_duration('total', $recipe->ID);
if ($prep_time) {
    $prep_h = zeroise(floor($prep_time / 60), 2);
    $prep_m = zeroise($prep_time % 60, 2);
} else {
    $prep_h = '';
    $prep_m = '';
}
if ($cook_time) {
    $cook_h = zeroise(floor($cook_time / 60), 2);
    $cook_m = zeroise($cook_time % 60, 2);
} else {
    $cook_h = '';
Example #3
0
/**
 * Format a given duration to a machine-readable format.
 *
 * @since 1.0.0
 *
 * @param int $time A duration, in minutes.
 * @return string|bool $duration The machine-readable duration or false on failure.
 */
function simmer_format_machine_duration($time)
{
    _simmer_deprecated_function(__FUNCTION__, '1.3.0', 'Simmer_Recipe_Durations::format_machine_duration');
    $durations_api = new Simmer_Recipe_Durations();
    $duration = $durations_api->format_machine_duration($time);
    return $duration;
}