PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Date and Time » Date » Bug #9732

Wrong result from NWeekdayOfMonth!

Details

Request #9732Wrong result from NWeekdayOfMonth!
Submitted2007-01-04 09:53 UTC
Fromeven at phoniax dot no
Assignedfirman
StatusClosed
PackageDate
PHP Version5.2.0
OS*nix
Roadmaps(Not assigned)

Comments

[2007-01-04 09:53 UTC] even at phoniax dot no

Description:
------------
Returns wrong date when comparing to this page:
http://www.timeanddate.com/calendar/index.html?
year=2009&country=18

Test script:
---------------
echo Date_Calc::NWeekdayOfMonth(1, 1, 12, 2008, '%Y-%m-%d');

Expected result:
----------------
2008-12-29

The script should, according to http://www.timeanddate.com/
calendar/index.html?year=2009&country=18, output the date
2008-12-29

Actual result:
--------------
2008-12-01

[2007-01-09 06:46 UTC] sidshakal at gmail dot com

Frankly, I don't understand why you expect the result to be 2008-12-29.

For one thing, you are comparing your test script's output (year expected is 2008), with a calendar of 2009. Why?

Also, do you even understand what NWeekdayOfMonth is actually supposed to do?

I'd try to explain it myself, but I was having a hard time keeping on track doing so and erased what I'd just typed. You might check the API documentation though.
http://pear.php.net/package/Date/docs/latest/apidoc/Date/Date_Calc.html#methodNWeekdayOfMonth

I haven't verified that the script gives the correct result myself; however, it is bound to be a hell of a lot closer than your expected result is because the 29th of December is in no way ever located in the first week of December.

-- Sid

[2007-01-09 08:02 UTC] even at phoniax dot no

Seems like I misunderstood the documentation.
$week seems to range from 1-4 in this method (week of
month), while I thought it was week of the year. Looking at
the method-name once again this clarly makes more sence.

Perhaps the "bug" should change to a feature request
instead? :)
I would like to be able to input week of the year, and have
a valid date-range given back for that week. I couldn't find
any method that did that in the current release?