peterpeter8585 commited on
Commit
d167a15
Β·
verified Β·
1 Parent(s): d60e9d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -102,16 +102,27 @@ def file_delete(filename: str) -> str:
102
  # ──────────────────────────────
103
  # βœ… μ •ν™•ν•œ ν•œκ΅­ μ‹œκ°„ ν•¨μˆ˜ (Asia/Seoul)
104
  # ──────────────────────────────
 
105
  from datetime import datetime
106
- from zoneinfo import ZoneInfo # Python 3.9 이상 λ‚΄μž₯
107
 
108
  def time_now(_=""):
109
  try:
 
 
 
 
 
 
 
 
 
 
 
 
110
  tz = ZoneInfo("Asia/Seoul")
111
  now = datetime.now(tz)
112
- return f"ν˜„μž¬ μ‹œκ°: {now.strftime('%Y-%m-%d %H:%M:%S')} (Asia/Seoul)"
113
- except Exception as e:
114
- return f"⚠️ μ‹œκ°„ 계산 였λ₯˜: {e}"
115
  # ──────────────────────────────
116
  # βœ… 도ꡬ 등둝
117
  # ──────────────────────────────
 
102
  # ──────────────────────────────
103
  # βœ… μ •ν™•ν•œ ν•œκ΅­ μ‹œκ°„ ν•¨μˆ˜ (Asia/Seoul)
104
  # ──────────────────────────────
105
+ import requests
106
  from datetime import datetime
107
+ from zoneinfo import ZoneInfo
108
 
109
  def time_now(_=""):
110
  try:
111
+ # μ •ν™•ν•œ UTC μ‹œκ°μ„ μ™ΈλΆ€ APIμ—μ„œ κ°€μ Έμ˜΄
112
+ resp = requests.get("https://timeapi.io/api/Time/current/zone?timeZone=Asia/Seoul", timeout=5)
113
+ if resp.status_code == 200:
114
+ data = resp.json()
115
+ dt = data["dateTime"].split(".")[0].replace("T", " ")
116
+ return f"ν˜„μž¬ μ‹œκ°: {dt} (Asia/Seoul, μ„œλ²„ κΈ°μ€€ NTP 동기화)"
117
+ else:
118
+ # API μ‹€νŒ¨ μ‹œ 둜컬 μ‹œμŠ€ν…œ μ‹œκ°μœΌλ‘œ λŒ€μ²΄
119
+ tz = ZoneInfo("Asia/Seoul")
120
+ now = datetime.now(tz)
121
+ return f"ν˜„μž¬ μ‹œκ°(둜컬): {now.strftime('%Y-%m-%d %H:%M:%S')} (Asia/Seoul)"
122
+ except Exception as e:
123
  tz = ZoneInfo("Asia/Seoul")
124
  now = datetime.now(tz)
125
+ return f"ν˜„μž¬ μ‹œκ°(λ°±μ—…): {now.strftime('%Y-%m-%d %H:%M:%S')} (Asia/Seoul, 였λ₯˜: {e})"
 
 
126
  # ──────────────────────────────
127
  # βœ… 도ꡬ 등둝
128
  # ──────────────────────────────