浏览代码

In some situations new date handling could cause a page to not display
or to show strange chars together with the date. This behaviour has not
been explained so far as all function callings seem to be fine. The problem
has been narrowed to a date( $format, $stamp ); calling. $format and $stamp
have been checked and are both OK. It looks like an internal PHP problem,
but I can't be sure.

I've observed this problem in PHP 4.0.4. PHP 4.0.6 is working just fine and
don't show that strange behaviour.

In order to avoid that problem, I've observed that placing some chars
leading and trailing the date() format string avoids the problem (so maybe
an internal pointer to the string problem ?). So do I and I remove then once
the conversion is finished.

If someone can reproduce the bug with prior version and find a solution
please tell me.

philippe_mingo 24 年之前
父节点
当前提交
0387c01b1c
共有 1 个文件被更改,包括 18 次插入16 次删除
  1. 18 16
      functions/date.php

+ 18 - 16
functions/date.php

@@ -154,30 +154,29 @@
 
 
    function date_intl( $date_format, $stamp ) {
    function date_intl( $date_format, $stamp ) {
 
 
-      $date_format = str_replace( 'D', '[D]', $date_format );
-      $date_format = str_replace( 'F', '[F]', $date_format );
-      $date_format = str_replace( '[D]', 
-                                  ereg_replace( "([a-zA-Z])", "\\\\1", substr( getDayName( date( 'w', $stamp ) ), 0, 3 ) ), 
-                                  $date_format );
-      $date_format = str_replace( '[F]', 
-                                  ereg_replace( "([a-zA-Z])", "\\\\1", getMonthName( date( 'm', $stamp ) ) ), 
-                                  $date_format );
-      return( $date_format . ' ' );
+      $ret = str_replace( 'D', '$1', $date_format );
+      $ret = str_replace( 'F', '$2', $ret );
+      $ret = date( '$3'. $ret . '$3', $stamp ); // Workaround for a PHP 4.0.4 problem
+      $ret = str_replace( '$1', substr( getDayName( date( 'w', $stamp ) ), 0, 3 ), $ret );
+      $ret = str_replace( '$2', getMonthName( date( 'm', $stamp ) ), $ret );
+      $ret = str_replace( '$3', '', $ret );
+      
+      return( $ret );
    }
    }
 
 
-   function getLongDateString($stamp) {
+   function getLongDateString( $stamp ) {
    
    
-      $date_format = date_intl( _("D, F j, Y g:i a"), $stamp );
-      return date( $date_format, $stamp );
+      return( date_intl( _("D, F j, Y g:i a"), $stamp ) );
       
       
    }
    }
 
 
-   function getDateString($stamp) {
+   function getDateString( $stamp ) {
    
    
       global $invert_time;
       global $invert_time;
-      
+
       $now = time();
       $now = time();
-      $dateZ = date('Z', $now);
+      
+      $dateZ = date('Z', $now );
       if ($invert_time)
       if ($invert_time)
           $dateZ = - $dateZ;
           $dateZ = - $dateZ;
       $midnight = $now - ($now % 86400) - $dateZ;
       $midnight = $now - ($now % 86400) - $dateZ;
@@ -193,7 +192,8 @@
          $date_format = _("M j, Y");
          $date_format = _("M j, Y");
       }
       }
       
       
-      return( date( date_intl( $date_format, $stamp ), $stamp ) );
+      return( date_intl( $date_format, $stamp ) );
+      // return( date( $date_i, $stamp ) );
    }
    }
 
 
    function getTimeStamp($dateParts) {
    function getTimeStamp($dateParts) {
@@ -244,10 +244,12 @@
 
 
    // I use this function for profiling. Should never be called in
    // I use this function for profiling. Should never be called in
    // actual versions of squirrelmail released to public.
    // actual versions of squirrelmail released to public.
+/*
    function getmicrotime() {
    function getmicrotime() {
       $mtime = microtime();
       $mtime = microtime();
       $mtime = explode(' ',$mtime);
       $mtime = explode(' ',$mtime);
       $mtime = $mtime[1] + $mtime[0];
       $mtime = $mtime[1] + $mtime[0];
       return ($mtime);
       return ($mtime);
    }
    }
+*/
 ?>
 ?>