.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.weather.DateTime Class Reference

Public Member Functions

 __init__ (self, datetime.datetime time)
 
 __str__ (self)
 
str l10n (self, DateTimeFormats|str fmt="medium", babel.Locale|GeoLocation|None locale=None)
 

Public Attributes

 datetime = time
 

Detailed Description

Class to represent date & time.  Essentially, it is a wrapper that
conveniently combines :py:obj:`datetime.datetime` and
:py:obj:`babel.dates.format_datetime`.  A conversion of time zones is not
provided (in the current version).

Definition at line 198 of file weather.py.

Constructor & Destructor Documentation

◆ __init__()

searx.weather.DateTime.__init__ ( self,
datetime.datetime time )

Definition at line 205 of file weather.py.

205 def __init__(self, time: datetime.datetime):
206 self.datetime = time
207

Member Function Documentation

◆ __str__()

searx.weather.DateTime.__str__ ( self)

Definition at line 208 of file weather.py.

208 def __str__(self):
209 return self.l10n()
210

References l10n().

+ Here is the call graph for this function:

◆ l10n()

str searx.weather.DateTime.l10n ( self,
DateTimeFormats | str fmt = "medium",
babel.Locale | GeoLocation | None locale = None )
Localized representation of date & time.

Definition at line 211 of file weather.py.

215 ) -> str:
216 """Localized representation of date & time."""
217 if isinstance(locale, GeoLocation):
218 locale = locale.locale()
219 elif locale is None:
220 locale = babel.Locale.parse(_get_sxng_locale_tag(), sep='-')
221 return babel.dates.format_datetime(self.datetime, format=fmt, locale=locale)
222
223

References searx.weather._get_sxng_locale_tag(), searx.result_types.answer.WeatherAnswer.Item.datetime, and datetime.

Referenced by searx.weather.Compass.__str__(), __str__(), searx.weather.Pressure.__str__(), searx.weather.RelativeHumidity.__str__(), searx.weather.Temperature.__str__(), and searx.weather.WindSpeed.__str__().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ datetime

searx.weather.DateTime.datetime = time

Definition at line 206 of file weather.py.

Referenced by l10n().


The documentation for this class was generated from the following file: