Re: PACKAGE Proposal: Date_Calendar
| From: | Greg Beaver | Date: | Sat, 09 Aug 2003 18:43:54 +0000 |
| Subject: | Re: PACKAGE Proposal: Date_Calendar | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-19453@lists.php.net to get a copy of this message | ||
Harry,
I think the code is great, and I'm very enthusiastic about seeing this in PEAR. I do have one major caveat: it really does need to handle dates before 1970 and after 2038 to be truly useful for all cases. The classes are so powerful as they stand now, that it would be a shame to limit them in this way. I would recommend using Julian days as a basis, or at the very least encapsulating all base calculations in the DateMath class, so that the calendar can also be very easily converted to other formats that are non-Gregorian. This will allow extended classes to do things like calculate holidays that are based on other calendars and display them using your calendar class.
All those calls to mktime could simply be replaced by calls to $this->_timeBase->mktime() where $_timeBase is an instance of DateBase (the base class that would perform all conversions and calculations). This would mean the only 2 classes that would need any modification are the Calendar and Date base class (currently DateMath)
With those changes (which are rather major, and I am interested in helping if you need any, as I can't use the class without these changes), I am +1, so call me +0 :)
Greg
Harry Fuecks wrote:
Following on from the discussion here: http://marc.theaimsgroup.com/?l=pear-dev&m=106043809425575&w=2 Would like to propose Date_Calendar, for building calendar data structures. They are designed to make building calendars as easy as possible, while completely seperating the logic from user interface. They could be used in rendering HTML, WML, PHP-GTK, command line output or whatever you like. Right now they're not prepared for PEAR (no package.xml or use of PEAR Error) but they're in a stable form. What to get the approval first before continuing. Beginning with some examples first; 1. Shows all the classes in action, from Years down to Seconds http://www.phppatterns.com/code/Date_Calendar/docs/examples/1.phps http://www.phppatterns.com/code/Date_Calendar/docs/examples/1.php 2. Shows Month being used to build Weeks then Days http://www.phppatterns.com/code/Date_Calendar/docs/examples/2.phps http://www.phppatterns.com/code/Date_Calendar/docs/examples/2.php 3. Shows Month being used to build Days (bypassing the Week) http://www.phppatterns.com/code/Date_Calendar/docs/examples/3.phps http://www.phppatterns.com/code/Date_Calendar/docs/examples/3.php The source for classes themselves can be see at; http://www.phppatterns.com/code/Date_Calendar/ For the PEAR release I'll probably reduce the number of files to avoid the pain of require_once(). The source code is fully documented but I'll come up with more examples and documentation for the release. One thing to be aware of is they rely on Unix timestamps. This helps when you need to perform database queries but means your calendar will only run up to 2038 for a 32bit OS. PS: it that the right namespace? Or should it be DateAndTime?