HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux srvntsweb01 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: admntserv (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //snap/certbot/5370/lib/python3.12/site-packages/pyrfc3339/__pycache__/generator.cpython-312.pyc
�

ʂ�i
��@�ddlZddlmZmZ			d	dededededef
d�Zy)
�N)�datetime�timezone�dt�utc�accept_naive�microseconds�returnc�j�|j�;|r.|r!|jtj��}nt	d��t	d��|r|jtj�}|j
|rdnd��}|jtjk(rtjdd|�}|S)	a�	
    Generate an :RFC:`3339`-formatted timestamp from a :class:`datetime.datetime`.

    >>> from datetime import datetime, timezone
    >>> from zoneinfo import ZoneInfo
    >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0, timezone.utc))
    '2009-01-01T12:59:59Z'

    The timestamp be normalized to UTC unless :python:`utc=False` is specified, in which case
    it will use the timezone from the :class:`~datetime.datetime`'s :attr:`~datetime.datetime.tzinfo` attribute.

    >>> eastern = ZoneInfo('US/Eastern')
    >>> dt = datetime(2009, 1, 1, 12, 59, 59, tzinfo=eastern)
    >>> generate(dt)
    '2009-01-01T17:59:59Z'
    >>> generate(dt, utc=False)
    '2009-01-01T12:59:59-05:00'

    Unless :python:`accept_naive=True` is specified, the :class:`~datetime.datetime` must not be naive.

    >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0))
    Traceback (most recent call last):
    ...
    ValueError: naive datetime and accept_naive is False

    >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0), accept_naive=True)
    '2009-01-01T12:59:59Z'

    If, however, :python:`accept_naive=True` is specified, the :class:`~datetime.datetime` is assumed to represent a UTC time.
    Attempting to generate a local timestamp from a naive datetime will result in an error.

    >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0), accept_naive=True, utc=False)
    Traceback (most recent call last):
    ...
    ValueError: cannot generate a local timestamp from a naive datetime

    :param datetime.datetime dt: the :class:`~datetime.datetime` for which to generate an :RFC:`3339` timestamp.
    :param bool utc: :const:`True` to normalize the supplied :class:`datetime.datetime` to UTC; :const:`False` otherwise.
                     Defaults to :const:`True`.
    :param bool accept_naive: :const:`True` if :func:`generate()` should accept a 'naive' datetime
                              (that is, one without timezone information) and treat it as a UTC timestamp;
                              :const:`False` otherwise. Defaults to :const:`False`.
    :param bool microseconds: :const:`True` to generate a timestamp which includes fractional seconds, if present;
                              :const:`False` otherwise. Defaults to :const:`False`.
                              Note that fractional seconds are *truncated*,
                              not rounded when :obj:`microseconds` is :const:`False`.
    :return: the supplied :class:`~datetime.datetime` instance represented as an :RFC:`3339` timestamp
    :rtype: str

    )�tzinfoz7cannot generate a local timestamp from a naive datetimez(naive datetime and accept_naive is Falser�seconds)�timespecz\+00:00$�Z)	r�replacerr�
ValueError�
astimezone�	isoformat�re�sub)rrrr�	timestamps     ��/build/snapcraft-certbot-817459ae66b3942307a8b35b87e7f45e/parts/certbot/install/lib/python3.12/site-packages/pyrfc3339/generator.py�generaters���r
�y�y�����Z�Z�x�|�|�Z�4�� �M����G�H�H�
�
�]�]�8�<�<�
(������n�)��T�I�	�y�y�H�L�L� ��F�F�;��Y�7�	���)TFF)rrr�bool�strr�rr�<module>rsO��	�'�
���	L��L�	
�L��L��	L�
	�Lr