File: //var/opt/nydus/ops/primordial/__pycache__/timeutils.cpython-39.pyc
a
�,�h� � @ sd d dl mZ d dlZd dlmZ d dlmZmZ eje d�dd�Z
dejeej ee
d �d
d�ZdS )
� )�OptionalN)�utc)�CANONICAL_TIMESTRING_FORMAT�+CANONICAL_TIMESTRING_FORMAT_NO_MICROSECONDS)�in_time�returnc C s t | t�ddd� �� �S )zu
Return integer seconds since epoch.
:param in_time: Datetime
:returns: Integer seconds since epoch
i� � )�int�datetime�
total_seconds)r � r �E/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/primordial/timeutils.py�datetime_to_epoch_seconds
s r T)�dt�tz�microsecondsr c C sP |rt nt}| jdu r2|du r&td��| j|d�} | jturF| �t�} | �|�S )a�
Return a string representation of a datetime in ISO8601 format (YYYY-MM-DDTHH:MM:SS.ssssssZ)
in the UTC (Z) timezone.
:param dt: The datetime object.
:param tz: The timezone to assume when coverting a naive datetime to UTC (Required if `dt` is naive).
:param microseconds: Whether to include microseconds in the representation. Defaults to `True`.
:returns: ISO8601-formatted string representation
:raises ValueError: If the datetime is naive, and no tz is provided
Nz7`tz` param must be provided if datetime object is naive)�tzinfo)r r r �
ValueError�replace�UTC�
astimezone�strftime)r r r Ztformatr r r
�iso8601_utc s
r )NT)�typingr r
Zpytzr r Zprimordial.constantsr r r r r �bool�strr r r r r
�<module> s