Re: pear calendar

From: Date: Mon, 17 May 2004 09:26:33 +0000
Subject: Re: pear calendar
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-12535@lists.php.net to get a copy of this message
On Sun, 16 May 2004 19:17:56 -0400, Site Resources wrote: > I have four links at the bottom of my page which say next month, > previous month, next year and previous year. Now, say that I have > displayed in the calendar January of 2004. I have that split up > into weeks in my table, and according to that the first day of > January is on a Thursday. Now obviously, the 31 of December must be > on a wednesday; but when I click the previous month link, which > makes the url look like: > > calendars.php?month=0&year=2004&start_day=0 > > and I use adjust in my code as you will see in the code at the > bottom, to be december of 2003, it shows December 31 as landing on > a Monday. However, if I go to the page: > > calendar.php?month=12&year=2003&start_day=0 > > it displays correctly; with the 31 of December on Wednesday. While I couldn't find any obvious error in your script (I don't have time to debug it thoroughly), all I can say is the adjust() method should work. I just added a specific testcase for your problem, and the date is calculated correctly. See for yourself: ==================== $Month =& new Calendar_Month_Weekdays($_REQUEST['year'], $_REQUEST['month'], $start_day); $Month->adjust(); $y = $Month->thisYear(); $m = $Month->thisMonth(); var_dump($Month->cE->getDayOfWeek($y, $m, $Month->cE->getDaysInMonth($y, $m))); //prints "3", i.e. Wednesday. ===================== Maybe there's some wrong offset in your table rendering code, please have a look at the example 14.php provided with the package for a working solution. HTH Regards, -- Lorenzo Alberton http://pear.php.net/user/quipo

« previous php.pear.general (#12535) next »