|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Apr 2004
Location: The Netherlands
Posts: 240
|
I am using the code from PHP Anthology Volume I, Chapter 6.
Everything works fine and groovy, except when I move to the next or previous month. If that month is 31 days instead of 30 I get a E_USER_WARNING: "Calendar::Calendar Day 32 must be a number from 1 to 31" I doublechecked the code with the book, but I will still include it here. PHP Code:
Last edited by yjanse; Jun 3, 2004 at 03:05. |
|
|
|
|
|
#2 |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Apr 2004
Location: The Netherlands
Posts: 240
|
The class files from the SPLIB package are unedited and included. (Otherwise it wouldn't work at all).
Also, after showing the warning, the entire calendar is still rendered without errors. |
|
|
|
|
|
#3 |
|
SitePoint Member
Join Date: May 2004
Location: Brisbane
Posts: 19
|
I think that the calendar library evolved into PEAR::Calendar. Check it out at the pear repository OR do a search for info on these forums. I've got a forum thread happening over in the advanced php section that involves pear::calendar, so you might want to check that out as well.
|
|
|
|
|
|
#4 |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Apr 2004
Location: The Netherlands
Posts: 240
|
Thanks for the tips, I will look further.
|
|
|
|
|
|
#5 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Nov 2000
Location: Switzerland
Posts: 2,906
|
That's right - I'm ashamed to say there does seem to a bug that I missed in the version of the Calendar library in the book. Performance-wise, that code could also be better.
That's largely the reason it evolved into PEAR::Calendar, which has come on a long way since then. Using it is still similar - there's documentation here: http://pear.php.net/manual/en/package.datetime.php which shows how it works. You may want to read Getting Started with PEAR if you're unsure how to install it |
|
|
|
|
|
#6 |
|
SitePoint Zealot
![]() ![]() Join Date: Jan 2004
Location: Wisconsin
Posts: 132
|
I say we all burn the book :P (kidding, nice work on the book)
|
|
|
|
|
|
#7 |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Apr 2004
Location: The Netherlands
Posts: 240
|
Harry, first: thanks for the great book.
I have never seen a programmingbook without errors in the code yet, so nothing to be ashamed of. I am already using PEAR for validation, but not much else. I believe that I want to be able to solve every problem myself, and then when I am confident about my skills I will use PEAR and Eclipse and the likes. I just want to know what every piece of the code does ![]() To be honest, I chose to use the calender code from your book because it looked simpler than the PEAR::Calender, that overwhelmed me a bit. I will look into it now, and see if I can bushwhack through it, and find the few basic things I need. Btw: The problem I have to solve with calenders is this: For an online bookingsystem for a learning center I want to show a calender per month, where every day is colored with a color: Green = Opened and there is still room Orange = Opened but no room left White = Closed Gray = Weekends and holidays [/ul] I was breaking my brain on how I could add that to your code, because I have to perform multiple calculations based on many factors for it, using SQL and several functions I wrote. Maybe I have to write a function like isFirst() in your class which handles all of that, and call it "isRoomLeft()" or something. |
|
|
|
|
|
#8 |
|
SitePoint Member
Join Date: Aug 2004
Location: RiO
Posts: 3
|
I started reading the book, PHP Anthology vol.1, lastweek and now I've reached chapter 6. So far it's a really great book and I want to thank Harry for providing a great start in learning about the OOP techniques with PHP.
Anyways, I also got the same error message when I executed the roman calendar script. Though it was really a hard task for me novice OOP programmer to track down the bug, after spending considarable time analyzing the source I managed to find what is the problem. I think what causes the error is the line 215 in 'Month.php'. (Month.php) PHP Code:
However pls note that, as stated above, I'm by no means an OOP guru or a php master, so maybe my finding is incorrect and ridiculous... well, in that case just ignore my post. P.S. I've just downloaded the PEAR::Calendar and am viewing the code. It's very interesting and great. But, like yjanse's saying, the PEAR::Calender seems a bit complex and it overwhelmes me too. Anyways, if I have an oppotunity to build a site that needs a neat calendar system, I will challenge to use the PEAR::Calendar for the better performance and stability. Addenda: OK, I noticed that the above modification(removing the line 215) affects the highlight system of the roman calendar script. I mean when you click the last day or (last day-1) of a month, the highlight system seems not to work correctly. To fix this problem, you have to add one new line of code (000) before the line 229 and then you also need to change the line 232 of Month.php as follows. Well, I do know this is not a brilliant solution, but at the same time this is not that bad, I think. You know, the only thing you have to do here is to write the 2 line of code, anyways. (Month.php) PHP Code:
(Sorry for my bad english. I hope you guys understand what I'm saying) Last edited by desertlynx; Aug 2, 2004 at 21:09. |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 16:05.







Anyways, if I have an oppotunity to build a site that needs a neat calendar system, I will challenge to use the PEAR::Calendar for the better performance and stability. 


Linear Mode
