mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(date_parser): add check for time range timeshifts (#36039)
This commit is contained in:
committed by
GitHub
parent
c42e3c6837
commit
c9f65cf1c2
@@ -477,10 +477,20 @@ def get_since_until( # pylint: disable=too-many-arguments,too-many-locals,too-m
|
||||
)
|
||||
|
||||
if time_shift:
|
||||
time_delta_since = parse_past_timedelta(time_shift, _since)
|
||||
time_delta_until = parse_past_timedelta(time_shift, _until)
|
||||
_since = _since if _since is None else (_since - time_delta_since)
|
||||
_until = _until if _until is None else (_until - time_delta_until)
|
||||
separator = " : "
|
||||
if separator in time_shift:
|
||||
# Date range format: parse as a new time range
|
||||
parts = time_shift.split(separator, 1)
|
||||
if len(parts) != 2:
|
||||
raise ValueError(f"Invalid time_shift format: {time_shift}")
|
||||
since_part, until_part = (part.strip() for part in parts)
|
||||
_since = parse_human_datetime(since_part)
|
||||
_until = parse_human_datetime(until_part)
|
||||
else:
|
||||
time_delta_since = parse_past_timedelta(time_shift, _since)
|
||||
time_delta_until = parse_past_timedelta(time_shift, _until)
|
||||
_since = _since if _since is None else (_since - time_delta_since)
|
||||
_until = _until if _until is None else (_until - time_delta_until)
|
||||
|
||||
if instant_time_comparison_range:
|
||||
# This is only set using the new time comparison controls
|
||||
|
||||
Reference in New Issue
Block a user