Spaces:
Runtime error
Runtime error
| from agentpro.tools import Tool | |
| from typing import Any | |
| import datetime | |
| import pytz | |
| class CurrentDateTimeTool(Tool): | |
| # 1) Class attributes (Pydantic fields) | |
| name: str = "Current DateTime" | |
| description: str = "Get the current day, time, year, and month" | |
| action_type: str = "current_date_time_pst" | |
| input_format: str = "Any input; this tool returns the current date/time." | |
| def run(self, input_text: Any) -> str: | |
| """ | |
| Ignores the input_text and returns: | |
| • Current weekday name (e.g., Monday) | |
| • Current time (HH:MM:SS) in Pakistan Standard Time | |
| • Current year (YYYY) | |
| • Current month name (e.g., June) | |
| """ | |
| now_pkt = datetime.datetime.now() | |
| weekday = now_pkt.strftime("%A") # e.g., "Friday" | |
| time_str = now_pkt.strftime("%I:%M %p") # e.g., "07:45 PM" | |
| year_str = now_pkt.strftime("%Y") # e.g., "2025" | |
| month = now_pkt.strftime("%B") # e.g., "June" | |
| date_str = now_pkt.strftime("%d %B %Y") # e.g., "05 June 2025" | |
| return ( | |
| f"Day of week: {weekday}\n" | |
| f"Current time: {time_str}\n" | |
| f"Date: {date_str}\n" | |
| f"Year: {year_str}\n" | |
| f"Month: {month}" | |
| ) |