Skip to content

Commit

Permalink
Search on years before -9999 and after 9999 (#11420)
Browse files Browse the repository at this point in the history
* Search on years before -9999 and after 9999

* Update changelog
  • Loading branch information
chiatt authored Aug 31, 2024
1 parent d76c057 commit 3c8d5b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion arches/app/utils/date_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ def __init__(
except Exception as err:
self.error = err
raise err

def get_long_year(self, date):
"""
Dates with long years will fail to parse unless properly formatted.
Example: '-200000-01-01' and '20000-01-01' will fail to parse.
The day and month must be stripped and the year prefixed with a y.
"""

date_elements = date.split("-")
if len(date_elements) == 4:
long_year = f"y-{date_elements[1]}"
if len(date_elements) == 3:
long_year = f"y{date_elements[0]}"
return long_year

def parse(self, date=None):
if date is None:
Expand All @@ -91,7 +105,12 @@ def parse(self, date=None):
except Exception:
pass

self.edtf = parse_edtf(date)
try:
self.edtf = parse_edtf(date)
except Exception as e: #Exception is likely because year has more than 4 digits
long_year = self.get_long_year(date)
self.edtf = parse_edtf(long_year)

result = self.handle_object(self.edtf)
if isinstance(result, list):
self.result_set = result
Expand Down
1 change: 1 addition & 0 deletions releases/7.5.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Arches 7.5.4 Release Notes
is specified #11120
- Allow main (left) nav to scroll to content height when expanded #11243
- Ensure resource type search filter dropdown is not displayed beneath search filter buttons #11188
- Fix search failure when filtering on dates with years having more than 4 digits, #11419

### Dependency changes:
```
Expand Down

0 comments on commit 3c8d5b3

Please sign in to comment.