Skip to content

Commit

Permalink
Add '%m.%d.%y' date format for .mpr file timestamps
Browse files Browse the repository at this point in the history
Closes #60
  • Loading branch information
chatcannon committed May 23, 2021
1 parent dd605e8 commit cec14e6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions galvani/BioLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,18 @@ def __init__(self, file_or_path):

if maybe_log_module:
log_module, = maybe_log_module
try:
tm = time.strptime(log_module['date'].decode('ascii'), '%m/%d/%y')
except ValueError:
tm = time.strptime(log_module['date'].decode('ascii'), '%m-%d-%y')
date_string = log_module['date'].decode('ascii')
date_formats = ['%m/%d/%y', '%m-%d-%y', '%m.%d.%y']
for date_format in date_formats:
try:
tm = time.strptime(date_string, date_format)
except ValueError:
continue
else:
break
else:
raise ValueError(f'Could not parse timestamp {date_string!r}'
f' with any of the formats {date_formats}')
self.enddate = date(tm.tm_year, tm.tm_mon, tm.tm_mday)

# There is a timestamp at either 465 or 469 bytes
Expand Down

0 comments on commit cec14e6

Please sign in to comment.