diff --git a/pygeoapi/api.py b/pygeoapi/api.py index 09280b2..58535c9 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -2600,6 +2600,11 @@ def validate_datetime(resource_def, datetime_=None): if '/' in datetime_: # envelope LOGGER.debug('detected time range') LOGGER.debug('Validating time windows') + + # normalize "" to ".." (actually changes datetime_) + datetime_ = re.sub(r'^/', '../', datetime_) + datetime_ = re.sub(r'/$', '/..', datetime_) + datetime_begin, datetime_end = datetime_.split('/') if datetime_begin != '..': datetime_begin = dateparse_begin(datetime_begin) diff --git a/pygeoapi/util.py b/pygeoapi/util.py index 1e91606..e67b4e0 100644 --- a/pygeoapi/util.py +++ b/pygeoapi/util.py @@ -68,14 +68,14 @@ def dategetter(date_property, collection): :param date_property: property representing the date :param collection: dictionary to check within - :returns: `str` (ISO8601) representing the date. ('..' if null or "now", - allowing for an open interval). + :returns: `str` (ISO8601) representing the date. (allowing for an open interval + using null). """ value = collection.get(date_property, None) - if value == 'now' or value is None: - return '..' + if value is None: + return None return value.isoformat() diff --git a/tests/test_api.py b/tests/test_api.py index 1f69572..ff2d700 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1157,6 +1157,8 @@ def test_validate_datetime(): '2001-10-30/2002-10-30') assert validate_datetime(config, '2004/..') == '2004/..' assert validate_datetime(config, '../2005') == '../2005' + assert validate_datetime(config, '2004/') == '2004/..' + assert validate_datetime(config, '/2005') == '../2005' assert validate_datetime(config, '2004-10/2005-10') == '2004-10/2005-10' assert (validate_datetime(config, '2001-10-30/2002-10-30') == '2001-10-30/2002-10-30')