From d205a7bf5da5c2fffb619cf30baa2d7ef5354938 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Thu, 18 Oct 2001 08:50:35 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1581 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/date.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/functions/date.php b/functions/date.php index 3dc34db6..a1c3d5c5 100644 --- a/functions/date.php +++ b/functions/date.php @@ -154,30 +154,29 @@ 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; @@ -193,7 +192,8 @@ $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) { @@ -244,10 +244,12 @@ // 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); } +*/ ?> -- 2.25.1