admin commited on
Commit
8b93af5
1 Parent(s): 61cd014

fix datetime

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import json
3
  import time
4
  import requests
@@ -8,12 +9,25 @@ import pandas as pd
8
  from tqdm import tqdm
9
  from functools import partial
10
  from bs4 import BeautifulSoup
 
11
  from urllib.parse import urlparse
12
 
13
  TIMEOUT = 15
14
  DELAY = 1
15
 
16
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  def get_studios(username: str):
18
  # 请求负载
19
  payload = {
@@ -213,7 +227,9 @@ def list_tasks():
213
  jobs = schedule.get_jobs()
214
  if jobs:
215
  details = f"{jobs}".replace("[", "").replace("]", "")
216
- return details.split("functools.")[0] + "(" + details.split(") (")[-1]
 
 
217
 
218
  return "None"
219
 
 
1
  import os
2
+ import re
3
  import json
4
  import time
5
  import requests
 
9
  from tqdm import tqdm
10
  from functools import partial
11
  from bs4 import BeautifulSoup
12
+ from datetime import datetime, timedelta
13
  from urllib.parse import urlparse
14
 
15
  TIMEOUT = 15
16
  DELAY = 1
17
 
18
 
19
+ def fix_datetime(text: str):
20
+ datetime_pattern = r"\b\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\b"
21
+
22
+ def add_six_hours(match):
23
+ datetime_str = match.group(0)
24
+ dt = datetime.strptime(datetime_str, "%Y-%m-%d %H:%M:%S")
25
+ dt_plus_six = dt + timedelta(hours=6)
26
+ return dt_plus_six.strftime("%Y-%m-%d %H:%M:%S")
27
+
28
+ return re.sub(datetime_pattern, add_six_hours, text)
29
+
30
+
31
  def get_studios(username: str):
32
  # 请求负载
33
  payload = {
 
227
  jobs = schedule.get_jobs()
228
  if jobs:
229
  details = f"{jobs}".replace("[", "").replace("]", "")
230
+ return fix_datetime(
231
+ details.split("functools.")[0] + "(" + details.split(") (")[-1]
232
+ )
233
 
234
  return "None"
235