ID:               40271
 User updated by:  slomo at sonarkollektiv dot de
 Reported By:      slomo at sonarkollektiv dot de
-Status:           Feedback
+Status:           Open
 Bug Type:         Date/time related
 Operating System: Mac OS X 10.4.8
 PHP Version:      5.2.0
 New Comment:

thanks [EMAIL PROTECTED], that's brilliant :)

and it seems to be bug free. I still think my code produced a 
bug in PHP and I do not get why this happens.


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

[2007-01-29 12:01:58] [EMAIL PROTECTED]

Could you please just paste something like this:
code :
strftime("<something>")

actual result:
<something you can actually see>

expected result:
<something you expected to see>

I really don't think those functions, cycles and HTML output are
required to demonstrate a problem with strftime().


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

[2007-01-29 11:55:33] slomo at sonarkollektiv dot de

My "Reproduce code" was quite complete. Here it is again, 
this time it starts with <?php and ends with ?> :-)

I expect: using strtotime("last monday") should behave 
always the same. If you run my code you will see that it 
differs depending on the given date. My code is not complex, 
so I hope you get the point very soon.

This "Day of week items" are a little bit confusing, because 
if you have e.g. a $date for a monday and state strtotime
("$date last monday"), you get $date. I assume this is 
correct.

Anyway I would think it's just my fault if my function would 
be "off 1 week" for the whole year if the date is a monday 
every time. But this happens only for the first week, in any 
other week the result is like I learned strtotime() is doing 
it.

Can you follow?

<?php

function MondayOfWeek($year, $week) { 
        return strtotime("$year-01-04 UTC + " . ($week-1) . ' 
week last monday');
} 

for ($y = 1998; $y < 2012; $y++) {
        for ($w = 1; $w < 53; $w++) {
                $start = MondayOfWeek($y, $w);
                $end   = strtotime("+6 day", $start);
                
                echo "KW $w/$y: " . gmstrftime('%A, %x %X', $start) 
. ' - ' . gmstrftime('%A, %x %X', $end) . ' - reverse check 
(week/year): ' . gmstrftime('%V/%G', $start) . "<br />\n";
                
                if ($w != gmstrftime('%V', $start) || $y != 
gmstrftime('%G', $start)) {
                        echo '<span style="color: red;">Oops, 
EXCEPTIONAL ERROR!</span>' . "<br />\n";
                }
        }
        echo "<hr>\n";
}

?>

best regards,
  slomo

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

[2007-01-29 11:50:06] [EMAIL PROTECTED]

You can also just use "strtotime('2007W011')"; for Monday "1", of Week
1 ("01") of year 2007 ("2007").

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

[2007-01-29 11:33:36] [EMAIL PROTECTED]

And please do not forget about expected and actual results.
Thank you.

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

[2007-01-29 11:32:05] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/40271

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

Reply via email to