File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 1919import softwarerenderbackend
2020import zarr
2121
22+ from dateutil .parser import parse
23+
2224from datetime import datetime
2325from concurrent .futures import ALL_COMPLETED , ThreadPoolExecutor , wait
2426from threading import BoundedSemaphore
@@ -322,10 +324,18 @@ def get_image_metadata_sdk_v2(self, image_no):
322324 def acquisition_datetime (self ):
323325 pe_in = self .pixel_engine ["in" ]
324326 if self .sdk_v1 :
325- timestamp = str (pe_in .DICOM_ACQUISITION_DATETIME )
327+ timestamp = str (pe_in .DICOM_ACQUISITION_DATETIME ). strip ()
326328 else :
327- timestamp = pe_in .acquisition_datetime
328- return datetime .strptime (timestamp , "%Y%m%d%H%M%S.%f" )
329+ timestamp = pe_in .acquisition_datetime .strip ()
330+ # older files store the date time in YYYYmmddHHMMSS.ffffff format
331+ # newer files use ISO 8601, i.e. YYYY-mm-ddTHH:mm:ss
332+ # other timestamp formats may be used in the future
333+ try :
334+ # Handle "special" isyntax date/time format
335+ return datetime .strptime (timestamp , "%Y%m%d%H%M%S.%f" )
336+ except ValueError :
337+ # Handle other date/time formats (such as ISO 8601)
338+ return parse (timestamp )
329339
330340 def barcode (self ):
331341 pe_in = self .pixel_engine ["in" ]
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ def read(fname):
8686 'zarr==2.8.1' ,
8787 'kajiki==0.8.2' ,
8888 'fsspec>=0.9.0' ,
89+ 'python-dateutil>=2.8.2'
8990 ],
9091 tests_require = [
9192 'flake8' ,
You can’t perform that action at this time.
0 commit comments