Retrieve a date period given a day of month.
    
    For example, if the period is month:15 and now is equal
    to 2012-11-22 then this method will return the following:
    
        (date(2012, 11, 15), date(2012, 12, 14)) 
    
    Other examples:
        monthly:1 with now 2012-12-1 would return: (date(2012, 11, 1), date(2012, 12, 1))
    
    @param now: A date used to determine some point within a date period.
    @return tuple with date start and stop dates.
    @raise MaxAnniversaryDayError
    @raise DateFrequencyError

def date_period(frequency, anniversary, now=None):
    """
    Retrieve a date period given a day of month.
    
    For example, if the period is month:15 and now is equal
    to 2012-11-22 then this method will return the following:
    
        (date(2012, 11, 15), date(2012, 12, 14)) 
    
    Other examples:
        monthly:1 with now 2012-12-1 would return: (date(2012, 11, 1), date(2012, 12, 1))
    
    @param now: A date used to determine some point within a date period.
    @return tuple with date start and stop dates.
    @raise MaxAnniversaryDayError
    @raise DateFrequencyError
    """
    if frequency != DATE_FREQUENCY_MONTHLY:
        raise DateFrequencyError("Only monthly date frequency is supported - not '%s'" % (frequency))
    
    if anniversary > 28:
        raise MaxAnniversaryDayError("'%s' is greater than maximum allowed anniversary day 28." % anniversary)
    
    if not now:
        now = date.now()
   
    if now.day >= anniversary:
        start = date(now.year, now.month, anniversary)
        stop = start + relativedelta(months=+1) + relativedelta(days=-1)
    else:
        stop = date(now.year, now.month, anniversary)
        start = stop + relativedelta(months=-1)
        stop = stop  + relativedelta(days=-1)
    return (start, stop,)