# Path: athlib/utils.py
# def isStr(o):
#     '''return true if argument is a string type'''
#     return isinstance(o,(str,bytes))


from datetime import date, timedelta
from dateutil.parser import parse as parse_date
from dateutil.relativedelta import relativedelta
from athlib.utils import isStr


def prior_date(match_date, cutoff_month, cutoff_day):
    """
    Count back to relevant date.
    e.g. find the 31st August prior to match date
    """
    y = match_date.year
    m = match_date.month
    d = match_date.day
    x = date(y, cutoff_month, cutoff_day)
    if x > match_date:
        x = date(y - 1, cutoff_month, cutoff_day)
    return x


def rule107_agegroups_trackandfield(birth_date,
                                    match_date,
                                    vets=True,
                                    underage=False):
    august_cutoff = date(match_date.year, 8, 31)
    december_cutoff = date(match_date.year, 12, 31)


# Path: athlib/utils.py
# def isStr(o):
#     '''return true if argument is a string type'''
#     return isinstance(o,(str,bytes))


# Path: athlib/uka/agegroups.py
from datetime import date, timedelta
from dateutil.parser import parse as parse_date
from dateutil.relativedelta import relativedelta
from athlib.utils import isStr



def prior_date(match_date, cutoff_month, cutoff_day):
    """
    Count back to relevant date.
    e.g. find the 31st August prior to match date
    """
    y = match_date.year
    m = match_date.month
    d = match_date.day
    x = date(y, cutoff_month, cutoff_day)
    if x > match_date:
        x = date(y - 1, cutoff_month, cutoff_day)
    return x


def rule107_agegroups_trackandfield(birth_date,
                                    match_date,
                                    vets=True,
                                    underage=False):
    august_cutoff = date(match_date.year, 8, 31)
    december_cutoff = date(match_date.year, 12, 31)


    if isStr(birth_date):