diff --git a/codalab/model/bundle_model.py b/codalab/model/bundle_model.py index a8265614a..d10ecbe15 100644 --- a/codalab/model/bundle_model.py +++ b/codalab/model/bundle_model.py @@ -571,7 +571,7 @@ def add_join(table: Table, condition: Any, left_outer_join: bool = False): conjunct = condition elif key in ('.before', '.after'): try: - target_datetime = parser.isoparse(value) + target_datetime = parser.parse(value) except ValueError: raise UsageError( "Unable to parse datetime. Datetime must be specified as an ISO-8601 datetime string such as YYYY-MM-DD." diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 42c21a673..a8bb566c4 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -1939,6 +1939,12 @@ def test_search_time(ctx): time.sleep(1) time3 = datetime.now().isoformat() + # Check date format works correctly, GH issue #4360 + check_not_equals( + 'UsageError: Unable to parse datetime. Datetime must be specified as an ISO-8601 datetime string such as YYYY-MM-DD.', + _run_command([cl, 'search', '.before=2023-1-11', '.count']), + ) + # No results check_equals('', _run_command([cl, 'search', 'name=' + name, '.before=' + time1, '-u'])) check_equals('', _run_command([cl, 'search', 'name=' + name, '.after=' + time3, '-u']))