scout/utils/date.py
def get_date(date, date_format = None):
    """Return a datetime object if there is a valid date

        Raise exception if date is not valid
        Return todays date if no date where added

        Args:
            date(str)
            date_format(str)

        Returns:
            date_obj(datetime.datetime)
    """
    date_obj = datetime.datetime.now()
    if date:
        if date_format:
            date_obj = datetime.datetime.strptime(date, date_format)
        else:
            if match_date(date):
                if len(date.split('-')) == 3:
                    date = date.split('-')
                elif len(date.split(' ')) == 3:
                    date = date.split(' ')
                elif len(date.split('.')) == 3:
                    date = date.split('.')
                else:
                    date = date.split('/')
                date_obj = datetime.datetime(*(int(number) for number in date))
            else:
                raise ValueError("Date %s is invalid" % date)

    return date_obj
def get_date(date, date_format = None):
    """Return a datetime object if there is a valid date

        Raise exception if date is not valid
        Return todays date if no date where added

        Args:
            date(str)
            date_format(str)

        Returns:
            date_obj(datetime.datetime)
    """
    date_obj = datetime.datetime.now()
    if date:
        if date_format:
            date_obj = datetime.datetime.strptime(date, date_format)
        else:
            if match_date(date):
                if len(date.split('-')) == 3:
                    date = date.split('-')
                elif len(date.split(' ')) == 3:
                    date = date.split(' ')
                elif len(date.split('.')) == 3:
                    date = date.split('.')
                else:
                    date = date.split('/')
                date_obj = datetime.datetime(*(int(number) for number in date))
            else:
                raise ValueError("Date %s is invalid" % date)

    return date_obj
Return a datetime object if there is a valid date

        Raise exception if date is not valid
        Return todays date if no date where added

        Args:
            date(str)
            date_format(str)

        Returns:
            date_obj(datetime.datetime)