ID:               35219
 User updated by:  mail at harendt dot de
 Reported By:      mail at harendt dot de
 Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Linux infong 2.4 #1 SMP Thu Jan
 PHP Version:      4.4.1
 Assigned To:      derick
 New Comment:

...Week 01 of a year is per definition the first week that
has the Thursday in this year ...

Thank you very much for this helpful hint. And excuse my "bug report".


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

[2005-11-17 13:27:27] [EMAIL PROTECTED]

Ok, this is what ISO says:
"In commercial and industrial applications (delivery times, production
plans, etc.), especially in Europe, it is often required to refer to a
week of a year. Week 01 of a year is per definition the first week that
has the Thursday in this year, which is equivalent to the week that
contains the fourth day of January. In other words, the first week of a
new year is the week that has the majority of its days in the new year.
Week 01 might also contain days from the previous year and the week
before week 01 of a year is the last week (52 or 53) of the previous
year even if it contains days from the new year. A week starts with
Monday (day 1) and ends with Sunday (day 7)."
http://www.cl.cam.ac.uk/~mgk25/iso-time.html

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

[2005-11-17 13:13:15] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://php.net/date, see the \"W\" modifier, which returns the ISO week
of the year. There is nothing wrong here.

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

[2005-11-14 19:56:25] [EMAIL PROTECTED]

Derick, take a look at it plz.
# date -d "2006-01-01 00:00:00" +"%W"
00


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

[2005-11-14 19:01:58] mail at harendt dot de

Description:
------------
The function "date" called with the parameter "W" to give the number of
the week is wrong when thr year turns.
For example the function give for sunday, 01.01.2006 the week number
52.

Reproduce code:
---------------
<?php
$Dez05 = mktime(0, 0, 0, 12, 28, 2005);

$aHour = 60*60; $aDay  = $aHour * 24;

for ($d = 0; $d <= 5; $d++) {
        $Day00 = $Dez05 + $d * $aDay;
        
        for ($ih = 0; $ih < 3; $ih++) {
        $h=8*$ih;
        $TS = $Day00 + $h * $aHour;
                $DAY = date("D",$TS); $nrDAY = date("d",$TS);
                $HR = date("H",$TS); $MIN = date("i",$TS);
                $MNTH = date("m",$TS); $YEAR = date("y",$TS);
                
                $WEEK = date("W",$TS); $WEEK = sprintf ("%02d", $WEEK);
        $sd = sprintf ("%02d", $d);
        $sh = sprintf ("%02d", $h);
        
                echo "$TS ($sd, $sh) --> week = <b>$WEEK</b>, $DAY,
$nrDAY.$MNTH.$YEAR,                   $HR.$MIN </br>";
        }       
}
?>


Expected result:
----------------
1135724400 (00, 00) --> week = 52, Wed, 28.12.05, 00.00 
1135753200 (00, 08) --> week = 52, Wed, 28.12.05, 08.00 
1135782000 (00, 16) --> week = 52, Wed, 28.12.05, 16.00 
1135810800 (01, 00) --> week = 52, Thu, 29.12.05, 00.00 
1135839600 (01, 08) --> week = 52, Thu, 29.12.05, 08.00 
1135868400 (01, 16) --> week = 52, Thu, 29.12.05, 16.00 
1135897200 (02, 00) --> week = 52, Fri, 30.12.05, 00.00 
1135926000 (02, 08) --> week = 52, Fri, 30.12.05, 08.00 
1135954800 (02, 16) --> week = 52, Fri, 30.12.05, 16.00 
1135983600 (03, 00) --> week = 52, Sat, 31.12.05, 00.00 
1136012400 (03, 08) --> week = 52, Sat, 31.12.05, 08.00 
1136041200 (03, 16) --> week = 52, Sat, 31.12.05, 16.00 
1136070000 (04, 00) --> week = 52, Sun, 01.01.06, 00.00 !!
1136098800 (04, 08) --> week = 52, Sun, 01.01.06, 08.00 !!
1136127600 (04, 16) --> week = 52, Sun, 01.01.06, 16.00 !! 
1136156400 (05, 00) --> week = 01, Mon, 02.01.06, 00.00 
1136185200 (05, 08) --> week = 01, Mon, 02.01.06, 08.00 
1136214000 (05, 16) --> week = 01, Mon, 02.01.06, 16.00 





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


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

Reply via email to