Spaces:
Sleeping
Sleeping
| import pytz | |
| import datetime | |
| def get_the_current_time_in_timezone(timezone: str) -> str: | |
| """A tool that fetches the current local time in a specified timezone.""" | |
| try: | |
| # Create timezone object | |
| tz = pytz.timezone(timezone) | |
| # Get current time in that timezone | |
| local_time = datetime.datetime.now(tz).strftime("%I:%M %p") # %I for 12-hour clock, %M for minutes, %p for AM/PM | |
| return f"The current local time in {timezone} is: {local_time}" | |
| except Exception as e: | |
| return f"Error fetching time for timezone '{timezone}': {str(e)}" | |