Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,9 +16,11 @@ def countdown_to_new_year(timezone: str):
|
|
16 |
# Define the target date and time for New Year 2025
|
17 |
new_year_2025 = tz.localize(datetime(2025, 1, 1, 0, 0, 0))
|
18 |
|
19 |
-
#
|
20 |
if now >= new_year_2025:
|
21 |
-
return "Happy New Year 2025
|
|
|
|
|
22 |
time_remaining = new_year_2025 - now
|
23 |
|
24 |
# Extract days, hours, minutes, and seconds
|
@@ -28,7 +30,10 @@ def countdown_to_new_year(timezone: str):
|
|
28 |
minutes = (seconds % 3600) // 60
|
29 |
seconds = seconds % 60
|
30 |
|
31 |
-
return
|
|
|
|
|
|
|
32 |
except Exception as e:
|
33 |
return f"Error: {str(e)}"
|
34 |
|
@@ -49,7 +54,7 @@ def build_interface():
|
|
49 |
value="UTC"
|
50 |
)
|
51 |
|
52 |
-
countdown_display = gr.Textbox(label="Time
|
53 |
|
54 |
calculate_button = gr.Button("Calculate Countdown")
|
55 |
|
|
|
16 |
# Define the target date and time for New Year 2025
|
17 |
new_year_2025 = tz.localize(datetime(2025, 1, 1, 0, 0, 0))
|
18 |
|
19 |
+
# Check if New Year has already passed
|
20 |
if now >= new_year_2025:
|
21 |
+
return f"Happy New Year 2025!\nCurrent time in {timezone}: {now.strftime('%Y-%m-%d %H:%M:%S')}"
|
22 |
+
|
23 |
+
# Calculate the time remaining
|
24 |
time_remaining = new_year_2025 - now
|
25 |
|
26 |
# Extract days, hours, minutes, and seconds
|
|
|
30 |
minutes = (seconds % 3600) // 60
|
31 |
seconds = seconds % 60
|
32 |
|
33 |
+
return (
|
34 |
+
f"{days} days, {hours} hours, {minutes} minutes, {seconds} seconds remaining\n"
|
35 |
+
f"Current time in {timezone}: {now.strftime('%Y-%m-%d %H:%M:%S')}"
|
36 |
+
)
|
37 |
except Exception as e:
|
38 |
return f"Error: {str(e)}"
|
39 |
|
|
|
54 |
value="UTC"
|
55 |
)
|
56 |
|
57 |
+
countdown_display = gr.Textbox(label="Countdown and Current Time", interactive=False)
|
58 |
|
59 |
calculate_button = gr.Button("Calculate Countdown")
|
60 |
|