Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions WrightTools/data/_solis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading