from datetime import datetime def ts_cover_str(ts=0) -> str: return datetime.fromtimestamp(ts / 1000).strftime('%Y-%m-%d %H:%M:%S') def str_cover_date(s: str): return datetime.strptime(s, '%Y-%m-%d %H:%M:%S') def timestamp_convert(ts: int) -> str: return seconds_convert(ts // 1000) def seconds_convert(seconds: int) -> str: hours = seconds // 3600 minutes = (seconds % 3600) // 60 seconds = seconds % 60 s = "" if hours > 0: s = f"{s} {hours}小时" if minutes > 0: s = f"{s} {minutes}分钟" if seconds > 0: s = f"{s} {seconds}秒" return s def date_convert_dt_hh(date_str: str) -> str: date_obj = datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S') return date_obj.strftime('%Y%m%d%H')