Tool
CW_NTP
CW-NTP retrieves the exact current date and time from an internet time server in the Detroit, USA time zone. Every response is prefaced with this accurate timestamp, and it is used for all time-tracked user requests or document creation, ensuring precision across time-sensitive tasks.
Tool ID
cw_ntp
Creator
@mleedix
Downloads
44+

Tool Content
python
import requests
from datetime import datetime
import pytz

class Tools:
    """
    CW_NTP Tool to retrieve and display the current date and time in Detroit, USA.
    """

    def get_detroit_time(self) -> str:
        """
        Fetches the current time from an internet time server, formatted for Detroit, USA.
        """
        try:
            response = requests.get("http://worldtimeapi.org/api/timezone/America/Detroit")
            response.raise_for_status()
            data = response.json()
            detroit_time = datetime.fromisoformat(data["datetime"]).astimezone(pytz.timezone("America/Detroit"))
            return detroit_time.strftime("%A, %B %d, %Y %I:%M:%S %p (Detroit Local Time)")
        except requests.RequestException:
            return "Unable to fetch current time."

    def preface_with_time(self, text: str) -> str:
        """
        Adds the Detroit timestamp to the start of a response.
        """
        current_time = self.get_detroit_time()
        return f"{current_time}\n\n{text}"