%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/babel/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/babel/__pycache__/dates.cpython-312.pyc

�

�x`e���dZddlZddlZddlZddlmZmZmZmZddl	m
Z
ddlmZm
Z
mZddlmZmZdZed�ZeZeZeZd	�Zd
�Zd�Zdhd�Zdhd
�Zdhd�Zdid�ZGd�d�Zddefd�Zddefd�Z ddefd�Z!ddefd�Z"defd�Z#defd�Z$defd�Z%defd�Z&ddedfd �Z'dedfd!�Z(dddeddfd"�Z)ddefd#�Z*dddefd$�Z+dddefd%�Z,ddd&efd'�Z-d(Z.d)d*ddefd+�Z/d,�Z0ddd&efd-�Z1ddefd.�Z2Gd/�d0e3�Z4edfd1�Z5edfd2�Z6Gd3�d4�Z7Gd5�d6�Z8id7gd8��d9d�d:d�d;d�d<gd8��d=gd8��d>gd8��d?gd8��d@dAdBg�dCdAg�dDdAdBg�dEgdF��dGdAg�dHd�dIgdJ��dKgdJ��dLgdM��idNgd8��dOgd8��dPgd8��dQdAdBg�dRdAdBg�dSdAdBg�dTdAdBg�dUdAdBg�dVdAdBg�dWd�dXd�dYgdZ��d[gd8��d\dAd]g�d^dAd]g�d_gdZ��d`gd8���dagd8�i�Z9dbZ:iZ;dc�Z<dd�Z=de�Z>df�Z?djdg�Z@y)ka�
    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-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�N)�date�datetime�time�	timedelta)�bisect_right)�default_locale�
get_global�Locale)�UTC�LOCALTZu	∅∅∅�LC_TIMEc�Z�|�tj�}t}||fSt|t�rd}t|�}||fSt|t�rd}t}||fSt|ttf�r1t|�}|j�|j}||fSt}||fSd}|}||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)r�nowr�
isinstance�str�get_timezone�intrr�
_get_datetime�tzinfo��dt_or_tzinfo�dtrs   �-/usr/lib/python3/dist-packages/babel/dates.py�_get_dt_and_tzinfor/s�����
�\�\�^���� �v�:��
�L�#�	&�
���l�+���v�:��
�L�#�	&�
�����v�:��
�L�8�T�"2�	3�
�<�
(��
�9�9� ��Y�Y�F��v�:��	�F��v�:������
�v�:��c���t|�\}}t|d�r|jSt|d�r|j�|jS|j	|xstj��S)z[
    Get the timezone name out of a time, datetime, or tzinfo object.

    :rtype: str
    �zone�key)r�hasattrrr�tznamer�utcnowrs   r�_get_tz_namer"Ls^��$�L�1�J�B���v�v���{�{��	���	�F�J�J�$:��z�z���}�}�R�4�8�?�?�#4�5�5rc��|�tj�St|t�st|t�rtj|�St|t�r(tjtj�|�St|t�r.t|t�stj|t
��S|S)aX
    Get a datetime out of an "instant" (date, time, datetime, number).

    .. warning:: The return values of this function may depend on the system clock.

    If the instant is None, the current moment is used.
    If the instant is a time, it's augmented with today's date.

    Dates are converted to naive datetimes with midnight as the time component.

    >>> _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
    )�	datetime_r!rr�float�utcfromtimestampr�combiner�todayr)�instants rrr[s���<�����!�!�	�G�S�	!�Z���%?��)�)�'�2�2�	�G�T�	"�� � �����w�7�7�	�G�T�	"�:�g�x�+H�� � ��$�&�1�1��Nrc��|j�|jt��}|�8|jt	|��}t|d�r|j
|�}|S)a+
    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.

    >>> _ensure_datetime_tzinfo(datetime(2015, 1, 1)).tzinfo.zone
    '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 tznfo.
    :return: datetime with tzinfo
    :rtype: datetime
    �r�	normalize)r�replacer�
astimezonerrr,)rrs  r�_ensure_datetime_tzinfor/�s\��(����#�8�#�#�3�/��
��&�8�&�&�|�F�';�<���6�;�'��'�'��1�H��Orc��|�tj�}n+t|ttf�rtj
|�}|j�|jt��}t|t�rD|�/|j|�}t|d�r|j|�}|j�}|S|�|j|��}|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
    r+r,)
rr!rrr%r&rr-rr.rr,�timetz)rrs  r�	_get_timer2�s����|���� ��	�D�3��,�	'��(�(��.���{�{���t�|�|�3�'���$��!���"�4�?�?�6�*�D��v�{�+��'�'��-���t�{�{�}���K�
�	��t�|�|�6�*���Krc��|�tSt|t�s|S	tj|�S#tj
$rt
d|z��wxYw)a�Looks up a timezone by name and returns it.  The timezone object
    returned comes from ``pytz`` and 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, mit's returned unchanged.
    zUnknown timezone %s)rrr�_pytz�timezone�UnknownTimeZoneError�LookupError)rs rrr�sW���|����d�C� ���8��~�~�d�#�#���%�%�8��/�$�6�7�7�8�s	�1�"Ac���tjdt��t|�}t	|�jd��}t
|d�std��	tdt|j|��}|j|dz
}|j|}|j|}|j|}t|j||||�	�S#ttf$rYywxYw)
a�Given a timezone it will return a :class:`TimezoneTransition` object
    that holds the information about the next timezone transition that's going
    to happen.  For instance this can be used to detect when the next DST
    change is going to happen and how it looks like.

    The transition is calculated relative to the given datetime object.  The
    next transition that follows the date is used.  If a transition cannot
    be found the return value will be `None`.

    Transition information can only be provided for timezones returned by
    the :func:`get_timezone` function.

    This function is pending deprecation with no replacement planned in the
    Babel library.

    :param zone: the timezone for which the transition should be looked up.
                 If not provided the local timezone is used.
    :param dt: the date after which the next transition should be found.
               If not given the current time is assumed.
    z�get_next_timezone_transition() is deprecated and will be removed in the next version of Babel. Please see https://github.com/python-babel/babel/issues/716 for discussion.��categoryNr+�_utc_transition_timesz�Given timezone does not have UTC transition times.  This can happen because the operating system fallback local timezone is used or a custom timezone objectr�)�	activates�from_tzinfo�	to_tzinfo�reference_date)�warnings�warn�DeprecationWarningrrr-r�	TypeError�maxrr;�_transition_info�_tzinfosr7�
ValueError�TimezoneTransition)rr�idx�	old_trans�	new_trans�old_tz�new_tzs       r�get_next_timezone_transitionrO�s���*
�M�M�	�$�����D�	�r�	�	"�	"�$�	"�	/�B��4�0�1��1�2�	2�
��!�\�$�"<�"<�b�A�B���)�)�#��'�2�	��)�)�#�.�	����y�)�����y�)����,�,�S�1����	���
��$����s�AC�C'�&C'c�^�eZdZdZd	d�Zed��Zed��Zed��Zed��Z	d�Z
y)
rIaLA helper object that represents the return value from
    :func:`get_next_timezone_transition`.

    This class is pending deprecation with no replacement planned in the
    Babel library.

    :field activates:
        The time of the activation of the timezone transition in UTC.
    :field from_tzinfo:
        The timezone from where the transition starts.
    :field to_tzinfo:
        The timezone for after the transition.
    :field reference_date:
        The reference date that was provided.  This is the `dt` parameter
        to the :func:`get_next_timezone_transition`.
    Nc�r�tjdt��||_||_||_||_y)Nz�TimezoneTransition is deprecated and will be removed in the next version of Babel. Please see https://github.com/python-babel/babel/issues/716 for discussion.r9)rArBrCr=r>r?r@)�selfr=r>r?r@s     r�__init__zTimezoneTransition.__init__s8���
�
�
�(�	
�#���&���"���,��rc�.�|jjS)z/The name of the timezone before the transition.)r>�_tzname�rRs r�from_tzzTimezoneTransition.from_tz&s�����'�'�'rc�.�|jjS)z.The name of the timezone after the transition.)r?rUrVs r�to_tzzTimezoneTransition.to_tz+s���~�~�%�%�%rc�\�t|jjj��S)z0The UTC offset in seconds before the transition.)rr>�
_utcoffset�
total_secondsrVs r�from_offsetzTimezoneTransition.from_offset0s$���4�#�#�.�.�<�<�>�?�?rc�\�t|jjj��S)z/The UTC offset in seconds after the transition.)rr?r[r\rVs r�	to_offsetzTimezoneTransition.to_offset5s"���4�>�>�,�,�:�:�<�=�=rc�V�d|j�d|j�d|j�d�S)Nz<TimezoneTransition z -> z (z)>)rWrYr=rVs r�__repr__zTimezoneTransition.__repr__:s!���L�L��J�J��N�N�
�	
r�N)�__name__�
__module__�__qualname__�__doc__rS�propertyrWrYr]r_ra�rrrIrIsc���"-��(��(��&��&��@��@��>��>�
rrI�wide�stand-alonec�L�tj|�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_periods��width�context�locales   r�get_period_namesrrBs#���<�<���+�+�G�4�U�;�;r�formatc�L�tj|�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
rl�daysrns   r�
get_day_namesrvOs#�� �<�<���$�$�W�-�e�4�4rc�L�tj|�j||S)a�Return 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
rl�monthsrns   r�get_month_namesrybs#���<�<���&�&�w�/��6�6rc�L�tj|�j||S)a�Return 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
rl�quartersrns   r�get_quarter_namesr|ss#���<�<���(�(��1�%�8�8rc�F�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
rl�eras�rorqs  r�
get_era_namesr��s���<�<���$�$�U�+�+r�mediumc�F�tj|�j|S)a�Return the date formatting patterns used by the locale for the specified
    format.

    >>> get_date_format(locale='en_US')
    <DateTimePattern u'MMM d, y'>
    >>> get_date_format('full', locale='de_DE')
    <DateTimePattern u'EEEE, d. MMMM y'>

    :param format: the format to use, one of "full", "long", "medium", or
                   "short"
    :param locale: the `Locale` object, or a locale string
    )r
rl�date_formats�rsrqs  r�get_date_formatr������<�<���,�,�V�4�4rc�V�tj|�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
rl�datetime_formats)rsrq�patternss   r�get_datetime_formatr��s0���|�|�F�#�4�4�H�
�X�����F��rc�F�tj|�j|S)a�Return the time formatting patterns used by the locale for the specified
    format.

    >>> get_time_format(locale='en_US')
    <DateTimePattern u'h:mm:ss a'>
    >>> get_time_format('full', locale='de_DE')
    <DateTimePattern u'HH:mm:ss zzzz'>

    :param format: the format to use, one of "full", "long", "medium", or
                   "short"
    :param locale: the `Locale` object, or a locale string
    )r
rl�time_formatsr�s  r�get_time_formatr��r�r�longFc��tt|��}tj|�}|jj|�}|jdzdzdz|jz}t|d�\}}|r|dk(r|dk(ry|dk(r
|dk(rd|zS|dk(s|dk(rd	}n|d
k(rd}n|jddz}|||dzfzS)
a�Return the timezone associated with the given `datetime` object formatted
    as string indicating the offset from GMT.

    >>> 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 = tz.localize(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
    ��<�r�Z�
iso8601_shortz%+03d�shortz	%+03d%02d�iso8601z
%+03d:%02d�gmt)
r/rr
rlr�	utcoffsetru�seconds�divmod�zone_formats)rrorq�return_z�offsetr��hours�patterns        r�get_timezone_gmtr��s���F'�}�X�'>�?�H�
�\�\�&�
!�F�
�_�_�
&�
&�x�
0�F��k�k�B���#�b�(�6�>�>�9�G��G�T�*�N�E�7��E�Q�J�7�a�<��	�A��%�?�2��%���	�'�	�U�o�5���	�)�	����%�%�e�,�|�;���e�W��]�+�+�+rc���tj|�}t|�}td�j	||�}|j
j	|i�}|jd}td�j	|�}||jvrd}|j|}|s.|r,ttd�j	|g��dk(r||zS|jd}d|vr|d}	n|td	�j	|�}
|jj	|
i�}d|vr|d}	n<d
|vr&|jd
d�djdd�}	n|jdd�}	|r|	S|||	|d
�zzS)uVReturn a representation of the given timezone using "location format".

    The result depends on both the local display name of the country and the
    city associated with the time zone:

    >>> tz = get_timezone('America/St_Johns')
    >>> print(get_timezone_location(tz, locale='de_DE'))
    Kanada (St. John’s) Zeit
    >>> 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) Zeit'

    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_aliases�region�zone_territories�ZZ�territory_zonesr<�fallback�city�
meta_zones�/�_� )�0�1)r
rlr"r	�get�
time_zonesr��territories�lenr��splitr-)rrq�return_cityr�info�
region_format�	territory�territory_name�fallback_format�	city_name�metazone�
metazone_infos            r�get_timezone_locationr��s���F�\�\�&�
!�F���%�D��n�%�)�)�$��5�D���� � ��r�*�D��'�'��1�M��-�.�2�2�4�8�I���*�*�*��	��'�'�	�2�N��9��Z�8I�-J�-N�-N�y�Z\�-]�)^�bc�)c��~�-�-��)�)�*�5�O�
��~���L�	��l�+�/�/��5���)�)�-�-�h��;�
��]�"�%�f�-�I�
�D�[��
�
�3��*�1�-�5�5�c�3�?�I����S�#�.�I�����O�
�
�/���rc��t|�\}}tj|�}t|�}|�|�d}n(|j	|�}	|	rd}nd}n|dvrtd��t
d�j||�}|r|S|jj|i�}
||
vr||
|vr|
||St
d�j|�}|rg|jj|i�}||vrG||j|�}
|dk(r*|
tk(r!|jd	i�j|�}
|
r|
S|�t|||�
�St||��S)aReturn the localized display name for the given timezone. The timezone
    may be specified using a ``datetime`` or `tzinfo` object.

    >>> 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 indenpendent 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
    <https://www.unicode.org/reports/tr35/#Time_Zone_Fallback>`_

    .. 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
    �generic�daylight�standard)r�r�r�zInvalid zone variationr�r�r�r�r�rq)
rr
rlr"�dstrHr	r�r�r��NO_INHERITANCE_MARKERr�r�)rro�uncommonrq�zone_variant�return_zonerrrr�r�r�r��names              r�get_timezone_namer�Esl��N$�L�1�J�B��
�\�\�&�
!�F���%�D���
�:�$�L��*�*�R�.�C��)��)���B�B��5�6�6��n�%�)�)�$��5�D������� � ��r�*�D���}��4��;�&���;�|�,�,��,�'�+�+�D�1�H���)�)�-�-�h��;�
��M�!� ��'�+�+�L�9�D����D�,A�$A�%�(�(���4�8�8��F�����
�~���%��?�?� ��f�=�=rc��|�tj�}n!t|t�r|j�}tj|�}|dvr
t||��}t|�}|j||�S)a�Return a date formatted according to the given pattern.

    >>> 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
    ��fullr�r�r�r�)
�date_r(rrrr
rlr��
parse_pattern�apply)rrsrqr�s    r�format_dater��si��*�|��{�{�}��	�D�(�	#��t�y�y�{��
�\�\�&�
!�F�
�4�4� ���7���F�#�G��=�=��v�&�&rc	�@�tt|�|�}tj|�}|dvrVt	||��jdd�jdt
||d|���jdt|||���St|�j||�S)	aReturn a date formatted according to the given pattern.

    >>> dt = datetime(2007, 4, 1, 15, 30)
    >>> format_datetime(dt, locale='en_US')
    u'Apr 1, 2007, 3:30:00 PM'

    For any pattern requiring the display of the time-zone, the third-party
    ``pytz`` package is needed to explicitly specify the time-zone:

    >>> format_datetime(dt, 'full', tzinfo=get_timezone('Europe/Paris'),
    ...                 locale='fr_FR')
    u'dimanche 1 avril 2007 \xe0 17:30:00 heure d\u2019\xe9t\xe9 d\u2019Europe centrale'
    >>> format_datetime(dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz",
    ...                 tzinfo=get_timezone('America/New_York'), 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
    r�r��'��{0}N�rrq�{1})
r/rr
rlr�r-�format_timer�r�r�)rrsrrqs    r�format_datetimer��s���2'�}�X�'>��G�H�
�\�\�&�
!�F�
�4�4�"�6�&�9�
�W�S�"�
�
�W�U�K��&��/5�7�8�
�W�U�K��&��H�
I�		J��V�$�*�*�8�V�<�<rc��t||�}tj|�}|dvr
t||��}t	|�j||�S)aL	Return a time formatted according to the given pattern.

    >>> t = time(15, 30)
    >>> format_time(t, locale='en_US')
    u'3:30:00 PM'
    >>> 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 = tzinfo.localize(t)
    >>> format_time(t, format='full', tzinfo=tzinfo, locale='fr_FR')
    u'15:30:00 heure d\u2019\xe9t\xe9 d\u2019Europe centrale'
    >>> format_time(t, "hh 'o''clock' a, zzzz", tzinfo=get_timezone('America/New_York'),
    ...             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('America/New_York'),
    ...             locale='en_US')
    u'3:30:00 PM 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
    r�r�)r2r
rlr�r�r�)rrsrrqs    rr�r�sL��n�T�6�"�D�
�\�\�&�
!�F�
�4�4� ���7���� �&�&�t�V�4�4rTc��tj|�}|r$||jvrt||j�}|j|}t	||||�S)a�Return 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.

    >>> 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
rl�datetime_skeletons�match_skeletonr�)�skeletonrr�fuzzyrqrss      r�format_skeletonr�BsU��>�\�\�&�
!�F����!:�!:�:�!�(�F�,E�,E�F��
�
&�
&�x�
0�F��8�V�V�V�<�<r))�yeari�3�)�monthi�')�weeki�:	)�day�Q)�hourr�)�minuter�)�secondr<r�g333333�?c�����
��dvrtd���dk(rtjdt��d�t	|t
�r&t
|jdz|jz��
n|�
tj�������
fd�}tD]�\}}t�
�|z}	|	|k\s||k(s�||k(r|	d	kDrtd
|	�}	t
t|	��}	�j|	�}
d}||�D]*}|��|j!|
�xs|j!d�}n|�y
|j#dt%|	��cSy
)a�	Return a time delta according to the rules of the given locale.

    >>> 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
    )�narrowr�r�r�z1Format must be one of "narrow", "short" or "long"r�zU"medium" value for format param of format_timedelta is deprecated. Use "long" insteadr9r�r�c3���K��r&�jd|}�dk\r|d��n|d��d|z}�jdj|i�j����y�w)N�date_fieldsr�future�pastz	duration-�
unit_patterns)�_datar�)�a_unit�unit_rel_patterns�
add_directionrsrqr�s  ����r�_iter_patternsz(format_timedelta.<locals>._iter_patterns�sl������ &���]� ;�F� C���!�|�'��1�1�'��/�/��v�%���l�l�?�+�/�/���;�?�?��G�G�s�AA"rr<N�otherr�r�)rDrArBrCrrrrur�r
rl�TIMEDELTA_UNITS�absrE�round�plural_formr�r-r)�delta�granularity�	thresholdr�rsrqr��unit�
secs_per_unit�valuer�r�r�r�s   ```       @r�format_timedeltar�ssI���t�:�:��K�L�L�
����
�
�;�1�	3����%��#��u�z�z�E�)�U�]�]�:�;����
�\�\�&�
!�F�H� /�6���m��G��}�,���I����!4��{�"�u�q�y��A�u�
����e��%�E� �,�,�U�3�K��G�*�4�0�
���'�&�l�l�;�7�P�8�<�<��;P�G��
�
����?�?�5�#�e�*�5�5�6�"rc�\������jvr���fd�}n;td�||fD��r�fd�}n!td�||fD��r��fd�}n��fd�}||�}||�}||k(r||�S�jjdd�j	d|�j	d	|�S)
Nc�"��t�|����S�Nr�)r�)rrqr�rs ���r�<lambda>z+_format_fallback_interval.<locals>.<lambda>�s���O�H�b�&��P�rc3�bK�|]'}t|t�xrt|t����)y�wrb)rrr��.0�ds  r�	<genexpr>z,_format_fallback_interval.<locals>.<genexpr>�s)����Y�q�j��D�!�A�*�Q��*A�&A�A�Y���-/c���t|���Sr)r�)rrqs �rrz+_format_fallback_interval.<locals>.<lambda>�s���K��6�:�rc3�bK�|]'}t|t�xrt|t����)y�wrb)rrrrs  rrz,_format_fallback_interval.<locals>.<genexpr>�s)����U�1�j��D�!�=�*�Q��*=�&=�=�U�r	c� ��t|����S�Nr�)r��rrqrs ��rrz+_format_fallback_interval.<locals>.<lambda>�s���K��6�&�I�rc� ��t|����Sr
)r�rs ��rrz+_format_fallback_interval.<locals>.<lambda>�s���O�B�v�f�M�rz{0}-{1}r�r�)r��all�interval_formatsr�r-)�start�endr�rrqrs�formatted_start�
formatted_ends  ```   r�_format_fallback_intervalr�s�����6�,�,�,�P��	�Y�U�TW�L�Y�	Y�:��	�U��PS��U�	U�I��M���U�m�O��3�K�M��-�'��e�}��	���#�#�D�)�4�����'����}�%�rc	�4��tj����j}||vs|s$|r|r
t||�}nd}|st	||||��S||}||k(rt||||���St
t|�|��}t
t|�|��}t|���}t|���}	tD]U}
|
|vs�|j|
�|	j|
�k7s�,dj�fd�t||
||f�D��cSt	||||��S)u�
    Format an interval between two instants according to the locale's rules.

    >>> 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)r�rqr+r�r�c3�Z�K�|]"\}}t|�j|�����$y�wrb)r�r�)rr�r)rqs   �rrz"format_interval.<locals>.<genexpr>Fs/������(���"�'�*�0�0��&�A��s�(+)
r
rlrr�rr�r/r�DateTimeFormat�PATTERN_CHAR_ORDER�extract�join�zip)rrr�rr�rqr�skel_formats�	start_fmt�end_fmt�fields     `     r�format_intervalr"�s6���R�\�\�&�
!�F��.�.���'�'�x���%�h�0@�A�H��H��,�U�C��6�6�R�R�#�H�-�L���|��x���e�F�S�S�#�M�%�$8��H�E�
!�-��"4�V�
D�C��u�V�4�I��S��0�G�$�	���L� �� � ��'�7�?�?�5�+A�A��w�w���<��.����=����	�%�U�C��6�6�J�Jrc��t||�}t|jdzdz|jdzz|jz�}tj|�}|jj|i�j�}|D]\}}|D]}d|vs�|d|k(s�|ccS�!|D]�\}}|D]�}d|vrPd|vrL|d|dkr|d|cxkr|dkr0nn-|ccS|d|cxkrdksnd|cxkr|dkr	nn|ccSdx}	}
d|vr
||dk\rd}	d	|vr
||d	krd}
d|vr
||dkrd}
d
|vrtd��|	s��|
s��|ccS��|dkry
y)uW
    Get the day period ID for a given time.

    This ID can be used as a key for the period name dictionary.

    >>> 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".
    r��at�from�beforer�rFT�to�afterz$'after' is deprecated as of CLDR 29.i���am�pm)r2rr�r�r�r
rl�day_period_rulesr��items�NotImplementedError)rr�typerq�seconds_past_midnight�rulesets�rule_id�rules�rule�start_ok�end_oks           r�
get_period_idr6Qs���.�T�6�"�D���	�	�B��� 3�d�k�k�B�6F� F���� T�U��
�\�\�&�
!�F��&�&�*�*�4��4�:�:�<�H�"������	�D��t�|��T�
�.C� C���	��
#������	�D���~�(�d�"2���<�$�x�.�0��F�|�'<�M�t�H�~�M�&���F�|�'<�D�u�D��!6�G��h��G�&�� %�%�H�v���~�"7�4��<�"G����t�|� 5��d�� C����4��$9�D��N�$J����$��)�*P�Q�Q��F���3	��8�u�$��rc��eZdZy)�
ParseErrorN)rcrdrerhrrr8r8�s��rr8c�x�tjd|�}|std��t||��jj�}|j
d�}|j
d�}|dkr|j
d�}|j
d�}|d	f|d
f|dfg}|j�t|�D�	�
cic]\}	}
|
d|	��
}}	}
||d	}t|�d
k(rdt|�z}nt|�}t||d
�}t||d�}
|dkDr|
|}
}t|||
�Scc}
}	w)a�Parse a date from a string.

    This function uses the date format for the locale as a hint to determine
    the order in which the date fields appear in the string.

    >>> 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)

    :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 inputr��y�mr�lr�Y�M�Dr<�i��)�re�findallr8r�r��lower�index�sort�	enumerater�rr)�stringrqrs�numbers�
format_str�year_idx�	month_idx�day_idx�indexesrJ�itemr�r�r�s              r�
parse_daterR�sJ���j�j��6�*�G���9�:�:�!��v�>�F�F�L�L�N�J�����$�H�� � ��%�I��1�}��$�$�S�)�	����s�#�G��#���C� 0�7�C�.�A�G��L�L�N�-6�w�-?�@�	��T�t�A�w��|�@�G�@�
�7�3�<� �D�
�4�y�A�~��c�$�i����4�y�������%�&�E�

�g�g�c�l�#�
$�C��r�z��%�s����e�S�!�!��As�;D6c��tjd|�}|std��t||��jj�}|j
d�}|dkr|j
d�}|j
d�}|j
d�}|d	f|d
f|dfg}|j�t|�D�	�
cic]\}	}
|
d|	��
}}	}
d}d
|vrd|j�vrd}dx}}
t||d	�|z}t|�dkDr0t||d
�}t|�dkDrt||d�}
t|||
�Scc}
}	w)a�Parse 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`
    r:r;r��hr�kr=�s�Hr@�Sr<�ar*rCrB)rDrEr8r�r�rFrGrHrIrr�r)rJrqrsrKrL�hour_idx�min_idx�sec_idxrPrJrQ�hour_offsetr�r�r�s               r�
