ID:               21933
 Comment by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Open
 Bug Type:         Date/time related
 Operating System: WinXP
 PHP Version:      4.3.0
 New Comment:

When I run your script, it exits at this line:
1049065200 2003.03.31 01:00:00 <-> 1049061600 2003.03.31 01:00:00
!!!! ERROR !!!!

As you can see on <http://greenwichmeantime.com/local/europe/hu.htm>,
March 30th does not have 24*60*60 seconds, because that's when Hungary
switches to daylight savings time.


Previous Comments:
------------------------------------------------------------------------

[2003-01-29 03:48:44] [EMAIL PROTECTED]

When I run this script, it has make an error.
While I increment the an date with secsperday, it is make an wrong
result !

The example:

<?php

 define("SECSPERMIN",60);
 define("MINSPERHOUR",60);
 define("HOURSPERDAY",24);
 define("SECSPERHOUR",SECSPERMIN*MINSPERHOUR);
 define("SECSPERDAY",SECSPERHOUR*HOURSPERDAY);


 function TimeToStr($time){
  $str="";
  $dt=GetDate($time);
  $str=
sprintf("%02d",$dt['hours']).":".sprintf("%02d",$dt['minutes']).":".sprintf("%02d",$dt['seconds']);

  return($str);
 }

 function DateToStr($date) {
  $str="";
  $dt=GetDate($date);
 
$str=$dt['year'].'.'.sprintf("%02d",$dt['mon']).'.'.sprintf("%02d",$dt['mday']);
  return($str);
  };

 function DateTimeToStr($datetime) {
  $r=DateToStr($datetime).' '.TimeToStr($datetime);
  return($r);
 }

 function EncodeDate($y,$m,$d){
  #printbr("$y $m $d");
  if (!checkdate($m,$d,$y)) return(-1);
  $res=mktime(0,0,0, $m, $d, $y);
  return($res) ;
 }

 function DecodeDate($date,&$y,&$m,&$d){
  $y=-1;$m=-1;$d=-1;
  $dt=GetDate($date);if($dt===False) return(False);
  $y=$dt['year'];
  $m=$dt['mon'];
  $d=$dt['mday'];
 }

 print "<html>\n";

 $date=EncodeDate(2003,01,01);
 for ($i=0;$i<1000;$i++) {
  DecodeDate($date,$y,$m,$d);
  $a1=DateTimeToStr($date);
  $date2=EncodeDate($y,$m,$d);
  $a2=DateTimeToStr($date);
  print "$date $a1 <-> $date2 $a2<br>\n";
  if (($a1<>$a2) or ($date<>$date2)) {print "!!!! ERROR !!!!<br>\n";
exit;}
  $date=$date+SECSPERDAY;
 }
 print "DONE WITHOUT ERRORS !<br>\n";
 print '</html>';
?>

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=21933&edit=1

Reply via email to