Re: Bug #4130 [NEW]: ?
| From: | Monte Ohrt | Date: | Tue, 12 Apr 2005 22:20:47 +0000 |
| Subject: | Re: Bug #4130 [NEW]: ? | ||
| References: | 1 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-2712@lists.php.net to get a copy of this message | ||
|Is your ||DATE_CALC_BEGIN_WEEKDAY defined as 1 or 0? If 1 (default), then Monday would be considered the beginning of the week, and may be creating the "extra" week.|
rachelw at cybrzn dot com wrote:
From: rachelw at cybrzn dot comOperating system: LinuxPHP version: 5.0.3 Package: Date Bug Type: BugBug description: ? Description: ------------ Was using the getWeeksInMonth() function found in Date.php. I noticed the actual function is implemented in Date/Calc.php (Date_Calc class) in the weeksInMonth() method. Date package version 1.4.3 Date/Calc.php: version 1.2.6 Date.php: version 1.2.8 configure line: './configure' '--prefix=/usr' '--with-config-file-path=/etc' '--with-apxs2' '--with-openssl=/usr/local/ssl' '--with-zlib' '--with-bz2' '--with-cpdflib' '--with-curl' '--enable-dba' '--with-db4' '--with-gd' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--with-xpm-dir=/usr' '--with-ttf' '--with-freetype-dir=/usr' '--with-gd-native-ttf' '--with-gettext' '--with-imap=../imap-2004' '--with-mcrypt' '--with-mysql' '--with-ncurses' '--with-unixODBC' '--with-snmp' '--with-openssl-dir=/usr/local/ssl' '--with-imap-ssl=/usr/local/ssl' '--enable-ftp' '--with-pspell' I am writing a dynamically generated calendar, and for the month of May 2005, it returned 6 for the number of weeks in that month, instead of the correct response of 5. Some other months where it returns 6 weeks when it should return 5 include: August 2004 January 2006 October 2006 April 2007 July 2007 Upon inspecting any similarities between these months, I noticed that the 1st of the month is on Sunday with all of these. Perhaps that might point you in the right direction. Reproduce code: --------------- $year = $_GET["year"]; $month = $_GET["month"]; $first_month = new Date($year."-".$month."-01"); $days_month = $first_month->getDaysInMonth(); $weeks_month = $first_month->getWeeksInMonth(); echo $weeks_month; //expect 5 but it returns 6 Expected result: ---------------- again, for these months (just a sampling): August 2004 May 2005 January 2006 October 2006 April 2007 July 2007 I expect to get a result of 5 (weeks) vs. 6. Actual result: -------------- Actual result is 6 (instead of 5).