spug.util.DateRange
index
/home/mmuller/w/spug/util/DateRange.py

Class representing a date range.
 
DateRange is created using two dates and can be used to make 
determinations about dates within the range.
 
Synopsis:
 
{{
   r0 = DateRange(Date(stdfmt = '2/12/98'), Date(stdfmt = '3/13/99'))
   
   # see if a date range includes a particular date
   if r0.includes(Date(stdfmt = '12/1/98')):
      print 'yup'
   
   # see if the range overlaps with another data range
   if r0.overlap(DateRange(Date(stdfmt = '12/1/98'),
                           Date(stdfmt = '1/1/2000')
                           )
                 ):
      print 'double-yup'
}}

 
Classes
       
util.DateRange.DateRange

 
class DateRange
    A date range is a period in time.  By default, a date range begins with
negative infinity and ends with infinity.
 
  Methods defined here:
__cmp__(self, other)
Compares the start date of two date ranges.  If the two date ranges
have the same start date, compares the end date.
__init__(self, startDate=<util.Date.Date instance at 0x8279c4c>, endDate=<util.Date.Date instance at 0x8279cec>)
Constructs a date range.  By default, the start date is the
bottomless past and the end date is the endless future.  This
allows us to define date ranges from a given point to the end of
time, or from the beginning of time to a given point.
__str__(self)
Formats the receiver as a string (two new standard format dates
seperated by a dash.
alignedWith(self, other)
Returns true if the records are "aligned" - that is, if the start
date of one matches the end date of the other.
getEnd(self)
Returns the end date.
getStart(self)
Returns the start date.
includes(self, date)
Returns true if the date range includes the given date.  In keeping
with the spirit of date ranges, inclusion is defined as being
greater than or equal to the start date but less than the end date.
overlap(self, other)
Returns true if the receiver date range overlaps with the /other/ date
range.
setEnd(self, end)
Resets the end Date.
setStart(self, start)
Resets the start Date.
union(self, other)
Returns a date range that is the union of the periods defined by
self and other, or None if the two periods do not overlap.