Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,15 +34,15 @@ def get_current_time_in_timezone(timezone: str): str
|
|
| 34 |
Returns:
|
| 35 |
The current local time in the string format %Y-%m-%d %H:%M:%S (e.g., '2015-09-14 04:20:00')
|
| 36 |
"""
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
| 46 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 47 |
|
| 48 |
|
|
|
|
| 34 |
Returns:
|
| 35 |
The current local time in the string format %Y-%m-%d %H:%M:%S (e.g., '2015-09-14 04:20:00')
|
| 36 |
"""
|
| 37 |
+
try:
|
| 38 |
+
# Create timezone object
|
| 39 |
+
tz = pytz.timezone(timezone)
|
| 40 |
|
| 41 |
+
# Get current time in that timezone
|
| 42 |
+
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
| 43 |
+
return f"The current local time in {timezone} is: {local_time}"
|
| 44 |
|
| 45 |
+
except Exception as e:
|
| 46 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 47 |
|
| 48 |
|