parse_timer^�se���j�j��6�*�G���9�:�:�!��v�>�F�F�L�L�N�J�����$�H��!�|��#�#�C�(�����s�#�G����s�#�G��#���#���#��?�G��L�L�N�-6�w�-?�@�	��T�t�A�w��|�@�G�@��K�
�j���6�<�<�>�!��K���F�V��w�w�s�|�$�%��3�D�
�7�|�a���W�W�S�\�*�+���w�<�!�������.�/�F���f�f�%�%��%As�;Ec�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�DateTimePatternc� �||_||_yrb)r�rs)rRr�rss   rrSzDateTimePattern.__init__�s�������rc�N�dt|�j�d|j�d�S)N�<r��>)r.rcr�rVs rrazDateTimePattern.__repr__s�� ��J�/�/����>�>rc��|jSrb�r�rVs r�__unicode__zDateTimePattern.__unicode__s���|�|�rc��|j}|Srbrf)rR�pats  r�__str__zDateTimePattern.__str__s���l�l���
rc�N�t|�turtS|j|zSrb)r.r�NotImplementedrs)rRr�s  r�__mod__zDateTimePattern.__mod__s#����;�n�,�!�!��{�{�U�"�"rc� �|t||�zSrb)r)rRrrqs   rr�zDateTimePattern.applys���n�X�v�6�6�6rN)	rcrdrerSrargrjrmr�rhrrr`r`�s ���?���#�
7rr`c�~�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
dd	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zdd�Zdd�Zy)rc���t|tttf�sJ�t|ttf�r"|j�|jt��}||_tj|�|_
y)Nr+)rrrrrr-rr�r
rlrq)rRr�rqs   rrSzDateTimeFormat.__init__sX���%�$��$�!7�8�8�8��e�h��-�.�5�<�<�3G��M�M��M�-�E���
��l�l�6�*��rc�f�|d}t|�}|dk(r|j||�S|dvr|j||�S|dvr|j||�S|dvr|j	||�S|dvr|j||�S|dk(r&|j
|jj|�S|dk(r|j|�S|d	k(r|j�S|d
vr|j||�S|dvr|j||�S|dk(rW|jjd
zdk(r|j
d
|�S|j
|jjd
z|�S|dk(r&|j
|jj|�S|dk(r)|j
|jjd
z|�S|dk(rQ|jjdk(r|j
d|�S|j
|jj|�S|dk(r&|j
|jj|�S|dk(r&|j
|jj|�S|dk(r|j!|�S|dk(r|j#|�S|dvr|j%||�St'd|z��)Nr�G)r<r?�u��Q�q�r@�L)�w�WrrA�F)�E�e�c)rY�b�BrTrCrW�KrUr�r=rVrX�A)�zr��v�V�x�X�OzUnsupported date/time field %r)r��
format_era�format_year�format_quarter�format_month�format_weekrsr�r��format_day_of_year�format_day_of_week_in_month�format_weekday�
format_periodr�r�r��format_frac_seconds�format_milliseconds_in_day�format_timezone�KeyError)rRr��char�nums    r�__getitem__zDateTimeFormat.__getitem__s����A�w���$�i���3�;��?�?�4��-�-�
�_�
$��#�#�D�#�.�.�
�Z�
��&�&�t�S�1�1�
�Z�
��$�$�T�3�/�/�
�Z�
��#�#�D�#�.�.�
�S�[��;�;�t�z�z�~�~�s�3�3�
�S�[��*�*�3�/�/�
�S�[��3�3�5�5�
�_�
$��&�&�t�S�1�1�
�_�
$��%�%�d�C�0�0�
�S�[��z�z����#�q�(��{�{�2�s�+�+��{�{�4�:�:�?�?�R�#7��=�=�
�S�[��;�;�t�z�z����4�4�
�S�[��;�;�t�z�z����3�S�9�9�
�S�[��z�z���!�#��{�{�2�s�+�+��{�{�4�:�:�?�?�C�8�8�
�S�[��;�;�t�z�z�0�0�#�6�6�
�S�[��;�;�t�z�z�0�0�#�6�6�
�S�[��+�+�C�0�0�
�S�[��2�2�3�7�7�
�8�
8��'�'��c�2�2��;�d�B�C�Crc���t|�d}|dk(r|jjS|dk(r|jjS|dk(r|jjS|dk(r|jj
S|dk(r|jj
dzxsdS|dk(r|jjS|d	k(r"t|jj
dk\�Std
|�d|j����)Nrr<r@rrWrTrCr=rYzNot implemented: extracting z from )	rr�r�r�r�r�r�rr-)rRr�s  rrzDateTimeFormat.extractOs����4�y��|���3�;��:�:�?�?�"�
�S�[��:�:�#�#�#�
�S�[��:�:�>�>�!�
�S�[��:�:�?�?�"�
�S�[��:�:�?�?�R�'�-�2�-�
�S�[��:�:�$�$�$�
�S�[��t�z�z���"�,�-�-�%�RV�X\�Xb�Xb�&c�d�drc��dddd�td|�}t|jjdk\�}t	||j
�|S)N�abbreviatedrir�����r�r)rErr�r�r�rq)rRr�r�ro�eras     rr�zDateTimeFormat.format_erabsF��!�f��:�3�q�#�;�G���$�*�*�/�/�Q�&�'���U�D�K�K�0��5�5rc���|jj}|j�r)|j|j	��}|dk(r|dz}|j||�}|dk(r|dd}|S)Nrr<rB���)r�r��isupper�get_week_number�get_day_of_yearrs)rRr�r�r�r�r�s      rr�zDateTimeFormat.format_yeargsh���
�
�����<�<�>��'�'��(<�(<�(>�?�D��q�y���
���{�{�5�#�&���!�8����9�D��rc��|jjdz
dzdz}|dkrd||fzSdddd�|}d	d
d�|}t|||j�|S)Nr<r�rB�%0*dr�rir�r�rsrjrt)r�r�r|rq)rRr�r��quarterrorps      rr�zDateTimeFormat.format_quarterrsn���:�:�#�#�a�'�A�-��1���!�8��S�'�N�*�*�!�f��:�3�?�� �}�5�d�;�� ������=�g�F�Frc��|dkrd||jjfzSdddd�|}ddd	�|}t|||j�|jjS)
NrBr�r�rir�r�rsrjrw)r�r�ryrq)rRr�r�rorps     rr�zDateTimeFormat.format_monthzse���!�8��S�$�*�*�"2�"2�3�3�3�!�f��:�3�?�� �}�5�d�;���u�g�t�{�{�;�D�J�J�<L�<L�M�Mrc�2�|j�r�|j�}|j|�}|dk(rI|jt	|��z
}|j|j|�|j
��}|j
||�S|j|jj�}|dk(rX|jt	|jj��z
}|j|j|j
��}d|zS)Nr)ru�%d)�islowerr�r�r�r�weekdayrsr�)rRr�r��day_of_yearr�rs      rr�zDateTimeFormat.format_week�s����<�<�>��.�.�0�K��'�'��4�D��q�y��z�z�I�;�$?�?���+�+�D�,@�,@��,F�,8�D�L�L�N�<���;�;�t�S�)�)��'�'��
�
���7�D��q�y��z�z�I�4�:�:�>�>�$B�B���+�+�D�H�H�l�d�l�l�n�E���$�;�rc�X�|dkr^|j�rLd|jjz
|jj	�z}|j|dzdz|�Sd}|jj	�}ddddd�|}|d	k(rd
}nd}t
|||j�|S)ai
        Return weekday from parsed datetime according to format pattern.

        >>> 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

        r��r<r�rir�r�)r�r�r��r~rjrs)r�rq�first_week_dayr�r�rsrv)rRr�r�r�r�rorps       rr�zDateTimeFormat.format_weekday�s���6��7��|�|�~��D�K�K�6�6�6����9K�9K�9M�M���{�{�5�1�9�q�=�#�6�6��C��*�*�$�$�&��!�f��g�F�s�K���3�;�#�G��G��U�G�T�[�[�9�'�B�Brc�B�|j|j�|�Srb)rsr�)rRr�s  rr�z!DateTimeFormat.format_day_of_year�s���{�{�4�/�/�1�3�7�7rc�F�d|jjdz
dzdzzS)Nr�r<r�)r�r�rVs rr�z*DateTimeFormat.format_day_of_week_in_month�s$����
�
����*�q�0�1�4�5�5rc�X�dddd�td|�dddg}|dk(r |jjdk\rdnd	}d
}n*t|j|j��}|dk(rd
nd
}|D]%}t|||j��}||vs� ||cSt
d|�d|j����)u)
        Return period from parsed datetime according to format pattern.

        >>> 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

        r�rir�r�r�rYrCr*r)rsr�r�rj)rprorqzCould not format period z in )rEr�r�r6rqrrrH)rRr�r��widths�periodrpro�period_namess        rr�zDateTimeFormat.format_period�s���8$��8�<�S��C�[�I��(�M�3���3�;�!�Z�Z�_�_��2�T��F��G�"�4�:�:�d�k�k�B�F�"&�#�+�h�=�G��	,�E�+�G�5�QU�Q\�Q\�]�L���%�#�F�+�+�	,��v�t�{�{�S�T�Trc�x�|jjdz}|jt||�d|zz|�S)z� Return fractional seconds.

        Rounds the time's microseconds to the precision given by the number         of digits passed in.
        i@B�
)r��microsecondrsr�)rRr�r�s   rr�z"DateTimeFormat.format_frac_seconds�s9���
�
�&�&��0���{�{�5���,�r�3�w�6��<�<rc���|jjdz|jjdzz|jjdzz|jjdzz}|j||�S)Ni�i`�i��6)r�r�r�r�r�rs)rRr��msecss   rr�z)DateTimeFormat.format_milliseconds_in_day�sh���
�
�&�&�$�.����1B�1B�T�1I�I��J�J����%�&�(,�
�
���'�(A�B���{�{�5�#�&�&rc�D�dddd�td|�}|dk(r"t|j||j��S|dk(rJ|d	k(r#t	|j||jd
��St	|j||j��S|dk(r(|d
k(r"t	|j||j��Sy|dk(r,t|jj
||j��S|dk(r�|dk(r-t|jj
|d
|j��S|dk(r,t|jj
|jd
��S|dk(r,t
|jj
|jd
��St
|jj
|j��S|dk(rw|dk(r#t	|jd|jd
��S|dvr#t	|jd|jd
��S|dvr#t	|jd|jd
��Sy|dk(rt|dk(r"t	|jd|j��S|dvr"t	|jd|j��S|dvr"t	|jd|j��Syy)Nr�r�r�r�r�r�r�r�r�T)rqr�r�r�r�r�r<)r�rqrB)rqr�)rqr�r�r�)rorqr�)rBr�)r�r�r�r)rEr�r�rqr�rr�)rRr�r�ros    rr�zDateTimeFormat.format_timezone�sR����9�5�c�!�S�k�B���3�;�$�T�Z�Z��t�{�{�K�K�
�S�[��a�x�'��
�
�E�$�+�+�X\�]�]�#�D�J�J��d�k�k�J�J�
�S�[��a�x�'��
�
�E�$�+�+�N�N���S�[�$�T�Z�Z�%6�%6��,0�K�K�9�
9�
�S�[��a�x�(����):�):�E�26�t�{�{�L�L����(����):�):�4�;�;�\`�a�a����,�T�Z�Z�->�->�t�{�{�`d�e�e�(����):�):�4�;�;�O�O�
�S�[��a�x�'��
�
�/�RV�R]�R]�15�7�7����'��
�
�'�$�+�+�15�7�7����'��
�
�)�D�K�K�15�7�7���S�[��a�x�'��
�
�/�RV�R]�R]�^�^����'��
�
�'�$�+�+�V�V����'��
�
�)�D�K�K�X�X��rc��d||fzS)Nr�rh)rRr��lengths   rrszDateTimeFormat.format"s������'�'rNc�f�|�|j}||jdd��z
jdzS)Nr<)r�r�)r�r-ru)rRrs  rr�zDateTimeFormat.get_day_of_year%s3���<��:�:�D��|�t�|�|�!��3�3�9�9�A�=�=rc���|�|jj�}||jjz
|z
dzdz}|dkr|dz
}||zdz
dz}d|z
|jjk\r|dz
}|S)a�Return the number of the week of a day within a period. This may be
        the week number in a year or the week number in a month.

        Usually this will return a value equal to or greater than 1, but if the
        first week of the period is so short that it actually counts as the last
        week of the previous period, this function will return 0.

        >>> format = DateTimeFormat(date(2006, 1, 8), Locale.parse('de_DE'))
        >>> format.get_week_number(6)
        1

        >>> format = DateTimeFormat(date(2006, 1, 8), Locale.parse('en_US'))
        >>> format.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 ommitted, the week day of the
                            current date is assumed
        r<r�r)r�r�rqr��
