o
    {j6h=                     @   s  d Z ddlZddlmZ ddlmZ dedefddZd	edefd
dZ	dedefddZ
dedefddZdedefddZdefddZdedefddZdedefddZdedefddZdedefddZdedefd d!Z	d%ded"eej dejfd#d$ZdS )&z#Contains the Timestamp helper APIs.    N)Optional)	Timestampvaluereturnc                 C      t  }||  |S )a<  Parse a RFC 3339 date string format to Timestamp.

  Args:
    value: A date string. Any fractional digits (or none) and any offset are
      accepted as long as they fit into nano-seconds precision. Example of
      accepted format: '1972-01-01T10:00:20.021-05:00'

  Raises:
    ValueError: On parsing problems.
  )r   FromJsonString)r   	timestamp r	   h/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/protobuf/timestamp.pyfrom_json_string   s   
r   microsc                 C   r   )z/Converts microseconds since epoch to Timestamp.)r   FromMicroseconds)r   r   r	   r	   r
   from_microseconds       
r   millisc                 C   r   )z/Converts milliseconds since epoch to Timestamp.)r   FromMilliseconds)r   r   r	   r	   r
   from_milliseconds'   r   r   nanosc                 C   r   )z.Converts nanoseconds since epoch to Timestamp.)r   FromNanoseconds)r   r   r	   r	   r
   from_nanoseconds.   r   r   secondsc                 C   r   )z*Converts seconds since epoch to Timestamp.)r   FromSeconds)r   r   r	   r	   r
   from_seconds5   r   r   c                  C   s"   t  } | tjjtjjd | S )z&Converts the current UTC to Timestamp.)tz)r   FromDatetimedatetimenowtimezoneutc)r   r	   r	   r
   from_current_time<   s   r   tsc                 C      |   S )a  Converts Timestamp to RFC 3339 date string format.

  Returns:
    A string converted from timestamp. The string is always Z-normalized
    and uses 3, 6 or 9 fractional digits as required to represent the
    exact time. Example of the return format: '1972-01-01T10:00:20.021Z'
  )ToJsonStringr    r	   r	   r
   to_json_stringC   s   r$   c                 C   r!   )z/Converts Timestamp to microseconds since epoch.)ToMicrosecondsr#   r	   r	   r
   to_microsecondsN      r&   c                 C   r!   )z/Converts Timestamp to milliseconds since epoch.)ToMillisecondsr#   r	   r	   r
   to_millisecondsS   r'   r)   c                 C   r!   )z.Converts Timestamp to nanoseconds since epoch.)ToNanosecondsr#   r	   r	   r
   to_nanosecondsX   r'   r+   c                 C   r!   )z*Converts Timestamp to seconds since epoch.)	ToSecondsr#   r	   r	   r
   
to_seconds]   r'   r-   r   c                 C   s   | j |dS )a7  Converts Timestamp to a datetime.

  Args:
    tz: A datetime.tzinfo subclass; defaults to None.

  Returns:
    If tzinfo is None, returns a timezone-naive UTC datetime (with no timezone
    information, i.e. not aware that it's UTC).

    Otherwise, returns a timezone-aware datetime in the input timezone.
  )tzinfo)
ToDatetime)r    r   r	   r	   r
   to_datetimeb   s   r0   )N)__doc__r   typingr   google.protobuf.timestamp_pb2r   strr   floatr   r   r   r   r   r$   intr&   r)   r+   r-   r.   r0   r	   r	   r	   r
   <module>   s.   