X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ce8d791a5298e0cb2569034aec4c8b57afac97b2..84e2c528c61c6018ab21d1729ee32f34d3653b8e:/apps/catalogue/helpers.py?ds=sidebyside diff --git a/apps/catalogue/helpers.py b/apps/catalogue/helpers.py index 7bc24819..df64ade1 100644 --- a/apps/catalogue/helpers.py +++ b/apps/catalogue/helpers.py @@ -1,3 +1,4 @@ +from datetime import date from functools import wraps from django.db.models import Count @@ -28,3 +29,10 @@ def cached_in_field(field_name): return value return wrapped return decorator + + +def parse_isodate(isodate): + try: + return date(*[int(p) for p in isodate.split('-')]) + except (AttributeError, TypeError, ValueError): + raise ValueError("Not a date in ISO format.")