Skip to content

Commit

Permalink
ods: add time type backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalfree committed Jul 10, 2024
1 parent 0f6eb81 commit b1c3b89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tablib/formats/_ods.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ def convert_date(val):
return convert_date(date_value)
if value_type == 'time':
time_value = cell.getAttribute('timevalue')
return dt.datetime.strptime(time_value, "PT%HH%MM%SS").time()
try:
return dt.datetime.strptime(time_value, "PT%HH%MM%SS").time()
except ValueError:
# backwards compatibility for times exported with older tablib versions
return dt.datetime.strptime(time_value, "%H:%M:%S").time()
if value_type == 'boolean':
bool_value = cell.getAttribute('booleanvalue')
return bool_value == 'true'
Expand Down
Binary file modified tests/files/book.ods
Binary file not shown.

0 comments on commit b1c3b89

Please sign in to comment.