ID:               33957
 User updated by:  paul at stunning-stuff dot com
 Reported By:      paul at stunning-stuff dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Date/time related
 Operating System: Windows XP Pro
 PHP Version:      5.1.0b3
 New Comment:

Here is some example code to reproduce the problem:

<?php

$timestamp = gmmktime(12, 0, 0, 12, 28, 1992);
echo 'Week number for ' . gmdate('D M d, Y H:i:s', $timestamp) . ': ' .
gmdate('W', $timestamp) . '<br>';

$timestamp = gmmktime(12, 0, 0, 12, 29, 1992);
echo 'Week number for ' . gmdate('D M d, Y H:i:s', $timestamp) . ': ' .
gmdate('W', $timestamp) . '<br>';

$timestamp = gmmktime(12, 0, 0, 12, 30, 1992);
echo 'Week number for ' . gmdate('D M d, Y H:i:s', $timestamp) . ': ' .
gmdate('W', $timestamp) . '<br>';

$timestamp = gmmktime(12, 0, 0, 12, 31, 1992);
echo 'Week number for ' . gmdate('D M d, Y H:i:s', $timestamp) . ': ' .
gmdate('W', $timestamp) . '<br>';

$timestamp = gmmktime(12, 0, 0, 12, 28, 2020);
echo 'Week number for ' . gmdate('D M d, Y H:i:s', $timestamp) . ': ' .
gmdate('W', $timestamp) . '<br>';

$timestamp = gmmktime(12, 0, 0, 12, 29, 2020);
echo 'Week number for ' . gmdate('D M d, Y H:i:s', $timestamp) . ': ' .
gmdate('W', $timestamp) . '<br>';

$timestamp = gmmktime(12, 0, 0, 12, 30, 2020);
echo 'Week number for ' . gmdate('D M d, Y H:i:s', $timestamp) . ': ' .
gmdate('W', $timestamp) . '<br>';

$timestamp = gmmktime(12, 0, 0, 12, 31, 2020);
echo 'Week number for ' . gmdate('D M d, Y H:i:s', $timestamp) . ': ' .
gmdate('W', $timestamp) . '<br>';

?>

Expected result:

Week number for Mon Dec 28, 1992 12:00:00: 53
Week number for Tue Dec 29, 1992 12:00:00: 53
Week number for Wed Dec 30, 1992 12:00:00: 53
Week number for Thu Dec 31, 1992 12:00:00: 53
Week number for Mon Dec 28, 2020 12:00:00: 53
Week number for Tue Dec 29, 2020 12:00:00: 53
Week number for Wed Dec 30, 2020 12:00:00: 53
Week number for Thu Dec 31, 2020 12:00:00: 53

Actual result:

Week number for Mon Dec 28, 1992 12:00:00: 1
Week number for Tue Dec 29, 1992 12:00:00: 1
Week number for Wed Dec 30, 1992 12:00:00: 1
Week number for Thu Dec 31, 1992 12:00:00: 1
Week number for Mon Dec 28, 2020 12:00:00: 1
Week number for Tue Dec 29, 2020 12:00:00: 1
Week number for Wed Dec 30, 2020 12:00:00: 1
Week number for Thu Dec 31, 2020 12:00:00: 1

Check
http://www.timeanddate.com/calendar/custom.html?year=1992&month=12&typ=1&display=1&wno=1
and
http://www.timeanddate.com/calendar/custom.html?year=2020&month=12&typ=1&display=1&wno=1
to see these expected results confirmed.

Sorry for the bulky post, but this way there is no room for
misinterpretation.

Thanks,

Paul van der Maas
---
www.stunning-stuff.com


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

[2005-08-02 07:55:12] [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 possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.



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

[2005-08-02 03:27:51] paul at stunning-stuff dot com

Description:
------------
Hi,

While I was writing my own getWeekNumber method I discovered
gmdate('W') and date('W') both return incorrect results for the year
1992 and 2020. Both years end on a thursday and both are leap years.
I'm guessing that this is exactly the reason they return incorrect
results :).

Expected result:
The last 4 days in 1992 and 2020 belong to week 53 of those years
according to ISO 8601 rules.

Actual result:
gmdate('W') and date('W') think the last 4 days of 1992 and 2020 belong
to week 1 of the following year.

I only had the time to test these two years, but I expect that PHP will
return the incorrect week number for every leap year that ends with a
thursday.

Thanks,

Paul van der Maas
---
www.stunning-stuff.com



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


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

Reply via email to