Skip to content

Commit 48ca13c

Browse files
committed
Fix regex and import warnings
1 parent f12ba48 commit 48ca13c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/spdx_tools/spdx/datetime_conversions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44
import re
5+
import warnings
56
from datetime import datetime, timezone
67

78

@@ -14,8 +15,8 @@ def datetime_from_str(date_str: str) -> datetime:
1415

1516
# Based on the https://www.w3.org/TR/xmlschema11-2/#dateTimeStamp
1617
# The secondFrag allows fractional second notation as well.
17-
# normalize to micro seconds so that we can use %f with strptime
18-
date_str = re.sub(r"\.(\d{1,6})\d*Z$", r".\1Z", date_str)
18+
# truncate the microsecond part
19+
date_str = re.sub(r"\.\d*Z$", "Z", date_str)
1920
warnings.warn(
2021
"Invalid date format. Expected YYYY-MM-DDThh:mm:ssZ "
2122
"Sub-second fractions have been discarded",

0 commit comments

Comments
 (0)