min_week_days)rR�
day_of_period�day_of_week�	first_day�week_numbers     rr�zDateTimeFormat.get_week_number*s���*���*�*�,�,�.�K� �4�;�;�#=�#=�=�"�#�%&�'�*+�,�	��q�=���N�I�$�y�0�1�4��:���y�=�D�K�K�5�5�5��1��K��r)r|r�rb)rcrdrerSr�rr�r�r�r�r�r�r�r�r�r�r�r�rsr�r�rhrrrrsg��+�0D�de�&6�
	�G�N�� &C�P8�6�(U�T=�'�
)Y�V(�>�
 rrrr)r<rBr�r�r�r<r?rsrurvr@rxryr<rBrzrrA)r<rBr�r{�gr|)r<rBr�r�r�r�r}r~)r<r�r�r�r�rYrr�rTrWr�rUr=rVrXr�r�)r<rBr�r�r�r�r�r�r�r�r��(GyYuUQqMLlwWdDFgEecabBChHKkjJmsSAzZOvVXxc��t|�tur|S|tvr	t|Sg}t|�D]{\}}|dk(r"|j	|jdd���-|dk(r=|\}}t|}|r||vrtd||zz��|j	d||zz��otd|z��t|dj|��xt|<}|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
    �chars�%z%%r!zInvalid length for field: %rz%%(%s)szUnknown token type: %sr�)
