File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -327,12 +327,17 @@ def acquisition_datetime(self):
327327 timestamp = str (pe_in .DICOM_ACQUISITION_DATETIME ).strip ()
328328 else :
329329 timestamp = pe_in .acquisition_datetime .strip ()
330- # older files store the date time in YYYYmmddHHMMSS.ffffff format
330+ # older files store the date time in YYYYmmddHHMMSS.ffffff format,
331+ # optionally with a timezone offset appended
331332 # newer files use ISO 8601, i.e. YYYY-mm-ddTHH:mm:ss
332333 # other timestamp formats may be used in the future
333334 try :
334- # Handle "special" isyntax date/time format
335- return datetime .strptime (timestamp , "%Y%m%d%H%M%S.%f" )
335+ try :
336+ # Handle "special" isyntax date/time format
337+ return datetime .strptime (timestamp , "%Y%m%d%H%M%S.%f" )
338+ except ValueError :
339+ # Handle "special" isyntax date/time format with timezone
340+ return datetime .strptime (timestamp , "%Y%m%d%H%M%S.%f%z" )
336341 except ValueError :
337342 # Handle other date/time formats (such as ISO 8601)
338343 return parse (timestamp )
You can’t perform that action at this time.
0 commit comments