Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from datetime import datetime | |
| from zoneinfo import ZoneInfo | |
| def get_times(): | |
| zones = { | |
| "π½ New York": "America/New_York", | |
| "π€ Texas": "America/Chicago", | |
| "π Denver": "America/Denver", | |
| "π΄ California": "America/Los_Angeles", | |
| "β Alaska": "America/Anchorage", | |
| "πΊ Hawaii": "Pacific/Honolulu" | |
| } | |
| text = "πΊπΈ USA LIVE CLOCK\n\n" | |
| for city, zone in zones.items(): | |
| now = datetime.now(ZoneInfo(zone)) | |
| text += f""" | |
| {city} | |
| β° Time : {now.strftime('%I:%M:%S %p')} | |
| π Date : {now.strftime('%d-%m-%Y')} | |
| π Day : {now.strftime('%A')} | |
| """ | |
| return text | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# πΊπΈ USA Digital Clock") | |
| output = gr.Textbox( | |
| value=get_times(), | |
| lines=30, | |
| label="USA Time" | |
| ) | |
| refresh = gr.Button("π Refresh") | |
| refresh.click( | |
| fn=get_times, | |
| outputs=output | |
| ) | |
| demo.launch() |