#24683 [Bgs]: ISO8601 weeks date seems incorrect for week 52

2003-07-17 Thread s dot vanvelthem at ibelgique dot com
 ID:   24683
 User updated by:  s dot vanvelthem at ibelgique dot com
 Reported By:  s dot vanvelthem at ibelgique dot com
 Status:   Bogus
 Bug Type: Date/time related
 Operating System: Redhat Linux 9
 PHP Version:  4.3.2
 New Comment:

My english is too bad to understand thoroughly the document
(http://www.cl.cam.ac.uk/~mgk25/iso-time.html). 

But I suspect the function date is incorrect :

date ('Y-W', '2003-12-31') returns 2003-1. Ok for week 1, but should
return 2004-1, isn't it?


In PHP4.2.3 this function returned 2003-53.

If you take a look at Mysql doc
(http://www.mysql.com/doc/en/Date_and_time_functions.html) and the
function week, I've tested :

select week('2003-12-31', 3); - 1 (as PHP does)

select date_format('2003-12-31', '%Y-%v') - returns '2003-1'
(it's not what I want to have)

select date_format('2003-12-31', '%x-%v') - returns '2004-1'
(OK that's what I wanted!!!).

In MySQL you have a supplementary 'format' character for year - %x
used in conjunction with %v (ISO8601 week number). Maybe it would be
nice if we have it too in PHP. I've looked in the manual but I didn't
find this feature.


Previous Comments:


[2003-07-16 21:16:55] [EMAIL PROTECTED]

It actually works correctly now.

From http://www.cl.cam.ac.uk/~mgk25/iso-time.html :

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). For example, the first
week of the year 1997 lasts from 1996-12-30 to 1997-01-05 and can be
written in standard notation as..



[2003-07-16 12:08:50] s dot vanvelthem at ibelgique dot com

Description:

In PHP4.3.2, the function date('W', $timestamp) behaves differently
from PHP4.2.3 concerning the ISO8601 dates 

For example (timestamps has been written in simple form for
readablility), 

date('W', '2003-12-31') 
reports 1 in PHP4.3.2 (incorrect? Mysql returns the same result)
reports 53 in PHP4.2.3 (should be the correct behaviour?)
 
(ISO8601 weeks starting on Monday, so i think you could sometimes have
a 53rd week in the year?).

It's difficult to differenciate same week between years as 

date('Y-W', '2003-12-31') reports '2003-1'


Sorry for my english,

Thanks for your time.

Seb






Reproduce code:
---
$timestamp = strtotime(2003-12-31);
echo date('Y-W', $timestamp);

 outputs '2003-1'






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



#24683 [Bgs]: ISO8601 weeks date seems incorrect for week 52

2003-07-17 Thread mgf
 ID:   24683
 Updated by:   [EMAIL PROTECTED]
 Reported By:  s dot vanvelthem at ibelgique dot com
 Status:   Bogus
 Bug Type: Date/time related
 Operating System: Redhat Linux 9
 PHP Version:  4.3.2
 New Comment:

The result from date() is correct -- the date() formats do not include
one for the year corresponding to the ISO8601 week number (perhaps this
should be a feature request?).

However, strftime() does -- see http://www.php.net/strftime, and look
for the %g and %G conversion specifiers.


Previous Comments:


[2003-07-17 05:13:21] s dot vanvelthem at ibelgique dot com

My english is too bad to understand thoroughly the document
(http://www.cl.cam.ac.uk/~mgk25/iso-time.html). 

But I suspect the function date is incorrect :

date ('Y-W', '2003-12-31') returns 2003-1. Ok for week 1, but should
return 2004-1, isn't it?


In PHP4.2.3 this function returned 2003-53.

If you take a look at Mysql doc
(http://www.mysql.com/doc/en/Date_and_time_functions.html) and the
function week, I've tested :

select week('2003-12-31', 3); - 1 (as PHP does)

select date_format('2003-12-31', '%Y-%v') - returns '2003-1'
(it's not what I want to have)

select date_format('2003-12-31', '%x-%v') - returns '2004-1'
(OK that's what I wanted!!!).

In MySQL you have a supplementary 'format' character for year - %x
used in conjunction with %v (ISO8601 week number). Maybe it would be
nice if we have it too in PHP. I've looked in the manual but I didn't
find this feature.



[2003-07-16 21:16:55] [EMAIL PROTECTED]

It actually works correctly now.

From http://www.cl.cam.ac.uk/~mgk25/iso-time.html :

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). For example, the first
week of the year 1997 lasts from 1996-12-30 to 1997-01-05 and can be
written in standard notation as..



[2003-07-16 12:08:50] s dot vanvelthem at ibelgique dot com

Description:

In PHP4.3.2, the function date('W', $timestamp) behaves differently
from PHP4.2.3 concerning the ISO8601 dates 

For example (timestamps has been written in simple form for
readablility), 

date('W', '2003-12-31') 
reports 1 in PHP4.3.2 (incorrect? Mysql returns the same result)
reports 53 in PHP4.2.3 (should be the correct behaviour?)
 
(ISO8601 weeks starting on Monday, so i think you could sometimes have
a 53rd week in the year?).

It's difficult to differenciate same week between years as 

date('Y-W', '2003-12-31') reports '2003-1'


Sorry for my english,

Thanks for your time.

Seb






Reproduce code:
---
$timestamp = strtotime(2003-12-31);
echo date('Y-W', $timestamp);

 outputs '2003-1'






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