File: //snap/certbot/current/lib64/python3.12/site-packages/pyrfc3339/__pycache__/parser.cpython-312.pyc
�
Ȗ0iG
� �J � d dl Z d dlZd dlmZmZ ddlmZ d
dedededefd �Zy)� N)�datetime�timezone� )�datetime_utcoffset� timestamp�utc�
produce_naive�returnc �t � t j dd| t j �� } t j dk rt j dd� | � } t j | � }|r|j t j � }|r-t |� dk( r|j d� � }|S t d
� �|S )aN
Parse an :RFC:`3339`-formatted timestamp and return a :class:`datetime.datetime`.
If the timestamp is presented in UTC, then the :attr:`~datetime.datetime.tzinfo` attribute of the
returned `datetime` will be set to :attr:`datetime.timezone.utc`.
>>> parse('2009-01-01T10:01:02Z')
datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
Otherwise, a :class:`datetime.timezone` instance is created with the appropriate offset, and
the :attr:`~datetime.datetime.tzinfo` attribute of the returned :class:`~datetime.datetime` is set to that value.
>>> parse('2009-01-01T14:01:02-04:00')
datetime.datetime(2009, 1, 1, 14, 1, 2, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=72000)))
However, if :meth:`parse()` is called with :python:`utc=True`, then the returned
:class:`~datetime.datetime` will be normalized to UTC (and its :attr:`~datetime.datetime.tzinfo` attribute set to
:attr:`~datetime.timezone.utc`), regardless of the input timezone.
>>> parse('2009-01-01T06:01:02-04:00', utc=True)
datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
As parsing is delegated to :meth:`datetime.datetime.fromisoformat()`, certain
timestamps which do not strictly adhere to :RFC:`3339` are nonetheless accepted.
>>> parse('2009-01-01T06:01:02')
datetime.datetime(2009, 1, 1, 6, 1, 2)
Exceptions will, however, be thrown for blatantly invalid input:
>>> parse('2009-01-01T25:01:02Z')
Traceback (most recent call last):
...
ValueError: hour must be in 0..23
:param str timestamp: the :RFC:`3339` timestamp to be parsed
:param bool utc: :const:`True` to normalize the timestamp to UTC; :const:`False` otherwise. Defaults to :const:`False`.
:param bool produce_naive: :const:`True` if the produced :class:`~datetime.datetime` instance should
not have a timezone attached (that is, be 'naive'); :const:`False` otherwise.
Defaults to :const:`False`.
:return: the parsed timestamp
:rtype: datetime.datetime
zZ$z+00:00)�flags)� � z'(\.)([0-9]+)(?=[+\-][0-9]{2}:[0-9]{2}$)c �n � | j d� | j d� j dd� d d z S )Nr � � �0)�group�ljust)�matchs ��/build/snapcraft-certbot-3159324ea1206d36e7f0992193f2ac71/parts/certbot/install/lib/python3.12/site-packages/pyrfc3339/parser.py�<lambda>zparse.<locals>.<lambda>C s/ � �%�+�+�a�.�5�;�;�q�>�+?�+?��3�+G���+K�K� � r N)�tzinfoz6cannot produce a naive datetime from a local timestamp)
�re�sub�
IGNORECASE�sys�version_infor �
fromisoformat�
astimezoner r r �replace�
ValueError)r r r �dt_outs r �parser$ s� � �` ���t�X�y��
�
�F�I� ���'�!��F�F�6�K��
� � �
#�
#�I�
.�F�
��"�"�8�<�<�0����f�%��*��^�^�4�^�0�F� �M� �U�V�V��Mr )FF) r r r r �utilsr �str�boolr$ � r r �<module>r) s7 �� �
� '� %�J�S� J�t� J�D� J�X� Jr