'Return the weekday for a given date.
The first day according to the week format is 0 and the last day is 6.'

def _get_weekday(self, date):

    week_format = self.get_week_format()
    if (week_format == u'%W'):
        return date.weekday()
    elif (week_format == u'%U'):
        return ((date.weekday() + 1) % 7)
    else:
        raise ValueError((u'unknown    week    format:    %s' % week_format))
