wladimir commited on
Commit
2091bdb
·
verified ·
1 Parent(s): 6e4ee26

Create get_current_time_in_timezone.py

Browse files
tools/get_current_time_in_timezone.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @tool
2
+ def get_current_time_in_timezone(timezone: str) -> str:
3
+ """A tool that fetches the current local time in a specified timezone.
4
+ Args:
5
+ timezone: A string representing a valid timezone (e.g., 'America/New_York').
6
+ """
7
+ try:
8
+ # Create timezone object
9
+ tz = pytz.timezone(timezone)
10
+ # Get current time in that timezone
11
+ local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
12
+ return f"The current local time in {timezone} is: {local_time}"
13
+ except Exception as e:
14
+ return f"Error fetching time for timezone '{timezone}': {str(e)}"