# Path: athlib/uka/agegroups.py
# def calc_uka_age_group(birth_date,
#                        match_date,
#                        category,
#                        vets=True,
#                        underage=False):
#     """Return UKA age group"""
#     if category == 'TF':
#         return rule107_agegroups_trackandfield(birth_date,
#                                                match_date,
#                                                vets=vets,
#                                                underage=underage)
#     elif category in ['ROAD', 'XC']:
#         return rule507_agegroups_crosscountry(birth_date,
#                                               match_date,
#                                               vets=vets,
#                                               underage=underage)
#     elif category == 'ESAA':
#         # Apparently the English Schools has its own rule, but we haven't done
#         # this yet. If still here, raise an exception
#         raise NotImplementedError
#     else:
#         raise ValueError("category must be one of:  TF, ROAD, XC, ESAA")
# 
# 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


from dateutil.parser import parse as parse_date
from datetime import date
from unittest import TestCase, main
from athlib.uka.agegroups import calc_uka_age_group, prior_date
            31/12/1996  14/2/2015   U20

            1/1/1997    14/2/2015   U20
            31/8/1997   14/2/2015   U20
            1/9/1997    14/2/2015   U20
            30/9/1997   14/2/2015   U20
            1/10/1997   14/2/2015   U20
            31/12/1997  14/2/2015   U20

            1/1/1998    14/2/2015   U20
            31/8/1998   14/2/2015   U20
            1/9/1998    14/2/2015   U17
            30/9/1998   14/2/2015   U17
            1/10/1998   14/2/2015   U17
            31/12/1998  14/2/2015   U17

            1/1/1999    14/2/2015   U17
            31/8/1999   14/2/2015   U17
            1/9/1999    14/2/2015   U17
            30/9/1999   14/2/2015   U17
            1/10/1999   14/2/2015   U17
            31/12/1999  14/2/2015   U17

            1/1/2000    14/2/2015   U17
            31/8/2000   14/2/2015   U17
            1/9/2000    14/2/2015   U15
            30/9/2000   14/2/2015   U15
            1/10/2000   14/2/2015   U15
            31/12/2000  14/2/2015   U15


# Path: athlib/uka/agegroups.py
# def calc_uka_age_group(birth_date,
#                        match_date,
#                        category,
#                        vets=True,
#                        underage=False):
#     """Return UKA age group"""
#     if category == 'TF':
#         return rule107_agegroups_trackandfield(birth_date,
#                                                match_date,
#                                                vets=vets,
#                                                underage=underage)
#     elif category in ['ROAD', 'XC']:
#         return rule507_agegroups_crosscountry(birth_date,
#                                               match_date,
#                                               vets=vets,
#                                               underage=underage)
#     elif category == 'ESAA':
#         # Apparently the English Schools has its own rule, but we haven't done
#         # this yet. If still here, raise an exception
#         raise NotImplementedError
#     else:
#         raise ValueError("category must be one of:  TF, ROAD, XC, ESAA")
# 
# 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


# Path: tests/test_agegroups.py
from dateutil.parser import parse as parse_date
from datetime import date
from unittest import TestCase, main
from athlib.uka.agegroups import calc_uka_age_group, prior_date

            31/12/1996  14/2/2015   U20

            1/1/1997    14/2/2015   U20
            31/8/1997   14/2/2015   U20
            1/9/1997    14/2/2015   U20
            30/9/1997   14/2/2015   U20
            1/10/1997   14/2/2015   U20
            31/12/1997  14/2/2015   U20

            1/1/1998    14/2/2015   U20
            31/8/1998   14/2/2015   U20
            1/9/1998    14/2/2015   U17
            30/9/1998   14/2/2015   U17
            1/10/1998   14/2/2015   U17
            31/12/1998  14/2/2015   U17

            1/1/1999    14/2/2015   U17
            31/8/1999   14/2/2015   U17
            1/9/1999    14/2/2015   U17
            30/9/1999   14/2/2015   U17
            1/10/1999   14/2/2015   U17
            31/12/1999  14/2/2015   U17

            1/1/2000    14/2/2015   U17
            31/8/2000   14/2/2015   U17
            1/9/2000    14/2/2015   U15
            30/9/2000   14/2/2015   U15
            1/10/2000   14/2/2015   U15
            31/12/2000  14/2/2015   U15


            1/1/2001    14/2/2015   U15