diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index e05dc4d..e20e4a5 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -5,9 +5,9 @@ name: Test on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] jobs: test: diff --git a/pycron/__init__.py b/pycron/__init__.py index 0486c23..3e74887 100644 --- a/pycron/__init__.py +++ b/pycron/__init__.py @@ -27,11 +27,11 @@ def _to_int(value, allow_daynames=False): if isinstance(value, int) or (isinstance(value, str) and value.isnumeric()): return int(value) - if isinstance(value, str) and allow_daynames and value in DAY_NAMES: - return DAY_NAMES.index(value) + if isinstance(value, str) and allow_daynames and value.lower() in DAY_NAMES: + return DAY_NAMES.index(value.lower()) - if isinstance(value, str) and allow_daynames and value in DAY_ABBRS: - return DAY_ABBRS.index(value) + if isinstance(value, str) and allow_daynames and value.lower() in DAY_ABBRS: + return DAY_ABBRS.index(value.lower()) raise ValueError("Failed to parse string to integer") diff --git a/tests/test_day_names.py b/tests/test_day_names.py index d1025f5..89f7f61 100644 --- a/tests/test_day_names.py +++ b/tests/test_day_names.py @@ -48,6 +48,19 @@ def run(now): assert pycron.is_now("* * * * tuesday-sunday/2", now) is False assert pycron.is_now("* * * * tue-sun/2", now) is False + # Test capitalised names + assert pycron.is_now("* * * * THU", now) + assert pycron.is_now("* * * * THURSDAY", now) + assert pycron.is_now("* * * * */THU", now) + assert pycron.is_now("* * * * */THURSDAY", now) + assert pycron.is_now("* * * * SUN,WED,THU", now) + assert pycron.is_now("* * * * SUNDAY,WEDNESDAY,THURSDAY", now) + assert pycron.is_now("* * * * WED", now) is False + assert pycron.is_now("* * * * WEDNESDAY", now) is False + assert pycron.is_now("* * * * */WED", now) is False + assert pycron.is_now("* * * * */WEDNESDAY", now) is False + assert pycron.is_now("* * * * SUN,WED,SAT", now) is False + now = datetime(2015, 6, 18, 16, 7) run(now) run(now.replace(tzinfo=utc))