Initial commit
This commit is contained in:
commit
998d011cd3
233 changed files with 36893 additions and 0 deletions
45
onyx/modules/templates/smarty/plugins/modifier.temps.php
Normal file
45
onyx/modules/templates/smarty/plugins/modifier.temps.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty calc temps modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: temps<br>
|
||||
* Date: Nov 01, 2009
|
||||
* Purpose: timestamp to string
|
||||
* Example: {$timestamp|separenombre}
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param timestamp $
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_temps($time)
|
||||
{
|
||||
$output = '';
|
||||
$tab = array ('jour' => '86400', 'heure' => '3600', 'minute' => '60', 'seconde' => '1');
|
||||
foreach ($tab as $key => $value) {
|
||||
$compteur = 0;
|
||||
while ($time > ($value-1)) {
|
||||
$time = $time - $value;
|
||||
$compteur++;
|
||||
}
|
||||
if ($compteur != 0) {
|
||||
$output .= $compteur.' '.$key;
|
||||
if ($compteur > 1) $output .= 's';
|
||||
if ($value != 1) $output .= ' ';
|
||||
}
|
||||
}
|
||||
if (empty($output)) return 'Instantané';
|
||||
else return $output;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
Reference in a new issue