jf{ZUdZddlmZddlZddlZddlmZddlmZm Z  ddl Z n#e $r dZ ddl Z YnwxYwddl Z ddlmZddlmZddlmZmZmZdd lmZeradd lmZmZe je jzezdzZd ed <ed Z d ed<edZ!d ed<e j e j"ze#ze$ze jzdzZ%d ed<dZ&e j'j(Z)ej*Z*edZ+ddZ,ddZ-ddZ.dd Z/ddd#Z0 ddd'Z1ddd*Z2d+d,e+fdd3Z3d+d4e+fdd6Z4d+d4e+fdd7Z5d+d4e+fdd8Z6d+e+fdd9Z7d:e+fdd<Z8d:e+fdd=Z9d:e+fdd>Z:dd?e+d@fddEZ;de+d@fddGZdd:de+fddRZ?dd:de+fddTZ@dddUe+fddXZAdYZBdZed[<d\d]d@d?e+fddfZCe+fddjZDdddUe+fddkZEdde+fddnZFGdodpeGZHe+d:fddsZIe+d:fddtZJGdud;ZKGdvdwZLidxgdydzdd{dd|dd}gdyd~gdydgdydgdydddgddgdddgdgdddgdddgddgddgdidgdydgdydgdydddgdddgdddgdddgdddgdddgdddddgddgdydddgdddgdgddgdydgdyiZMded<dZNddZOedddZPddZQddZRddZSdddZTdS)a babel.dates ~~~~~~~~~~~ Locale dependent formatting and parsing of dates and times. The default locale for the functions in this module is determined by the following environment variables, in that order: * ``LC_TIME``, * ``LC_ALL``, and * ``LANG`` :copyright: (c) 2013-2023 by the Babel Team. :license: BSD, see LICENSE for more details. ) annotationsN) lru_cache) TYPE_CHECKING SupportsInt)Iterable) localtime)Localedefault_locale get_global)LocaleDataDict)Literal TypeAliasr_Instantfulllongmediumshort_PredefinedTimeFormat)format stand-alone_Context _DtOrTzinfou ∅∅∅LC_TIMEtzdatetime.tzinfodtdatetime.datetimereturnc|j|ur|St|dr||S|j||S||S)Nlocalizetzinfo)r#hasattrr!replace astimezone)rrs k/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/babel/dates.py _localizer(<sf yB r:{{2 yzzz$$$ ==   dt_or_tzinfo0tuple[datetime.datetime | None, datetime.tzinfo]c|&tj}t}nt|trd}t |}nnt|t r d}t}nOt|tjtjfr%t|}|j |j nt}nd}|}||fS)z Parse a `dt_or_tzinfo` value into a datetime and a tzinfo. See the docs for this function's callers for semantics. :rtype: tuple[datetime, tzinfo] N) datetimenowLOCALTZ isinstancestr get_timezoneintUTCtime _get_datetimer#r*rr#s r'_get_dt_and_tzinfor8Ms   " " $ $ L# & &  l++ L# & &  L8#4hm"D E E < ( ( i3  v:r)r1ct|\}}t|dr|jSt|dr|j|jS||pt jS)z[ Get the timezone name out of a time, datetime, or tzinfo object. :rtype: str zonekey)r8r$r:r;tznamer-utcnowr7s r' _get_tz_namer>gsv $L11JBvv?{   ?FJ$:z}}R=8#4#;#;#=#=>>>r)instantc2|tjSt|ttfrtj|St|tjr>> from datetime import date, datetime >>> _get_datetime(date(2015, 1, 1)) datetime.datetime(2015, 1, 1, 0, 0) UNIX timestamps are converted to datetimes. >>> _get_datetime(1400000000) datetime.datetime(2014, 5, 13, 16, 53, 20) Other values are passed through as-is. >>> x = datetime(2015, 1, 1) >>> _get_datetime(x) is x True :param instant: date, time, datetime, integer, float or None :type instant: date|time|datetime|int|float|None :return: a datetime :rtype: datetime ) r-r=r0r3floatutcfromtimestampr5combinedatetoday)r?s r'r6r6vs> ''))) Gc5\ * *C 11'::: GX] + +C (()<)<)>)>HHH GX] + +CJwHY4Z4ZC (((-//BBB Nr)r#datetime.tzinfo | Nonec|j|t}|G|t |}t |dr||}|S)aS Ensure the datetime passed has an attached tzinfo. If the datetime is tz-naive to begin with, UTC is attached. If a tzinfo is passed in, the datetime is normalized to that timezone. >>> from datetime import datetime >>> _get_tz_name(_ensure_datetime_tzinfo(datetime(2015, 1, 1))) 'UTC' >>> tz = get_timezone("Europe/Stockholm") >>> _ensure_datetime_tzinfo(datetime(2015, 1, 1, 13, 15, tzinfo=UTC), tzinfo=tz).hour 14 :param datetime: Datetime to augment. :param tzinfo: optional tzinfo :return: datetime with tzinfo :rtype: datetime Nr" normalize)r#r%r4r&r2r$rH)rr#s r'_ensure_datetime_tzinforIsh* y ZZsZ # #  ]]<// 0 0 6; ' ' &!!"%%B Ir)r5(datetime.time | datetime.datetime | None datetime.timec|tj}n;t|ttfrtj|}|j|t}t|tjrQ|:| |}t|dr| |}| }n|||}|S)z Get a timezoned time from a given instant. .. warning:: The return values of this function may depend on the system clock. :param time: time, datetime or None :rtype: time Nr"rH) r-r=r0r3rArBr#r%r4r&r$rHtimetz)r5r#s r' _get_timerNs | '')) D3, ' '8 11$77 {||3|''$)**+  ??6**Dv{++ .''--{{}}  ||6|** Kr)r:str | datetime.tzinfo | NonecT|tSt|ts|Str3 tj|S#tj$r }|}Yd}~nDd}~wwxYwt sJ t j|S#t j$r }|}Yd}~nd}~wwxYwtd||)aLooks up a timezone by name and returns it. The timezone object returned comes from ``pytz`` or ``zoneinfo``, whichever is available. It corresponds to the `tzinfo` interface and can be used with all of the functions of Babel that operate with dates. If a timezone is not known a :exc:`LookupError` is raised. If `zone` is ``None`` a local zone object is returned. :param zone: the name of the timezone to look up. If a timezone object itself is passed in, it's returned unchanged. NzUnknown timezone ) r/r0r1pytztimezoneUnknownTimeZoneErrorzoneinfoZoneInfoZoneInfoNotFoundError LookupError)r:eexcs r'r2r2s | dC    =&& &(   CCCCCC x $T** *-   CCCCCC  0$00 1 1s:s-=A AA%A99BBBwiderwidth(Literal['abbreviated', 'narrow', 'wide']contextlocaleLocale | str | Noner cLtj|j||S)aGReturn the names for day periods (AM/PM) used by the locale. >>> get_period_names(locale='en_US')['am'] u'AM' :param width: the width to use, one of "abbreviated", "narrow", or "wide" :param context: the context, either "format" or "stand-alone" :param locale: the `Locale` object, or a locale string )r parse day_periodsr[r]r^s r'get_period_namesrds! <   +G 4U ;;r)r1Literal['abbreviated', 'narrow', 'short', 'wide']cLtj|j||S)a*Return the day names used by the locale for the specified format. >>> get_day_names('wide', locale='en_US')[1] u'Tuesday' >>> get_day_names('short', locale='en_US')[1] u'Tu' >>> get_day_names('abbreviated', locale='es')[1] u'mar' >>> get_day_names('narrow', context='stand-alone', locale='de_DE')[1] u'D' :param width: the width to use, one of "wide", "abbreviated", "short" or "narrow" :param context: the context, either "format" or "stand-alone" :param locale: the `Locale` object, or a locale string )r radaysrcs r' get_day_namesrh s!" <   $W -e 44r)cLtj|j||S)aReturn the month names used by the locale for the specified format. >>> get_month_names('wide', locale='en_US')[1] u'January' >>> get_month_names('abbreviated', locale='es')[1] u'ene' >>> get_month_names('narrow', context='stand-alone', locale='de_DE')[1] u'J' :param width: the width to use, one of "wide", "abbreviated", or "narrow" :param context: the context, either "format" or "stand-alone" :param locale: the `Locale` object, or a locale string )r ramonthsrcs r'get_month_namesrk s! <   &w / 66r)cLtj|j||S)aReturn the quarter names used by the locale for the specified format. >>> get_quarter_names('wide', locale='en_US')[1] u'1st quarter' >>> get_quarter_names('abbreviated', locale='de_DE')[1] u'Q1' >>> get_quarter_names('narrow', locale='de_DE')[1] u'1' :param width: the width to use, one of "wide", "abbreviated", or "narrow" :param context: the context, either "format" or "stand-alone" :param locale: the `Locale` object, or a locale string )r raquartersrcs r'get_quarter_namesrn2s! <   ( 1% 88r)c@tj|j|S)a\Return the era names used by the locale for the specified format. >>> get_era_names('wide', locale='en_US')[1] u'Anno Domini' >>> get_era_names('abbreviated', locale='de_DE')[1] u'n. Chr.' :param width: the width to use, either "wide", "abbreviated", or "narrow" :param locale: the `Locale` object, or a locale string )r raerasr[r^s r' get_era_namesrrDs <   $U ++r)rDateTimePatternc@tj|j|S)aReturn the date formatting patterns used by the locale for the specified format. >>> get_date_format(locale='en_US') >>> get_date_format('full', locale='de_DE') :param format: the format to use, one of "full", "long", "medium", or "short" :param locale: the `Locale` object, or a locale string )r ra date_formatsrr^s r'get_date_formatrwS <   ,V 44r)cPtj|j}||vrd}||S)a;Return the datetime formatting patterns used by the locale for the specified format. >>> get_datetime_format(locale='en_US') u'{1}, {0}' :param format: the format to use, one of "full", "long", "medium", or "short" :param locale: the `Locale` object, or a locale string N)r radatetime_formats)rr^patternss r'get_datetime_formatr|cs1|F##4H X F r)c@tj|j|S)uReturn the time formatting patterns used by the locale for the specified format. >>> get_time_format(locale='en_US') >>> get_time_format('full', locale='de_DE') :param format: the format to use, one of "full", "long", "medium", or "short" :param locale: the `Locale` object, or a locale string )r ra time_formatsrvs r'get_time_formatrtrxr)rFr-4Literal['long', 'short', 'iso8601', 'iso8601_short']return_zboolctt|}tj|}|j|}|jdzdzdz|jz}t|d\}}|r|dkr|dkrdS|dkr |dkrd|zS|dks|dkrd }n|d krd }n|j d d z}|||dzfzS) aReturn the timezone associated with the given `datetime` object formatted as string indicating the offset from GMT. >>> from datetime import datetime >>> dt = datetime(2007, 4, 1, 15, 30) >>> get_timezone_gmt(dt, locale='en') u'GMT+00:00' >>> get_timezone_gmt(dt, locale='en', return_z=True) 'Z' >>> get_timezone_gmt(dt, locale='en', width='iso8601_short') u'+00' >>> tz = get_timezone('America/Los_Angeles') >>> dt = _localize(tz, datetime(2007, 4, 1, 15, 30)) >>> get_timezone_gmt(dt, locale='en') u'GMT-07:00' >>> get_timezone_gmt(dt, 'short', locale='en') u'-0700' >>> get_timezone_gmt(dt, locale='en', width='iso8601_short') u'-07' The long format depends on the locale, for example in France the acronym UTC string is used instead of GMT: >>> get_timezone_gmt(dt, 'long', locale='fr_FR') u'UTC-07:00' .. versionadded:: 0.9 :param datetime: the ``datetime`` object; if `None`, the current date and time in UTC is used :param width: either "long" or "short" or "iso8601" or "iso8601_short" :param locale: the `Locale` object, or a locale string :param return_z: True or False; Function returns indicator "Z" when local time offset is 0 <rZ iso8601_shortz%+03drz %+03d%02diso8601z %+03d:%02dgmt) rIr6r rar# utcoffsetrgsecondsdivmod zone_formats)r-r[r^roffsetrhourspatterns r'get_timezone_gmtrsR'}X'>'>??H \& ! !F _ & &x 0 0FkB#b(6>9GGT**NE7 >> tz = get_timezone('America/St_Johns') >>> print(get_timezone_location(tz, locale='de_DE')) Kanada (St. John’s) (Ortszeit) >>> print(get_timezone_location(tz, locale='en')) Canada (St. John’s) Time >>> print(get_timezone_location(tz, locale='en', return_city=True)) St. John’s >>> tz = get_timezone('America/Mexico_City') >>> get_timezone_location(tz, locale='de_DE') u'Mexiko (Mexiko-Stadt) (Ortszeit)' If the timezone is associated with a country that uses only a single timezone, just the localized country name is returned: >>> tz = get_timezone('Europe/Berlin') >>> get_timezone_name(tz, locale='de_DE') u'Mitteleurop\xe4ische Zeit' .. versionadded:: 0.9 :param dt_or_tzinfo: the ``datetime`` or ``tzinfo`` object that determines the timezone; if `None`, the current date and time in UTC is assumed :param locale: the `Locale` object, or a locale string :param return_city: True or False, if True then return exemplar city (location) for the time zone :return: the localized timezone name using location format zone_aliasesregionzone_territoriesZZterritory_zonesfallbackcity meta_zones/_ )01) r rar>r get time_zonesr territorieslenrsplitr%) r*r^rr:info region_format territoryterritory_namefallback_format city_namemetazone metazone_infos r'get_timezone_locationrsN\& ! !F  % %D n % % ) )$ 5 5D   r * *D'1M-..22488I*** ' 2N .9.Z8I-J-J-N-NyZ\-]-])^)^bc)c)c~--)*5O ~~L l++//55)--h;; ] " "%f-II D[[ 3**1-55c3??II S#..I O  // r)Literal['long', 'short']uncommon zone_variant1Literal['generic', 'daylight', 'standard'] | None return_zonect|\}}tj|}t|}|!|d}n/||} | rdnd}n|dvrt dt d||}|r|S|j|i} || vr|| |vr| ||St d|} | rx|j | i} || vrY| ||} |d kr4| tkr)| d i|} | r| S|t||| St|| S) a1 Return the localized display name for the given timezone. The timezone may be specified using a ``datetime`` or `tzinfo` object. >>> from datetime import time >>> dt = time(15, 30, tzinfo=get_timezone('America/Los_Angeles')) >>> get_timezone_name(dt, locale='en_US') u'Pacific Standard Time' >>> get_timezone_name(dt, locale='en_US', return_zone=True) 'America/Los_Angeles' >>> get_timezone_name(dt, width='short', locale='en_US') u'PST' If this function gets passed only a `tzinfo` object and no concrete `datetime`, the returned display name is independent of daylight savings time. This can be used for example for selecting timezones, or to set the time of events that recur across DST changes: >>> tz = get_timezone('America/Los_Angeles') >>> get_timezone_name(tz, locale='en_US') u'Pacific Time' >>> get_timezone_name(tz, 'short', locale='en_US') u'PT' If no localized display name for the timezone is available, and the timezone is associated with a country that uses only a single timezone, the name of that country is returned, formatted according to the locale: >>> tz = get_timezone('Europe/Berlin') >>> get_timezone_name(tz, locale='de_DE') u'Mitteleurop\xe4ische Zeit' >>> get_timezone_name(tz, locale='pt_BR') u'Hor\xe1rio da Europa Central' On the other hand, if the country uses multiple timezones, the city is also included in the representation: >>> tz = get_timezone('America/St_Johns') >>> get_timezone_name(tz, locale='de_DE') u'Neufundland-Zeit' Note that short format is currently not supported for all timezones and all locales. This is partially because not every timezone has a short code in every locale. In that case it currently falls back to the long format. For more information see `LDML Appendix J: Time Zone Display Names `_ .. versionadded:: 0.9 .. versionchanged:: 1.0 Added `zone_variant` support. :param dt_or_tzinfo: the ``datetime`` or ``tzinfo`` object that determines the timezone; if a ``tzinfo`` object is used, the resulting display name will be generic, i.e. independent of daylight savings time; if `None`, the current date in UTC is assumed :param width: either "long" or "short" :param uncommon: deprecated and ignored :param zone_variant: defines the zone variation to return. By default the variation is defined from the datetime object passed in. If no datetime object is passed in, the ``'generic'`` variation is assumed. The following values are valid: ``'generic'``, ``'daylight'`` and ``'standard'``. :param locale: the `Locale` object, or a locale string :param return_zone: True or False. If true then function returns long time zone ID Ngenericdaylightstandard)rrrzInvalid zone variationrrrrrqr^) r8r rar>dst ValueErrorr rrrNO_INHERITANCE_MARKERrr)r*r[rr^rrrr#r:rrrrnames r'get_timezone_namers\$L11JB \& ! !F  % %D :$LL**R..C),<::*LL B B B566 6 n % % ) )$ 5 5D   r * *D }}e44E{<((,''++D11H )--h;; M ! ! '++L99DD,A$A$A%((4488FF   ~%???? f = = ==r)rDdatetime.date | None_PredefinedTimeFormat | strc<|tj}n.t|tjr|}t j|}|dvrt ||}t|}|||S)aReturn a date formatted according to the given pattern. >>> from datetime import date >>> d = date(2007, 4, 1) >>> format_date(d, locale='en_US') u'Apr 1, 2007' >>> format_date(d, format='full', locale='de_DE') u'Sonntag, 1. April 2007' If you don't want to use the locale default formats, you can specify a custom date pattern: >>> format_date(d, "EEE, MMM d, ''yy", locale='en') u"Sun, Apr 1, '07" :param date: the ``date`` or ``datetime`` object; if `None`, the current date is used :param format: one of "full", "long", "medium", or "short", or a custom date/time pattern :param locale: a `Locale` object or a locale identifier Nrr) r-rDrEr0r rarw parse_patternapply)rDrr^rs r' format_daters4 |}""$$ D(+ , ,yy{{ \& ! !F 444 777F##G ==v & &&r)c tt||}tj|}|dvrnt ||dddt ||d|dt|||St| ||S) uReturn a date formatted according to the given pattern. >>> from datetime import datetime >>> dt = datetime(2007, 4, 1, 15, 30) >>> format_datetime(dt, locale='en_US') u'Apr 1, 2007, 3:30:00\u202fPM' For any pattern requiring the display of the timezone: >>> format_datetime(dt, 'full', tzinfo=get_timezone('Europe/Paris'), ... locale='fr_FR') 'dimanche 1 avril 2007, 17:30:00 heure d’été d’Europe centrale' >>> format_datetime(dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz", ... tzinfo=get_timezone('US/Eastern'), locale='en') u'2007.04.01 AD at 11:30:00 EDT' :param datetime: the `datetime` object; if `None`, the current date and time is used :param format: one of "full", "long", "medium", or "short", or a custom date/time pattern :param tzinfo: the timezone to apply to the time for display :param locale: a `Locale` object or a locale identifier rr'{0}Nr#r^{1}) rIr6r rar|r% format_timerrr)r-rr#r^s r'format_datetimers:'}X'>'>GGH \& ! !F 444"6&999 WS"   WUK&/577788 WUK&HHH I I  J V$$**8V<<>> from datetime import datetime, time >>> t = time(15, 30) >>> format_time(t, locale='en_US') u'3:30:00\u202fPM' >>> format_time(t, format='short', locale='de_DE') u'15:30' If you don't want to use the locale default formats, you can specify a custom time pattern: >>> format_time(t, "hh 'o''clock' a", locale='en') u"03 o'clock PM" For any pattern requiring the display of the time-zone a timezone has to be specified explicitly: >>> t = datetime(2007, 4, 1, 15, 30) >>> tzinfo = get_timezone('Europe/Paris') >>> t = _localize(tzinfo, t) >>> format_time(t, format='full', tzinfo=tzinfo, locale='fr_FR') '15:30:00 heure d’été d’Europe centrale' >>> format_time(t, "hh 'o''clock' a, zzzz", tzinfo=get_timezone('US/Eastern'), ... locale='en') u"09 o'clock AM, Eastern Daylight Time" As that example shows, when this function gets passed a ``datetime.datetime`` value, the actual time in the formatted string is adjusted to the timezone specified by the `tzinfo` parameter. If the ``datetime`` is "naive" (i.e. it has no associated timezone information), it is assumed to be in UTC. These timezone calculations are **not** performed if the value is of type ``datetime.time``, as without date information there's no way to determine what a given time would translate to in a different timezone without information about whether daylight savings time is in effect or not. This means that time values are left as-is, and the value of the `tzinfo` parameter is only used to display the timezone name if needed: >>> t = time(15, 30) >>> format_time(t, format='full', tzinfo=get_timezone('Europe/Paris'), ... locale='fr_FR') u'15:30:00 heure normale d\u2019Europe centrale' >>> format_time(t, format='full', tzinfo=get_timezone('US/Eastern'), ... locale='en_US') u'3:30:00\u202fPM Eastern Standard Time' :param time: the ``time`` or ``datetime`` object; if `None`, the current time in UTC is used :param format: one of "full", "long", "medium", or "short", or a custom date/time pattern :param tzinfo: the time-zone to apply to the time for display :param locale: a `Locale` object or a locale identifier Nrr)reference_date) r0r-rDrNr rarrr)r5rr#r^ref_dates r'rrs~)x/@AAKtyy{{{tH T6 " "D \& ! !F 444 777  & &tVH & M MMr)Tskeletonfuzzyctj|}|r||jvrt||j}|j|}t ||||S)aReturn a time and/or date formatted according to the given pattern. The skeletons are defined in the CLDR data and provide more flexibility than the simple short/long/medium formats, but are a bit harder to use. The are defined using the date/time symbols without order or punctuation and map to a suitable format for the given locale. >>> from datetime import datetime >>> t = datetime(2007, 4, 1, 15, 30) >>> format_skeleton('MMMEd', t, locale='fr') u'dim. 1 avr.' >>> format_skeleton('MMMEd', t, locale='en') u'Sun, Apr 1' >>> format_skeleton('yMMd', t, locale='fi') # yMMd is not in the Finnish locale; yMd gets used u'1.4.2007' >>> format_skeleton('yMMd', t, fuzzy=False, locale='fi') # yMMd is not in the Finnish locale, an error is thrown Traceback (most recent call last): ... KeyError: yMMd After the skeleton is resolved to a pattern `format_datetime` is called so all timezone processing etc is the same as for that. :param skeleton: A date time skeleton as defined in the cldr data. :param datetime: the ``time`` or ``datetime`` object; if `None`, the current time in UTC is used :param tzinfo: the time-zone to apply to the time for display :param fuzzy: If the skeleton is not found, allow choosing a skeleton that's close enough to it. :param locale: a `Locale` object or a locale identifier )r radatetime_skeletonsmatch_skeletonr)rr-r#rr^rs r'format_skeletonr#s]L\& ! !F G!:::!(F,EFF  &x 0F 8VVV < <>> from datetime import timedelta >>> format_timedelta(timedelta(weeks=12), locale='en_US') u'3 months' >>> format_timedelta(timedelta(seconds=1), locale='es') u'1 segundo' The granularity parameter can be provided to alter the lowest unit presented, which defaults to a second. >>> format_timedelta(timedelta(hours=3), granularity='day', locale='en_US') u'1 day' The threshold parameter can be used to determine at which value the presentation switches to the next higher unit. A higher threshold factor means the presentation will switch later. For example: >>> format_timedelta(timedelta(hours=23), threshold=0.9, locale='en_US') u'1 day' >>> format_timedelta(timedelta(hours=23), threshold=1.1, locale='en_US') u'23 hours' In addition directional information can be provided that informs the user if the date is in the past or in the future: >>> format_timedelta(timedelta(hours=1), add_direction=True, locale='en') u'in 1 hour' >>> format_timedelta(timedelta(hours=-1), add_direction=True, locale='en') u'1 hour ago' The format parameter controls how compact or wide the presentation is: >>> format_timedelta(timedelta(hours=3), format='short', locale='en') u'3 hr' >>> format_timedelta(timedelta(hours=3), format='narrow', locale='en') u'3h' :param delta: a ``timedelta`` object representing the time difference to format, or the delta in seconds as an `int` value :param granularity: determines the smallest unit that should be displayed, the value can be one of "year", "month", "week", "day", "hour", "minute" or "second" :param threshold: factor that determines at which point the presentation switches to the next higher unit :param add_direction: if this flag is set to `True` the return value will include directional information. For instance a positive timedelta will include the information about it being in the future, a negative will be information about the value being in the past. :param format: the format, can be "narrow", "short" or "long". ( "medium" is deprecated, currently converted to "long" to maintain compatibility) :param locale: a `Locale` object or a locale identifier )narrowrrrz1Format must be one of "narrow", "short" or "long"rzU"medium" value for format param of format_timedelta is deprecated. Use "long" instead)categoryrrc3Kr.jd|}dkr |dVn |dVd|}jd|iVdS)N date_fieldsrfuturepastz duration- unit_patterns)_datar)a_unitunit_rel_patternsrrr^rs r'_iter_patternsz(format_timedelta.._iter_patternss  0 & ] ;F C !||'11111'////%V%%l?+//;;??GGGGGGGr)rrNotherrr) TypeErrorwarningswarnDeprecationWarningr0r- timedeltar3rgrr rarabsmaxround plural_formrr%r1)rrrrrr^runit secs_per_unitvaluerrr{rs ``` @r'format_timedeltar[s~:::KLLL  ;1 3 3 3 3%+,,uzE)U]:;; \& ! !FHHHHHHHH /66mG }, I  !4!4{""uqyyAu e %%E ,,U33KG*N400  '≪77P8<<;P;PGE(rr??5#e**55 5 5 5"5 2r)startend str | Nonecjvrfd}nItd||fDrfd}n(td||fDrfd}nfd}||}||}||kr ||Sjddd|d |S) Nc*t|SNr)r)rr^rr#s r'z+_format_fallback_interval..sOHb&PPPr)c3K|]9}t|tjot|tj V:dSN)r0r-rD.0ds r' z,_format_fallback_interval..sD k kYZjHM**S:aAR3S3S/S k k k k k kr)c&t|Sr)r)rr^s r'rz+_format_fallback_interval..sK6:::r)c3K|]9}t|tjot|tj V:dSr )r0r-r5rDr s r'rz,_format_fallback_interval..sC g gUVjHM**O:a3O3O/O g g g g g gr)c(t|SNr)rrr^r#s r'rz+_format_fallback_interval..sK6&IIIr)c(t|Sr)rrs r'rz+_format_fallback_interval..sOBvfMMMr)z{0}-{1}rr)rallinterval_formatsrr%)rrrr#r^rformatted_start formatted_ends ``` r'_format_fallback_intervalrs6,,,PPPPPP k k_dfi^j k k k k kN:::: g g[`beZf g g g g gNIIIIIMMMMMfUmmOF3KKM-''ve}} ##D)44''}%%r)c tjj}||vs|s,|r|rt||}nd}|st ||||S||}||krt ||||St t||}t t||}t|}t|} tD]k} | |vre| | | | kr9d fdt|| ||fDcSlt ||||S)u Format an interval between two instants according to the locale's rules. >>> from datetime import date, time >>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "yMd", locale="fi") u'15.–17.1.2016' >>> format_interval(time(12, 12), time(16, 16), "Hm", locale="en_GB") '12:12–16:16' >>> format_interval(time(5, 12), time(16, 16), "hm", locale="en_US") '5:12 AM – 4:16 PM' >>> format_interval(time(16, 18), time(16, 24), "Hm", locale="it") '16:18–16:24' If the start instant equals the end instant, the interval is formatted like the instant. >>> format_interval(time(16, 18), time(16, 18), "Hm", locale="it") '16:18' Unknown skeletons fall back to "default" formatting. >>> format_interval(date(2015, 1, 1), date(2017, 1, 1), "wzq", locale="ja") '2015/01/01~2017/01/01' >>> format_interval(time(16, 18), time(16, 24), "xxx", locale="ja") '16:18:00~16:24:00' >>> format_interval(date(2016, 1, 15), date(2016, 1, 17), "xxx", locale="de") '15.01.2016 – 17.01.2016' :param start: First instant (datetime/date/time) :param end: Second instant (datetime/date/time) :param skeleton: The "skeleton format" to use for formatting. :param tzinfo: tzinfo to use (if none is already attached) :param fuzzy: If the skeleton is not found, allow choosing a skeleton that's close enough to it. :param locale: A locale object or identifier. :return: Formatted interval N)rr^r"rrc3dK|]*\}}t||V+dSr )rr)r rr?r^s r'rz"format_interval..@sS$GWg&&,,Wf==r)) r rarrrrrIr6DateTimeFormatPATTERN_CHAR_ORDERextractjoinzip) rrrr#rr^r skel_formats start_fmtend_fmtfields ` r'format_intervalr%sb\& ! !F.'''x'   %h0@AAHHH S,UC66RR R#H-L ||xeFSSSS #M%$8$8 H H HE !-"4"4V D D DCuV444IS000G$ L Y%6%6u%=%=QVAWAW%W%W77|E*UCL99    %UC66 J JJr)typeLiteral['selection'] | Nonect||}t|jdzdz|jdzz|jz}t j|}|j|i }|D] \}}|D]}d|vr|d|kr|ccS!|D]\}}|D]}d|vrjd|vrf|d|dkr#|d|cxkr |dkr nn8|ccSn1|d|cxkrdksnd|cxkr |dkr nn|ccSdx} } d|vr||dkrd} d |vr||d krd} d|vr||dkrd} d |vrtd | r| r|ccSȌ|d krd SdS)uy Get the day period ID for a given time. This ID can be used as a key for the period name dictionary. >>> from datetime import time >>> get_period_names(locale="de")[get_period_id(time(7, 42), locale="de")] u'Morgen' >>> get_period_id(time(0), locale="en_US") u'midnight' >>> get_period_id(time(0), type="selection", locale="en_US") u'night1' :param time: The time to inspect. :param tzinfo: The timezone for the time. See ``format_time``. :param type: The period type to use. Either "selection" or None. The selection type is used for selecting among phrases such as “Your email arrived yesterday evening” or “Your email arrived last night”. :param locale: the `Locale` object, or a locale string :return: period ID. Something is always returned -- even if it's just "am" or "pm". ratfrombeforerrFTtoafterz$'after' is deprecated as of CLDR 29.iampm) rNr3rrrr raday_period_rulesritemsNotImplementedError) r5r#r&r^seconds_past_midnightrulesetsrule_idrulesrulestart_okend_oks r' get_period_idr:KsY: T6 " "D B 3dkB6F F TUU \& ! !F&**444::<>> parse_date('4/1/04', locale='en_US') datetime.date(2004, 4, 1) >>> parse_date('01.04.2004', locale='de_DE') datetime.date(2004, 4, 1) >>> parse_date('2004-04-01', locale='en_US') datetime.date(2004, 4, 1) >>> parse_date('2004-04-01', locale='de_DE') datetime.date(2004, 4, 1) :param string: the string containing the date :param locale: a `Locale` object or a locale identifier :param format: the format to use (see ``get_date_format``) (\d+)No numbers were found in inputz^(\d{4})-?([01]\d)-?([0-3]\d)$)flagsrvymrlr YMDc&i|]\}}|d|Srr@r idxitems r' zparse_date.."@@@ TtAw@@@r)i )refindallr<matchASCIIr-rDmapr3groupsrrwrlowerindexsorted enumerater) rAr^rnumbers iso_alike format_stryear_idx month_idxday_idxindexesrrrs r' parse_datergs0j6**G ;9::::rx111I =#c9+;+;+=+=">">? ?    D !v>>>FLLNNJ$$H  %%I1}}$$S)) s##Gxo 3'7'3HIIG@@Yw-?-?@@@G 73< D"4yyA~~4#d))  3t99D  % & &E ggcl# $ $C rzz%s =uc * **s 2A>> B  B ctjd|}|stdt||j}|d}|dkr|d}|d}|d}t|d f|d f|d fg}d t|D}d} d |vrd|vrd} dx} } t||d | z} t|dkrIt||d } t|dkrt||d } tj | | | S)aParse a time from a string. This function uses the time format for the locale as a hint to determine the order in which the time fields appear in the string. >>> parse_time('15:30:00', locale='en_US') datetime.time(15, 30) :param string: the string containing the time :param locale: a `Locale` object or a locale identifier :param format: the format to use (see ``get_time_format``) :return: the parsed time :rtype: `time` rDrErvhrkrHsHrKSc&i|]\}}|d|SrNr@rOs r'rRzparse_time..rSr)ar/rUrrT) rVrWr<rrr\r]r^r_r3rr-r5) rAr^rr`rbhour_idxmin_idxsec_idxrf hour_offsetrrrs r' parse_timerts&j6**G ;9:::!v>>>FLLNNJ$$H!||##C((s##Gs##Gxo~~FGGG@@Yw-?-?@@@G K jTV\\^^33 FV wws|$ % % 3D 7||aWWS\*++ w<)r&r=rrws r'__repr__zDateTimePattern.__repr__s&:4::&::::::r)c|j}|Sr r)rwpats r'__str__zDateTimePattern.__str__sl r)rcNt|tstS|j|zSr )r0rNotImplementedr)rwrs r'__mod__zDateTimePattern.__mod__s'%00 "! !{U""r)Nr-datetime.date | datetime.timer^r_rrc*|t|||zSr )r)rwr-r^rs r'rzDateTimePattern.applys nXv~FFFFr))rr1rrrr1)rrrr1r )r-rr^r_rrrr1)r=r>r?rxr}rrrr@r)r'rsrs s;;;;####04 GGGGGGGr)ceZdZ d)d*d Zd+d Zd,dZd-dZd-dZd-dZd-dZ d-dZ d.d-dZ d/dZ d0dZ d-dZd/dZdZd-dZd1d"Zd)d2d$Zd)d3d(ZdS)4rNrrr^ Locale | strrrrNonecJt|tjtjtjfsJt|tjtjfr"|j|t }||_tj ||_ ||_ dS)Nr") r0r-rDr5r#r%r4rr rar^r)rwrr^rs r'rxzDateTimeFormat.__init__(s %(-1BHM!RSSSSS eh/? @ @ .U\EYMMM--E l6** ,r)rr1c|d}t|}|dkr|||S|dvr|||S|dvr|||S|dvr|||S|dvr|||S|dkr ||jj|S|dkr| |S|d kr| S|d vr| ||S|d vr| ||S|d krL|jj d zdkr|d |S||jj d z|S|dkr ||jj |S|dkr#||jj d z|S|dkrF|jj dkr|d|S||jj |S|dkr ||jj|S|dkr ||jj|S|dkr||S|dkr||S|dvr|||St'd|)NrG)rGrJuQqrKL)wWr rLF)ErXc)robBrirUrlKrjrrHrkrmA)zrvVxXOzUnsupported date/time field )r format_era format_yearformat_quarter format_month format_weekrrrformat_day_of_yearformat_day_of_week_in_monthformat_weekday format_periodrrrformat_frac_secondsformat_milliseconds_in_dayformat_timezoneKeyError)rwrcharnums r' __getitem__zDateTimeFormat.__getitem__5sAw$ii 3;;??4-- - _ $ $##D#.. . Z  &&tS11 1 Z  $$T3// / Z  ##D#.. . S[[;;tz~s33 3 S[[**3// / S[[3355 5 _ $ $&&tS11 1 _ $ $%%dC00 0 S[[z#q(({{2s+++{{4:?R#7=== S[[;;tz44 4 S[[;;tz3S99 9 S[[z!##{{2s+++{{4:?C888 S[[;;tz0#66 6 S[[;;tz0#66 6 S[[++C00 0 S[[22377 7 8 8 8''c22 2B$BBCC Cr)rr3ct|d}|dkr |jjS|dkr |jjS|dkr |jjS|dkr |jjS|dkr|jjdzpdS|dkr |jjS|d krt|jjdkStd |d |j) NrrGrKr rlrirUrHrozNot implemented: extracting z from ) r1rrrrrrr3r2)rwrs r'rzDateTimeFormat.extractgs4yy| 3;;:? " S[[:# # S[[:> ! S[[:? " S[[:?R'-2 - S[[:$ $ S[[tz",-- -%&aT&a&aSWS]&a&abb br)rcddddtd|}t|jjdk}t ||j|S)N abbreviatedrZrrr)rr3rrrrr^)rwrrr[eras r'rzDateTimeFormat.format_erazsK!f::3q#;;G$*/Q&''UDK0055r)c|jj}|r|jd}|||}|dkr |dd}|S)NrrT)rrisupper isocalendarr)rwrrrrs r'rzDateTimeFormat.format_yearsa  <<>> 0J**,,Q/E{{5#&& !889D r)c|jjdz dzdz}|dkrd||fzSdddd|}d d d |}t|||j|S) NrrrT%0*drrZrrrrr)rrrnr^)rwrrquarterr[r]s r'rzDateTimeFormat.format_quartersr:#a'A-1 !88S'N* *!f::3? }55d; ==gFFr)c|dkrd||jjfzSdddd|}ddd |}t|||j|jjS) NrTrrrZrrrrr)rrrkr^)rwrrr[r]s r'rzDateTimeFormat.format_monthsd !88S$*"233 3!f::3? }55d;ugt{;;DJ> ..00K'' 44DqyyzH$6K$H$H$HH++D,@,@,F,F,0LLNN<<;;tS)) )'' 77DqyyzH$6DJN$K$K$KK++DHdllnnEEt99 r)rrc\|dkr[|rEd|jjz |jz}||dzdz|Sd}|j}ddddd|}|d krd nd }t |||j|S) a Return weekday from parsed datetime according to format pattern. >>> from datetime import date >>> format = DateTimeFormat(date(2016, 2, 28), Locale.parse('en_US')) >>> format.format_weekday() u'Sunday' 'E': Day of week - Use one through three letters for the abbreviated day name, four for the full (wide) name, five for the narrow name, or six for the short name. >>> format.format_weekday('E',2) u'Sun' 'e': Local day of week. Same as E except adds a numeric value that will depend on the local starting day of the week, using one or two letters. For this example, Monday is the first day of the week. >>> format.format_weekday('e',2) '01' 'c': Stand-Alone local day of week - Use one letter for the local numeric value (same as 'e'), three for the abbreviated day name, four for the full (wide) name, five for the narrow name, or six for the short name. >>> format.format_weekday('c',1) '1' :param char: pattern format character ('e','E','c') :param num: count of format character rrrrZrr)rrrrrr)rr^first_week_dayrrrrh)rwrrrrr[r]s r'rzDateTimeFormat.format_weekdays8 77||~~ 7DK669K9K9M9MM{{519q=#666C*$$&&!fgFFsK#'3;;--HUGT[99'BBr)cR|||Sr )rr)rwrs r'rz!DateTimeFormat.format_day_of_years"{{4//113777r)cFt|jjdz dzdzS)Nrr)r1rrr|s r'rz*DateTimeFormat.format_day_of_week_in_months#DJNQ&1,q0111r)cJddddtd|dddg}|dkr|jjdkrdnd }d }n%t|j|j }|d krd nd }|D]'}t |||j}||vr ||cS(t d|d|j)uY Return period from parsed datetime according to format pattern. >>> from datetime import datetime, time >>> format = DateTimeFormat(time(13, 42), 'fi_FI') >>> format.format_period('a', 1) u'ip.' >>> format.format_period('b', 1) u'iltap.' >>> format.format_period('b', 4) u'iltapäivä' >>> format.format_period('B', 4) u'iltapäivällä' >>> format.format_period('B', 5) u'ip.' >>> format = DateTimeFormat(datetime(2022, 4, 28, 6, 27), 'zh_Hant') >>> format.format_period('a', 1) u'上午' >>> format.format_period('b', 1) u'清晨' >>> format.format_period('B', 1) u'清晨' :param char: pattern format character ('a', 'b', 'B') :param num: count of format character rrZrrrrorUr/r.rrrr)r]r[r^zCould not format period z in )rrrr:r^rdr)rwrrwidthsperiodr]r[ period_namess r'rzDateTimeFormat.format_periods:$8<>> date = datetime.date(2006, 1, 8) >>> DateTimeFormat(date, 'de_DE').get_week_number(6) 1 >>> DateTimeFormat(date, 'en_US').get_week_number(6) 2 :param day_of_period: the number of the day in the period (usually either the day of month or the day of year) :param day_of_week: the week day; if omitted, the week day of the current date is assumed NrrrrU)rrr) rrr^r min_week_daysr-rDrr)rwrr first_day week_number max_weekss r'rzDateTimeFormat.get_week_numberGs&  *,,..K 4;#=="#%&'*+, q== NI$y014: y=DK5 5 5 1 K ; % * * ! 4:?"MMMYY[[\]^IY&&y( r)r )rrr^rrrrr)rr1rr1)rr1rr3)rr1rr3rr1)rr)rr3rr1r)rrrr3rr1)rDrrr3)rr3rrrr3)r=r>r?rxrrrrrrrrrrrrrrrrrr@r)r'rr&s 04 - - - - -0D0D0D0Ddcccc&6666 GGGGNNNN $C$C$C$C$CL88882222)O)O)O)OV====''' 1T1T1T1Tf((((>>>>> (((((((r)rr)rrTrrrrGrJrrrrKrrrrTrr rL)rrTrrgr)rrTrrrrrXr)rrrrrrorrrirlrrjrHrkrmrr)rrTrrrrrrrrrzdict[str, list[int] | None] PATTERN_CHARS(GyYuUQqMLlwWdDFgEecabBChHKkjJmsSAzZOvVXxrstr | DateTimePatterncNt|tr|St|S)aParse date, time, and datetime format patterns. >>> parse_pattern("MMMMd").format u'%(MMMM)s%(d)s' >>> parse_pattern("MMM d, yyyy").format u'%(MMM)s %(d)s, %(yyyy)s' Pattern can contain literal strings in single quotes: >>> parse_pattern("H:mm' Uhr 'z").format u'%(H)s:%(mm)s Uhr %(z)s' An actual single quote can be used by using two adjacent single quote characters: >>> parse_pattern("hh' o''clock'").format u"%(hh)s o'clock" :param pattern: the formatting pattern to parse )r0rs_cached_parse_patternrs r'rrs)*'?++  ) ))r)i)maxsizecg}t|D]\}}|dkr*||dd5|dkrI|\}}t|}|r||vrt d||z|d||zzt d|t |d|S) Nchars%z%%r$zInvalid length for field: z%%(%s)szUnknown token type: r)tokenize_patternappendr%rrr2rsr)rresulttok_type tok_value fieldcharfieldnumlimits r'rrs F/88 I I) w   MM)++C66 7 7 7 7  "+ Ix!),E X.. !Vi(>R!V!VWWW MM)y8';< = = = =%&GX&G&GHH H 7BGGFOO 4 44r)'list[tuple[str, str | tuple[str, int]]]c\gd}gdgdgfd}fd}|ddD]}||dkr"dr |n r |g},|tvrFr ||dkrdxxd z cc<^dr ||d<d d<{dr |||3|dkr|d}||ىdr |n r |S) ay Tokenize date format patterns. Returns a list of (token_type, token_value) tuples. ``token_type`` may be either "chars" or "field". For "chars" tokens, the value is the literal value. For "field" tokens, the value is a tuple of (field character, repetition count). :param pattern: Pattern string :type pattern: str :rtype: list[tuple] Nrrcddddfdd=dS)Nrrr)rrr%)charbufrsr' append_charsz&tokenize_pattern..append_charssE w 0 0 8 8s C CDEEE AAAJJJr)cfdddffdd<dd<dS)Nr$rr)r)rrrsr' append_fieldz&tokenize_pattern..append_fields= w1x{ ;<=== !  r)''rrr)r%rrextend) rquotebufrrrrrrrs @@@@r'rrs FHGIsH d++&&  s{{Q<# LNNNN# LNNN&&# LNNN9Q<''QKKK1$KKKK |'$ #'IaL"#HQKKQ<# LNNNt$$$$  !s{{x(((%%%|    Mr)tokens+Iterable[tuple[str, str | tuple[str, int]]]cXg}|D]\}}|dkr%||d|dz0|dkr[td|Ds||e|d|ddzd |S) z Turn a date format pattern token stream back into a string. This is the reverse operation of ``tokenize_pattern``. :type tokens: Iterable[tuple] :rtype: str r$rrrc3(K|] }|tvVdSr )r)r chs r'rz%untokenize_pattern..s'??rr]*??????r)z'%s'rrr)ranyr%r)routputrrs r'untokenize_patternr sF%EE) w   MM)A,15 6 6 6 6  ??Y????? E i(((( fy'8'8d'C'CCDDD 776??r) list[str]cHt}gg}t|D]v\}}|dkrN|d|vr)|g|||d|d||fwd|DS)u Split an interval-describing datetime pattern into multiple pieces. > The pattern is then designed to be broken up into two pieces by determining the first repeating field. - https://www.unicode.org/reports/tr35/tr35-dates.html#intervalFormats >>> split_interval_pattern(u'E d.M. – E d.M.') [u'E d.M. – ', 'E d.M.'] >>> split_interval_pattern("Y 'text' Y 'more text'") ["Y 'text '", "Y 'more text'"] >>> split_interval_pattern(u"E, MMM d – E") [u'E, MMM d – ', u'E'] >>> split_interval_pattern("MMM d") ['MMM d'] >>> split_interval_pattern("y G") ['y G'] >>> split_interval_pattern(u"MMM d – d") [u'MMM d – ', u'd'] :param pattern: Interval pattern string :return: list of "subpatterns" r$rc,g|]}t|Sr@)r )r rs r' z*split_interval_pattern..1s! ; ; ;6 v & & ; ; ;r))setrrclearadd)r seen_fieldspartsrrs r'split_interval_patternrs0%%K DE/8800) w  |{** R   !!### OOIaL ) ) ) b (I.//// ; ;U ; ; ;;r)options Iterable[str]allow_different_fieldsctd|D}d|vr/td|Ds|dd}tdt |Dj}d}d}|D]}tdt |Dj}d}t D]r} || d} || d} | | kr!| dks| dkr |sd}n@|d z }9| d kr| d kr| d ks | d kr | d kr|d z }]|t| | z z }s|s|r||kr|}|}|dkrn|S) a Find the closest match for the given datetime skeleton among the options given. This uses the rules outlined in the TR35 document. >>> match_skeleton('yMMd', ('yMd', 'yMMMd')) 'yMd' >>> match_skeleton('yMMd', ('jyMMd',), allow_different_fields=True) 'jyMMd' >>> match_skeleton('yMMd', ('qyMMd',), allow_different_fields=False) >>> match_skeleton('hmz', ('hmv',)) 'hmv' :param skeleton: The skeleton to match :type skeleton: str :param options: An iterable of other skeletons to match against :type options: Iterable[str] :return: The closest skeleton match, or if no match was found, None. :rtype: str|None c3K|]}||V dSr r@r options r'rz!match_skeleton..Ss'<<V.Us&"G"GV3&="G"G"G"G"G"Gr)rc3>K|]}|ddk|dVdSrr$rNr@r ts r'rz!match_skeleton..Xs/ ] ]!QqTU\__1____ ] ]r)Nc3>K|]}|ddk|dVdSrr@rs r'rz!match_skeleton..\s/"]"]AQqTU\__1Q4____"]"]r)rirKrT)r^rr%dictrrrr) rrrget_input_field_width best_skeleton best_distancerget_opt_field_widthdistancer$ input_width opt_widths r'rr4s><<'<<<<r6rIrNr2rdrhrkrnrrrwr|rrrrrrrrrrrr%r:rr<rgrtrsrrrrrrr rrr@r)r'r7sG "#""""" --------KKKK DOOOOO$$$$$$9999999999++++++d44444444"-(-7%?$FHFFFF'./P'QQQQQ!"9:H::::%.@3FLx}\_ccKcccc-   . # #"4 ? ? ? ?((((V@&*>;;;;;@HN)6V] < < < < <NT&.g55555(GM(0PW77777$IO*2RY99999$EK07 , , , , ,5=\c 5 5 5 5 5 9A`g"5=\c 5 5 5 5 5"BH") 9,9,9,9,9,z!%")MMMMMb!%&,")FJ w>w>w>w>w>v"&*2")#'#'#'#'#'N*2%)") '='='='='=V>B*2%)FNFNFNFNFNV%)") *=*=*=*=*=Z0X`;A") ggggg^#* @ %)") fKfKfKfKfKV&*(,") IIIIIX        #*$,9+9+9+9+9+|#*$,1/1/1/1/1/hGGGGGGGG6IIIIIIIIX ...D.t... . . !Q . qc . !Q . iii . "%qc . ,/ .   .!"4"4"4.7:???....14___.!Q.q!f."Aq6.,/A.!Q.!Q.d. ..OOO..11a&.;>1v..OOO...1///.. &@****4 45555"BBBBJ*#<#<#<#