Re: Package Proposal - DateRange and Range
| From: | MFriedman at symcor dot com | Date: | Mon, 18 Aug 2003 21:24:33 +0000 |
| Subject: | Re: Package Proposal - DateRange and Range | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20009@lists.php.net to get a copy of this message | ||
The source code of both classes can be reviewed at:
http://www.daart.ca/php/range.php
It's only partly done in terms of comments etc, but it should give a clear
indication of the purpose of the classes.
The Validate package stuff sounds interesting but I'm not familiar with the
package. I'll have a look.
Thanks,
Matt Friedman.
MFriedman@symcor.
com To: pear-dev@lists.php.net
cc:
18/08/2003 02:04 Subject: [PEAR-DEV] Package Proposal - DateRange and
Range
PM
I would like to propose two classes for PEAR entitled Range and DateRange.
DateRange would extend a more general abstract interface: Range.
The Range interface is as follows:
// constructor
Range::Range($start, $end)
// return the start of the range
Range::&getStart()
// return the end of the range
Range::&getEnd()
// Determine if this element is contained within the range
Range::inRange($rangeElement)
// Determine if one range equals another
Range::equals($range)
// the distance between the start and end
Range::getLength()
// Determine if the supplied range is a subset of this range
Range::isSubset($range)
// Determine if the supplied range is a superset of this range.
Range::isSuperset($range)
// Determine if this the supplied range intersects with this range
Range::intersects($range)
// Return the union of the supplied range and this range
Range::merge($range)
I've found this useful in particular for programming schedules. One can use
DateRanges to find free time in appointment books for instance.
Additionally, Range could be extended in various ways, for example it would
be easy to create an IntegerRange class. By the way, DateRange uses the
existing Date package.
I'm unsure as to where this might fit into PEAR; certainly DateRange could
possibly fit into the Date package, but what about Range? Does there need
to be a new category named Range? I'm partial to adding a Range category
and then including Range subclasses in that directory. In any case, perhaps
that discussion can be deferred until we see if the package gets the votes
required. :)
Coding is complete for DateRange and Range as well as a set of tests
written using PHPUnit - I was careful to check lots of boundary conditions
etc... and all the tests pass so things should be in pretty good shape.
Most of the comments haven't been written but will be soon.
Thanks very much. Any questions, please let me know.
Matt Friedman.
--
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php