
    i\	                         d dl Zd dlZd dlmZ d dlmZ d dlmZm	Z	 ddl
mZmZ ej                  rd dlmZ d dlmZ d d	lmZ ej(                   G d
 de             Zy)    N)gettext)EngineResults)DateTimeGeoLocation   )Plugin
PluginInfo)SearchWithPlugins)SXNG_Request)	PluginCfgc                   `     e Zd ZU dZdZeed<   g dZee   ed<   d fdZ	ddd	d
de
fdZ xZS )
SXNGPluginzWPlugin to display the current time at different timezones (usually the
    query city).	time_zoneid)timetimezonenowclock	timezoneskeywordsc                     t         |   |       t        | j                  t	        d      t	        d      dddg      | _        y )NzTimezones pluginz1Display the current time on different time zones.queryztime Berlinzclock Los Angeles)r   namedescriptionpreference_sectionexamples)super__init__r	   r   r   info)selfplg_cfg	__class__s     (/root/searxng/searx/plugins/time_zone.pyr   zSXNGPlugin.__init__   sA    !ww+, ST&#%89
	    requestr   searchr
   returnc                 D    t               }|j                  j                  dkD  r|S |j                  j                  }t	         fd|j                  d            }dj                  |      j                         }|sbt        t        j                  j                               }|j                  |j                  j                  |j                                      |S t        j                   |      }|rt        t        j                  j                  |j"                              }|j$                  j'                  dd      }	|j                  |j                  j                  |	 d|j                          d	|j                  j)                  d
       d             |S )a  The plugin uses the :py:obj:`searx.weather.GeoLocation` class, which
        is already implemented in the context of weather forecasts, to determine
        the time zone. The :py:obj:`searx.weather.DateTime` class is used for
        the localized display of date and time.r   c                 <    | j                         j                  vS )N)lowerr   )partr    s    r#   <lambda>z(SXNGPlugin.post_search.<locals>.<lambda>3   s    $**,dmm*K r$    )answer)search_term)tz_z: z (z%Z))r   search_querypagenor   filtersplitjoinstripr   datetimer   addtypesAnswerl10nr   by_queryzoneinfor   replacestrftime)
r    r%   r&   resultsr   query_partsr/   	date_timegeotz_names
   `         r#   post_searchzSXNGPlugin.post_search'   sS     /%%)N ##))KU[[Y\M]^hh{+113 !2!2!6!6!89IKK,,INN4D,EFN""{; !2!2!6!6#,,!6!GHIll**34GKK$$&ivinn.>-?r)BTBTB]B]^bBcAddef %  r$   )r!   r   )__name__
__module____qualname____doc__r   str__annotations__r   listr   r   rG   __classcell__)r"   s   @r#   r   r      sC     BKHd3iK	
> ;N S` r$   r   )typingtr9   flask_babelr   searx.result_typesr   searx.weatherr   r    r   r	   TYPE_CHECKINGsearx.searchr
   searx.extended_typesr   searx.pluginsr   finalr    r$   r#   <module>r\      sH       , /  ??.1' 0 0 	0r$   