Smarty
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file modifier.duration.php

Documentation is available at modifier.duration.php

  1. <?php
  2. /**
  3.  * Smarty plugin modifier duration
  4.  *
  5.  * Type:     modifier
  6.  * Name:     duration
  7.  * Purpose:  formats a duration from seconds
  8.  *
  9.  * @package Smarty
  10.  * @subpackage plugins
  11.  */
  12.  
  13. /**
  14.  * Function body.
  15.  *
  16.  * @param string $string Number of seconds
  17.  * @return string in format days,hours,minutes,seconds
  18.  */
  19. function smarty_modifier_duration($string)
  20. {
  21.   $result=Array();
  22.   if($string 60*60*24{
  23.     $days floor($string/(60*60*24));
  24.     $result[]="$days days";
  25.     $string $string (60*60*24);
  26.   }
  27.   if($string 60*60{
  28.     $hours floor($string/(60*60));
  29.     $result[]="$hours hours";
  30.     $string $string (60*60);
  31.   }
  32.   if($string 60{
  33.     $mins floor($string/(60));
  34.     $result[]="$mins minutes";
  35.     $string $string (60);
  36.   }
  37.   if($string 0{
  38.     $result[]="$string seconds";
  39.   }
  40.   
  41.   return implode(' ',$result);
  42. }
  43.  
  44. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:09 +0000 by phpDocumentor 1.5.0-lsces