From 9478f837e9d84fdddb65d75d7700183bb6d82bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 20 Jun 2016 14:35:29 +0200 Subject: [PATCH] agora+: allow wcs to send dates formatted as %Y-%m-%d (#11436) --- passerelle/contrib/agoraplus/wcs.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/passerelle/contrib/agoraplus/wcs.py b/passerelle/contrib/agoraplus/wcs.py index d029a0d..2e14d09 100644 --- a/passerelle/contrib/agoraplus/wcs.py +++ b/passerelle/contrib/agoraplus/wcs.py @@ -19,9 +19,12 @@ import calendar import datetime def date_from_iso(s): - utc = time.strptime(s, '%Y-%m-%dT%H:%M:%SZ') - timestamp = calendar.timegm(utc) - return datetime.date.fromtimestamp(timestamp).strftime('%Y-%m-%d') + if 'T' in s: + utc = time.strptime(s, '%Y-%m-%dT%H:%M:%SZ') + timestamp = calendar.timegm(utc) + return datetime.date.fromtimestamp(timestamp).strftime('%Y-%m-%d') + else: + return datetime.datetime.strptime(s, '%Y-%m-%d').date() def booleanize(value): ''' -- 2.8.1