In some situations new date handling could cause a page to not display
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 18 Oct 2001 08:50:35 +0000 (08:50 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 18 Oct 2001 08:50:35 +0000 (08:50 +0000)
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.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1581 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/date.php

index 3dc34db6f9b77f39f0b5056a9bb45a1d933de110..a1c3d5c5673f119615ddccfe09b169a537277115 100644 (file)
 
    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;
-      
+
       $now = time();
-      $dateZ = date('Z', $now);
+      
+      $dateZ = date('Z', $now );
       if ($invert_time)
           $dateZ = - $dateZ;
       $midnight = $now - ($now % 86400) - $dateZ;
          $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) {
 
    // I use this function for profiling. Should never be called in
    // actual versions of squirrelmail released to public.
+/*
    function getmicrotime() {
       $mtime = microtime();
       $mtime = explode(' ',$mtime);
       $mtime = $mtime[1] + $mtime[0];
       return ($mtime);
    }
+*/
 ?>