X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/6a259b96cff47e1fd64cbfd6f3d1e1d8e8b6486c..e7927df2744d46e176c7114bf63f1bd8f5746168:/apps/catalogue/helpers.py 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.")