'Validate a value, and convert it into a datetime.date object
as necessary
@param value: the value to validate
@return: tuple (value, error)'

def __call__(self, value):

    is_datetime = False
    if isinstance(value, basestring):
        dt = self.calendar.parse_date(value.strip(), dtfmt=self.format, local=True)
        if (dt is None):
            return (value, self.error_message)
    elif isinstance(value, datetime.datetime):
        dt = value
        is_datetime = True
    elif isinstance(value, datetime.date):
        dt = value
    else:
        return (value, self.error_message)
    if (is_datetime and dt.tzinfo):
        offset = dt.tzinfo.utcoffset(dt)
        dt = dt.replace(tzinfo=None)
    else:
        offset = self.delta()
        if (not ((-86340) < offset < 86340)):
            return (value, self.offset_error)
        offset = datetime.timedelta(seconds=offset)
    if (not is_datetime):
        dt = datetime.datetime.combine(dt, datetime.time(8, 0, 0))
    dt_utc = (dt - offset).date()
    if ((self.minimum and (dt_utc < self.minimum)) or (self.maximum and (dt_utc > self.maximum))):
        return (value, self.error_message)
    return (dt_utc, None)
