excelDateFormatter.py

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 ""
上一篇:How to Install ClamAV on Ubuntu 20.04 and Scan for Vulnerabilities


下一篇:源码分析 | 使用 gcov 和 lcov 测试 PostgreSQL 代码覆盖率