Skip to content

Commit

Permalink
modified get_precision function
Browse files Browse the repository at this point in the history
  • Loading branch information
binni979 committed Apr 10, 2024
1 parent 14b8c64 commit f0884da
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyQuARC/code/datetime_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def _iso_datetime(datetime_string):
"""
REGEX = r"^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$"
match_iso8601 = re.compile(REGEX).match
parts = datetime_string.split('.')
if len(parts) == 2:
datetime_string = parts[0] + '.' + parts[1][:3] + parts[1][len(parts[1]) - 1]
try:
if match_iso8601(datetime_string):
if datetime_string.endswith("Z"):
Expand Down Expand Up @@ -161,7 +164,7 @@ def get_precision(dt_str):
for fmt in formats:
try:
date_time = datetime.strptime(dt_str, fmt)
return date_time, fmt
return date_time
except ValueError:
continue
return None, False
Expand All @@ -171,7 +174,7 @@ def get_precision(dt_str):
if len(granules["feed"]["entry"]) > 0:
last_granule = granules["feed"]["entry"][0]
last_granule_datetime = last_granule.get(time_key)
date_time, date_time_format = get_precision(datetime_string)
date_time = get_precision(datetime_string)
last_granule_datetime, lgd_format = get_precision(last_granule_datetime)
validity = date_time == last_granule_datetime

Expand Down

0 comments on commit f0884da

Please sign in to comment.