Skip to content

Commit

Permalink
very minor fix in datetime_utils.parse_datetime_string
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Nov 17, 2024
1 parent ebd157a commit 150a9e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion dcicutils/datetime_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "8.16.3"
version = "8.16.3.1b1" # TODO: To become 8.16.4
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 150a9e5

Please sign in to comment.