elon_py/pkg/dash/func/clock.py
NY 2bf5cf28b7 1.▶️🔄
2.修改项目结构
2025-03-05 10:24:46 +08:00

20 lines
759 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pytz
from pkg.dash.app_init import app
from dash.dependencies import Input, Output
from pkg.config import pacific,central,eastern
from datetime import datetime
# Callback for updating clocks (unchanged)
@app.callback(
[Output('pst-clock', 'children'),
Output('cst-clock', 'children'),
Output('est-clock', 'children')],
[Input('clock-interval', 'n_intervals')]
)
def update_clocks(n):
now_utc = datetime.now(pytz.UTC)
pst_time = now_utc.astimezone(pacific).strftime('%Y-%m-%d %H:%M:%S PST')
cst_time = now_utc.astimezone(central).strftime('%Y-%m-%d %H:%M:%S CST')
est_time = now_utc.astimezone(eastern).strftime('%Y-%m-%d %H:%M:%S EST')
return f"𝕏: {pst_time}", f"🚀: {cst_time}", f"🏛️/🌴: {est_time}"