forked from HammerCloth/BangumiCalendar-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
28 lines (20 loc) · 769 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from datetime import datetime, date
def genUUID(projectId, epsId, userid) -> str:
return str(projectId) + "-" +str(epsId) + "-" + str(userid)
def genSummary(name, name_cn, ep) -> str:
if name_cn != "":
return name_cn + " " + str(ep)
else:
return name + " " + str(ep)
def genDec(summary, epname) -> str:
str(epname).replace("/n","\n")
return "「"+epname+"」" + "\n" + "\n"+ "\n"+ summary
def genDate(time: str) -> date:
formats = ["%Y-%m-%d", "%Y年%m月%d日"]
for fmt in formats:
try:
parsed_date = datetime.strptime(time, fmt)
return parsed_date.date()
except ValueError:
continue
raise ValueError(f"time data '{time}' does not match any supported format")