From d997e9be08b2d8483134f01c60b1fdd7b99d69c6 Mon Sep 17 00:00:00 2001 From: Jessy Barrette <30420025+JessyBarrette@users.noreply.github.com> Date: Tue, 15 Aug 2023 10:14:34 -0400 Subject: [PATCH] fix utils.convert_datetime_str when None --- ocean_data_parser/parsers/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ocean_data_parser/parsers/utils.py b/ocean_data_parser/parsers/utils.py index d911ad56..d9676c01 100644 --- a/ocean_data_parser/parsers/utils.py +++ b/ocean_data_parser/parsers/utils.py @@ -214,8 +214,12 @@ def get_spatial_coverage_attributes( return ds -def convert_datetime_str(time_str, **to_datetime_kwargs): +def convert_datetime_str(time_str:str, **to_datetime_kwargs) -> pd.Timestamp: + """Parse time stamp string to a pandas Timestamp""" date_format = None + if time_str is None: + return pd.NaT + if re.fullmatch(r"\d\d\d\d-\d\d-\d\d", time_str): date_format = "%Y-%m-%d" elif re.fullmatch(r"\d\d-\d\d-\d\d\d\d", time_str):