add missing converter functions

This commit is contained in:
chfw 2017-08-27 07:14:46 +01:00
parent 388cb54dac
commit 5e02a4c3c7
1 changed files with 32 additions and 0 deletions

View File

@ -164,6 +164,38 @@ VALUE_CONVERTERS = {
}
def ods_date_value(value):
return value.strftime("%Y-%m-%d")
def ods_time_value(value):
return value.strftime("PT%HH%MM%SS")
def ods_bool_value(value):
"""convert a boolean value to text"""
if value is True:
return "true"
else:
return "false"
def ods_timedelta_value(cell):
"""convert a cell value to time delta"""
hours = cell.days * 24 + cell.seconds // 3600
minutes = (cell.seconds // 60) % 60
seconds = cell.seconds % 60
return "PT%02dH%02dM%02dS" % (hours, minutes, seconds)
ODS_VALUE_CONVERTERS = {
"date": ods_date_value,
"time": ods_time_value,
"boolean": ods_bool_value,
"timedelta": ods_timedelta_value
}
VALUE_TOKEN = {
"float": "value",
"date": "date-value",