shared.make_timestamp.php
Current file: C:\DATA\Viktor\Diplomka\XSLT-Benchmarking/Libs/Smarty/plugins/shared.make_timestamp.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
100.00%  
100.00%   CRAP
0.00% 0 / 14
smarty_make_timestamp($string)
0.00% 0 / 1 0
0.00% 0 / 14



       1                 : <?php                                                                                                          
       2                 : /**                                                                                                            
       3                 :  * Smarty shared plugin                                                                                        
       4                 :  *                                                                                                             
       5                 :  * @package Smarty                                                                                             
       6                 :  * @subpackage PluginsShared                                                                                   
       7                 :  */                                                                                                            
       8                 :                                                                                                                
       9                 : /**                                                                                                            
      10                 :  * Function: smarty_make_timestamp<br>                                                                         
      11                 :  * Purpose:  used by other smarty functions to make a timestamp from a string.                                 
      12                 :  *                                                                                                             
      13                 :  * @author   Monte Ohrt <monte at ohrt dot com>                                                                
      14                 :  * @param DateTime|int|string $string  date object, timestamp or string that can be converted using strtotime()
      15                 :  * @return int                                                                                                 
      16                 :  */                                                                                                            
      17               0 : function smarty_make_timestamp($string)                                                                        
      18                 : {                                                                                                              
      19               0 :     if (empty($string)) {                                                                                      
      20                 :         // use "now":                                                                                          
      21               0 :         return time();                                                                                         
      22               0 :     } elseif ($string instanceof DateTime) {                                                                   
      23               0 :         return $string->getTimestamp();                                                                        
      24               0 :     } elseif (strlen($string) == 14 && ctype_digit($string)) {                                                 
      25                 :         // it is mysql timestamp format of YYYYMMDDHHMMSS?                                                     
      26               0 :         return mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),                     
      27               0 :                        substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));                     
      28               0 :     } elseif (is_numeric($string)) {                                                                           
      29                 :         // it is a numeric string, we handle it as timestamp                                                   
      30               0 :         return (int) $string;                                                                                  
      31                 :     } else {                                                                                                   
      32                 :         // strtotime should handle it                                                                          
      33               0 :         $time = strtotime($string);                                                                            
      34               0 :         if ($time == -1 || $time === false) {                                                                  
      35                 :             // strtotime() was not able to parse $string, use "now":                                           
      36               0 :             return time();                                                                                     
      37                 :         }                                                                                                      
      38               0 :         return $time;                                                                                          
      39                 :     }                                                                                                          
      40                 : }                                                                                                              
      41                 :                                                                                                                
      42                 : ?>                                                                                                             


Generated by PHP_CodeCoverage @package_version@ using PHP 5.3.6 and PHPUnit @package_version@ at Tue Jun 26 15:06:55 CEST 2012.