import datetime
import xlrd
def excelDateFormatter(sh, i, j, sep = "-"):
if sh.cell(i, j).ctype == 3:
cell = sh.cell_value(i, j)
date = datetime.datetime(*xlrd.xldate_as_tuple(cell, 0))
YMD = ['%Y', '%m', '%d']
return date.strftime(sep.join(YMD))
else:
return ""
def excelTimeFormatter(sh, i, j, sep = ":"):
if sh.cell(i, j).ctype == 3:
cell = sh.cell_value(i, j)
date = xlrd.xldate_as_tuple(cell, 0)
timeList = []
for j in range(3,6):
timeList.append(str(date[j]))
return sep.join(timeList)
else:
return ""