r.r`�_pattern_cache�tokenize_pattern�appendr-�
PATTERN_CHARSrHr-r)r��result�tok_type�	tok_value�	fieldchar�fieldnum�limitris        rr�r�es���*�G�}��'����.� ��g�&�&�
�F�/��8�K���)��w���M�M�)�+�+�C��6�7�
��
 �"+��I�x�!�)�,�E����.� �!?�$-��$8�":�;�;��M�M�)�y�8�';�<�=�%�&>��&I�J�J�K�%4�G�S�X�X�f�=M�$N�N�N�7��c��Jrc�����	�g�	d}g�dg�dg���	fd�}���	fd�}t|jdd��D]�\}}|�z|dk(r�dr|�n	�r|�g}�&|tvr6�r|�|�dk(r�dxxd	z
cc<�M�dr|�|�d<d	�d<�d�dr|��j|���|���|dk(r�j	|�d}��|j|����dr	|��	S�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]
    Nr�rc�t���jddj��jdd�f��dd�=y)Nr�r��r�)r�rr-)�charbufr�s��r�append_charsz&tokenize_pattern.<locals>.append_chars�s1����
�
�w����� 0� 8� 8��s� C�D�E��A�Jrc�P���jd�d�dff�d�d<d�d<y)Nr!rr�)r�)r�r�r�s���r�append_fieldz&tokenize_pattern.<locals>.append_field�s3����
�
�w��1��x��{� ;�<�=��	�!�����r�''r�r�r<)rIr-r�r��extend)
r��quotebufr�r�rJr�r�r�r�r�s
      @@@@rr�r��s%��� �F��H��G���I��s�H���
�w���t�T�:�;�&�	��T����s�{��Q�<� �N�� �N�����&�� �N��9�Q�<�'��Q�K�1�$�K� ��|�$��#'�I�a�L�"#�H�Q�K��Q�<� �N����t�$�
�
!��s�{����x�(�������%�9&�<��|����M�
����Mrc��g}|D]s\}}|dk(r|j|d|dz��&|dk(s�,td�|D��s|j|��P|jd|jdd�z��ud	j|�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!rr<r�c3�,K�|]}|tv���y�wrb)r�)r�chs  rrz%untokenize_pattern.<locals>.<genexpr>�s����?�r�r�]�*�?�s�z'%s'r�r�r�)r��anyr-r)�tokens�outputr�r�s    r�untokenize_patternr��s����F�%�E���)��w���M�M�)�A�,��1��5�6�
��
 ��?�Y�?�?��
�
�i�(��
�
�f�y�'8�'8��d�'C�C�D�E��7�7�6�?�rc�,�t�}gg}t|�D]\\}}|dk(r<|d|vr!|jg�|j�|j	|d�|dj||f��^|D�cgc]
}t|���c}Scc}w)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!r���)�setr�r��clear�addr�)r��seen_fields�partsr�r�r�s      r�split_interval_patternr��s���0�%�K�
�D�E�/��8�0���)��w����|�{�*����R� ��!�!�#��O�O�I�a�L�)�
�b�	���(�I�.�/�
0�6;�;�6��v�&�;�;��;s�<Bc�&�td�|D��}d|vr$td�|D��s|jdd�}td�t	|�D��j
}d}d}|D]�}td�t	|�D��j
}d}tD]`}	||	d�}
||	d�}|
|k(r�|dk(s|
dk(r|sd}n8|d	z
}�1|	d
k(r|
dkDr|dks
|
dkr|dkDr|dz
}�P|t|
|z
�z
}�b|s��|r||kr|}|}|dk(s��|S|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
    c3�&K�|]	}|s�|���y�wrbrh�r�options  rrz!match_skeleton.<locals>.<genexpr>2s����<��V�V�<�s��r�c3�$K�|]}d|v���
