def fmt_date(numericdate, dt_type, dt_fmt=None):
"""
This static method accepts a date and converts it to
the format used in the timeseries.
"""
if dt_type == TS_ORDINAL:
if dt_fmt is None:
dt_fmt = FMT_DATE
return datetime.fromordinal(int(numericdate)).strftime(dt_fmt)
elif dt_type == TS_TIMESTAMP:
if dt_fmt is None:
dt_fmt = FMT_IDATE
return datetime.fromtimestamp(numericdate).strftime(dt_fmt)
else:
raise ValueError("Unknown dt_type: %s" % dt_type)
评论列表
文章目录