ziyuzhou02 commited on
Commit
1b19ebd
·
verified ·
1 Parent(s): df09e67

Format last eval timestamp as UTC+8

Browse files
Files changed (1) hide show
  1. src/display/formatting.py +17 -0
src/display/formatting.py CHANGED
@@ -1,3 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  def model_hyperlink(model_link: str, code_link: str, model_name: str) -> str:
2
  if not model_link:
3
  return model_name
 
1
+ from datetime import datetime, timedelta, timezone
2
+
3
+ UTC8 = timezone(timedelta(hours=8))
4
+
5
+
6
+ def format_timestamp_utc8(iso: str) -> str:
7
+ """Format ISO-8601 timestamp as readable UTC+8 datetime."""
8
+ if not iso or iso == "n/a":
9
+ return "n/a"
10
+ try:
11
+ dt = datetime.fromisoformat(iso.replace("Z", "+00:00"))
12
+ local = dt.astimezone(UTC8)
13
+ return local.strftime("%Y-%m-%d %H:%M:%S") + " (UTC+8)"
14
+ except (ValueError, TypeError):
15
+ return iso
16
+
17
+
18
  def model_hyperlink(model_link: str, code_link: str, model_name: str) -> str:
19
  if not model_link:
20
  return model_name