diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 591649a0f..3de17b11f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,12 @@ dcicutils Change Log ---------- +8.16.4 +====== +* dmichaels / 2024-11-17 +* Very minor fix in datetime_utils.parse_datetime_string. + + 8.16.3 ====== * dmichaels / 2024-11-08 diff --git a/dcicutils/datetime_utils.py b/dcicutils/datetime_utils.py index c28e7553f..3c5f340bc 100644 --- a/dcicutils/datetime_utils.py +++ b/dcicutils/datetime_utils.py @@ -53,7 +53,10 @@ def parse_datetime_string(value: str) -> Optional[datetime]: if tz_hours < 0 or tz_minutes < 0: tz_hours, tz_minutes = get_local_timezone_hours_minutes() try: - dt = datetime.strptime(value, "%Y-%m-%d %H:%M:%S") + try: + dt = datetime.strptime(value, "%Y-%m-%d %H:%M:%S") + except Exception: + dt = datetime.strptime(value, "%Y-%m-%d %H:%M:%S.%f") tz = timezone(timedelta(hours=tz_hours, minutes=tz_minutes)) return dt.replace(tzinfo=tz) except Exception: @@ -214,11 +217,12 @@ def format_datetime(value: datetime, if utc is True: tz = timezone.utc elif not isinstance(tz, timezone): - tz = get_local_timezone() if tz is True: notz = False + tz = get_local_timezone() elif tz is False: notz = True + tz = get_local_timezone() if noseconds is True: ms = False value = value.astimezone(tz) diff --git a/pyproject.toml b/pyproject.toml index 569afe3a5..a2c33e56c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.16.3" +version = "8.16.4" description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT"