From 5ca08c18134123fd5f9a457829090410221a93ce Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 26 Apr 2025 22:21:39 +0200 Subject: [feat] plugins: add new time/timezone search plugin The plugin uses the ``GeoLocation`` class, which is already implemented in the context of weather forecasts, to determine the time zone. The ``DateTime`` class is used for the localized display of date and time. Co-authored-by: Markus Heiser --- searx/weather.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'searx/weather.py') diff --git a/searx/weather.py b/searx/weather.py index 793dc09c4..cb10181a0 100644 --- a/searx/weather.py +++ b/searx/weather.py @@ -20,6 +20,7 @@ import typing import base64 import datetime import dataclasses +import zoneinfo from urllib.parse import quote_plus @@ -137,6 +138,10 @@ class GeoLocation: country_code: str # 2-Character ISO-3166-1 alpha2 country code. E.g. DE for Germany timezone: str # Time zone using time zone database definitions + @property + def zoneinfo(self) -> zoneinfo.ZoneInfo: + return zoneinfo.ZoneInfo(self.timezone) + def __str__(self): return self.name -- cgit v1.2.3