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