def format_datestr(v):
    """ Formats a datetime or date object into the string format shared by xml and notation serializations."""
    if hasattr(v, 'microsecond'):
        return v.isoformat() + 'Z'
    else:
        return v.strftime('%Y-%m-%dT%H:%M:%SZ')