y�w)r�Nrhr�s  rrz!match_skeleton.<locals>.<genexpr>4s����"G�V�3�&�=�"G�s�r�c3�8K�|]}|ddk(s�|d���y�w�rr!r<Nrh�r�ts  rrz!match_skeleton.<locals>.<genexpr>7s���� ]�!�Q�q�T�U\�_��1�� ]���
�
Nc3�8K�|]}|ddk(s�|d���y�wr�rhr�s  rrz!match_skeleton.<locals>.<genexpr>;s����"]�A�Q�q�T�U\�_�1�Q�4�"]�r�rir@rB�)�sortedr�r-�dictr�r�r�r�)r��options�allow_different_fields�get_input_field_width�
best_skeleton�
best_distancer��get_opt_field_width�distancer!�input_width�	opt_widths            rr�r�s]��>�<�'�<�<�G�
�h��s�"G�w�"G�G��#�#�C��-�� � ]�/?��/I� ]�]�a�a���M��M����"�"]�1A�&�1I�"]�]�a�a����"�
	9�E�/��q�9�K�+�E�1�5�I��i�'���A�~���!1�-�!�F���F�"���#��K�!�O�	�Q��K�[\�L\�aj�mn�an��E�!���C��i� 7�8�8��
	9�����=� 8�"�M�$�M��q�=����9�8�rrb)NN)F)ArfrDrA�pytzr4rrrr�bisectr�
babel.corerr	r
�
babel.utilrrr�r
r�r$�time_rr"rr/r2rrOrIrrrvryr|r�r�r�r�r�r�r�r�r�r�r�r�r�rr"r6rHr8rRr^r`rr�rr�r�r�r�r�r�rhrr�<module>rs����$
���4�4��9�9�#�.����
#��	
���	����:6�'�T�:�48�*3�l8
�8
�v"�=��
<����5�&!�(�7�7�"#�H�W�9�"�w�,�$�G�
5�  (���"$�G�
5� #�&��5�3,�l(,�G��I�X$(�v��$�4�U�t>�n�(�7�'�B"�(�4�"�#=�L�(�4��<5�~(,�D��W�#=�L��)1�C�#(��#�b�J�.*.�d�$�w�_K�D $�$�w�C�L	��	�&�h�+"�\&�h�/&�d7�7�2v�v�r	��������D���t����������	���	�
�!�Q���
�q�c���!�Q��
��i�
�"%�q�c�
�,/��
��	��!�"4��7:�?��������14�_���!�Q����q�!�f��"�A�q�6��,/��A����!�Q����!�Q����d�� �������O��.1�1�a�&��;>��1�v������O��.1�/��
�&@����+�\B�J�*#<�LCr

Zerion Mini Shell 1.0