/[cvs]/nfo/php/libs/net.php.smarty/plugins/shared.make_timestamp.php
ViewVC logotype

Diff of /nfo/php/libs/net.php.smarty/plugins/shared.make_timestamp.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by cvsjoko, Wed Oct 9 00:53:36 2002 UTC revision 1.2 by joko, Wed Jun 16 21:58:17 2004 UTC
# Line 1  Line 1 
1  <?php  <?php
2    /**
3     * Smarty shared plugin
4     * @package Smarty
5     * @subpackage plugins
6     */
7    
8  /*======================================================================*\  
9      Function: smarty_make_timestamp  /**
10      Purpose:  used by other smarty functions to make a timestamp   * Function: smarty_make_timestamp<br>
11                from a string.   * Purpose:  used by other smarty functions to make a timestamp
12  \*======================================================================*/   *           from a string.
13     * @param string
14     * @return string
15     */
16  function smarty_make_timestamp($string)  function smarty_make_timestamp($string)
17  {  {
18      if(empty($string)) {      if(empty($string)) {
# Line 15  function smarty_make_timestamp($string) Line 23  function smarty_make_timestamp($string)
23          return $time;          return $time;
24    
25      // is mysql timestamp format of YYYYMMDDHHMMSS?      // is mysql timestamp format of YYYYMMDDHHMMSS?
26      if (is_numeric($string) && strlen($string) == 14) {      if (preg_match('/^\d{14}$/', $string)) {
27          $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),          $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
28                 substr($string,4,2),substr($string,6,2),substr($string,0,4));                 substr($string,4,2),substr($string,6,2),substr($string,0,4));
29    
# Line 25  function smarty_make_timestamp($string) Line 33  function smarty_make_timestamp($string)
33      // couldn't recognize it, try to return a time      // couldn't recognize it, try to return a time
34      $time = (int) $string;      $time = (int) $string;
35      if ($time > 0)      if ($time > 0)
36                  return $time;          return $time;
37          else      else
38                  return time();          return time();
39  }  }
40    
41  /* vim: set expandtab: */  /* vim: set expandtab: */

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed