From:             sandved at gmail dot com
Operating system: All
PHP version:      5.0.4
PHP Bug Type:     Date/time related
Bug description:  Date('w') do not return correct number for sunday

Description:
------------
The Date function have a day of the week parameter 'w'

This parameter should return 7 for sundays, not 0 to be ISO 8601
compilant

Why

http://se.php.net/date :
> w   Numeric representation of the day of the week     
> 0 (for Sunday) through 6 (for Saturday)

This week parameter do not return leading zeros when used like
Date('o\WWw'), Date('o\-\WW\-w')

According to ISO 8601 monday is the first day of the week and sunday the
last, numbereded 1 to 7

(Section 5.2.3 Week date states
In expressions of week dates
- day of the week is represented by one decimal digit. Monday shall be
identified as day [1] of any calendar
week, and subsequent days of the same week shall be numbered in ascending
sequence to Sunday (day [7]).) like:

Date       - Week (extended format YYYY-Www-D)
---------- - ----------
1997-12-29 - 1998-W01-1
1998-01-04 - 1998-W01-7
1998-01-01 - 1998-W01-4
1998-12-31 - 1998-W53-4
1992-01-01 - 1992-W01-3
1992-02-29 - 1992-W09-6
1992-12-31 - 1992-W53-4
1975-01-01 - 1975-W01-3
1975-12-28 - 1975-W52-7
1975-12-29 - 1976-W01-1


Sources
Here's a copy of the latest free online copy
http://www.pvv.org/~nsaa/8601v2000.pdf, only minor changes in the text
in the latest version from ISO - also see
http://en.wikipedia.org/wiki/ISO_8601.


Reproduce code:
---------------
Echo Date('o\-\WW\-w', strtotime('2 January 2005'))
Date('o\-\WW\-w', strtotime('9 January 2005'));


Expected result:
----------------
2004-W53-7
2005-W01-7

Actual result:
--------------
2004-W53-0
2005-W1-0 (leading zeros in week fixed in bug report
http://bugs.php.net/?id=34302)

-- 
Edit bug report at http://bugs.php.net/?id=34304&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34304&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34304&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34304&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34304&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34304&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34304&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34304&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34304&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34304&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34304&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34304&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34304&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34304&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34304&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34304&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34304&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34304&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34304&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34304&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34304&r=mysqlcfg

Reply via email to