ID:               43452
 Updated by:       [EMAIL PROTECTED]
 Reported By:      sean dot thorne at gmail dot com
-Status:           Closed
+Status:           Open
 Bug Type:         Date/time related
 Operating System: Mac OS X 10.4.11
 PHP Version:      5.2CVS-2007-11-29 (CVS)
 Assigned To:      derick
 New Comment:

Sorry to re-open, I found the same bug on:
PHP Version 5.2.6-pl6-gentoo

Some code to reproduce:
<?php
echo date('Y-m-d', strtotime('first Monday', mktime(0, 0, 0, 12, 1,
2008)));
?>

Shows 2008-12-08, while indeed the first Monday in December is
2008-12-01.




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

[2008-07-23 18:50:15] [EMAIL PROTECTED]

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.



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

[2008-07-17 10:32:00] [EMAIL PROTECTED]

Yeah, and I've done some work on that -- but it's not ready yet.

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

[2008-07-17 10:29:15] m dot ford at leedsmet dot ac dot uk

Then there's a doc problem, because currently http://php.net/strtotime
describes its first argument as "The string to parse, according to the
GNU ยป Date Input Formats syntax", with a link to the GNU documentation. 
If strtotime() does not, in fact, implement the entirety of what's
described there, exactly as described, then what's actually implemented
should be incorporated into the PHP manual and that link removed.

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

[2008-07-15 17:23:37] [EMAIL PROTECTED]

Assigning this to myself, but be aware that we do not necessarily
implement this GNU date stuff -- we've never done this either. I'll
check it though.

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

[2008-07-15 17:19:38] m dot ford at leedsmet dot ac dot uk

Derick, please take another look at this.

I've examined it in some depth, and tend to agree there's a bug here. 
However, if you read the GNU Date Input Formats syntax, linked from
http://php.net/manual/function.strtotime.php, very closely, you find it
says:

"a day of the week will forward the date (only if necessary) to reach
that day of the week in the future"

... and ...

"a number may precede a day of the week item to move forward
supplementary weeks."

The crucial word here is "supplementary". Taken together, these
specifications suggest that, somewhat counter-intuitively:

   Monday month year

should represent the first Monday of the month, no matter what date it
falls on, and

   1 Monday month year

should be the Monday *after* that (i.e. the 2nd Monday!!), and so on.
Other wording in the GNU Date "Day of week items" section would tend to
confirm this interpretation.

I therefore submit that the bug actually manifests when the first
occurrence of the requested weekday falls on any date *other* than the
first of the month! :(

However you interpret it, it's nonetheless clear that the relationship
of "1 weekday" to "weekday" should be fixed -- either according to the
GNU specification to occur 1 week later, or more intuitively to mean the
same thing. It's definitely NOT right that "1 Monday" (for example)
means something different from "Monday" *only* when "Monday" is the 1st
of the month...!!

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

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/43452

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

Reply via email to