From a741928cfdd5c624b3fc545b171ccd7d476e6743 Mon Sep 17 00:00:00 2001 From: DLafayetteII <41025413+DLafayetteII@users.noreply.github.com> Date: Tue, 14 Jul 2026 10:10:40 -0600 Subject: [PATCH 1/2] Update _solis.py Adds support for fractional seconds, and a new error handling exception for other unexpected DateTime formats --- WrightTools/data/_solis.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/WrightTools/data/_solis.py b/WrightTools/data/_solis.py index ae0018cc..5b7cfe84 100644 --- a/WrightTools/data/_solis.py +++ b/WrightTools/data/_solis.py @@ -119,6 +119,28 @@ def get_frames(f, arr, axis0): created = attrs["Date and Time"] # is this UTC? created = time.strptime(created, "%a %b %d %H:%M:%S %Y") created = timestamp.TimeStamp(time.mktime(created)).RFC3339 + except ValueError: #round fractional seconds assuming it is the culprit + try: + HMS = created.split(' ')[3].split(':') + round_seconds = int(round(float(HMS[-1]))) + HMS_rounded = HMS[0] +':'+ HMS[1] +':'+ str(round_seconds) + created_rounded = [] + for i,p in enumerate(created.split(' ')): + if i>0: + created_rounded.append(' ') + if i !=3: + created_rounded.append(p) + else: + created_rounded.append(HMS_rounded) + created = "".join(created_rounded) + created = time.strptime(created, "%a %b %d %H:%M:%S %Y") + created = timestamp.TimeStamp(time.mktime(created)).RFC3339 + except (ValueError, IndexError) as e: #rounding failed, saving modified time instead: + created = os.stat(filepath).st_mtime + created = timestamp.TimeStamp(created).RFC3339 + warnings.warn( + f"{filepath.name} has a 'Date and Time' format that does not match %a %b %d %H:%M:%S %Y: using file modified time instead: {created}" + ) except KeyError: # use file creation time created = os.stat(filepath).st_mtime created = timestamp.TimeStamp(created).RFC3339 From 7c9c43520b14016defec6db8c0adccad3c381a0a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 16:15:56 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- WrightTools/data/_solis.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/WrightTools/data/_solis.py b/WrightTools/data/_solis.py index 5b7cfe84..4fbd9931 100644 --- a/WrightTools/data/_solis.py +++ b/WrightTools/data/_solis.py @@ -119,23 +119,23 @@ def get_frames(f, arr, axis0): created = attrs["Date and Time"] # is this UTC? created = time.strptime(created, "%a %b %d %H:%M:%S %Y") created = timestamp.TimeStamp(time.mktime(created)).RFC3339 - except ValueError: #round fractional seconds assuming it is the culprit + except ValueError: # round fractional seconds assuming it is the culprit try: - HMS = created.split(' ')[3].split(':') + HMS = created.split(" ")[3].split(":") round_seconds = int(round(float(HMS[-1]))) - HMS_rounded = HMS[0] +':'+ HMS[1] +':'+ str(round_seconds) + HMS_rounded = HMS[0] + ":" + HMS[1] + ":" + str(round_seconds) created_rounded = [] - for i,p in enumerate(created.split(' ')): - if i>0: - created_rounded.append(' ') - if i !=3: + for i, p in enumerate(created.split(" ")): + if i > 0: + created_rounded.append(" ") + if i != 3: created_rounded.append(p) else: created_rounded.append(HMS_rounded) created = "".join(created_rounded) created = time.strptime(created, "%a %b %d %H:%M:%S %Y") created = timestamp.TimeStamp(time.mktime(created)).RFC3339 - except (ValueError, IndexError) as e: #rounding failed, saving modified time instead: + except (ValueError, IndexError) as e: # rounding failed, saving modified time instead: created = os.stat(filepath).st_mtime created = timestamp.TimeStamp(created).RFC3339 warnings.warn(