File: //opt/alt/python38/lib/python3.8/site-packages/humanize/__pycache__/time.cpython-38.pyc
U
su]aB � @ s� d Z ddlZddlZddlmZ ddlmZ ddlm Z
ddlmZ dd d
ddgZeG d
d� de��Z
dd� Zdd� Zdd�dd�Zd*ed�dd�Zd+ed�dd �Zd,ed�dd
�Zed�dd�Zdd � Zd!d"� Zd#d$� Zd%d&� Zd-ed�d)d�ZdS ).zYTime humanizing functions.
These are largely borrowed from Django's `contrib.humanize`.
� N)�Enum)�total_ordering� )�gettext)�ngettext�naturaldelta�naturaltime�
naturalday�naturaldate�precisedeltac @ s4 e Zd ZdZdZdZdZdZdZdZ dZ
d d
� ZdS )�Unitr r � � � � � � c C s | j |j kr| j|jk S tS �N)� __class__�value�NotImplemented)�self�other� r �>/opt/alt/python38/lib/python3.8/site-packages/humanize/time.py�__lt__# s zUnit.__lt__N)�__name__�
__module__�__qualname__�MICROSECONDS�MILLISECONDS�SECONDS�MINUTES�HOURS�DAYS�MONTHS�YEARSr r r r r r s r c C s
t j�� S r )�dt�datetime�nowr r r r �_now) s r* c C s | j dk rt� }||| S | S )z�Return an "absolute" value for a timedelta, always representing a time distance.
Args:
delta (datetime.timedelta): Input timedelta.
Returns:
datetime.timedelta: Absolute timedelta.
r )�daysr* )�deltar) r r r �
abs_timedelta- s
r- �r) c C s� |s
t � }t| tj�r$| }|| }n\t| tj�r>|| }| }nBz t| �} tj| d�}|| }W n ttfk
r~ d| f Y S X |t|�fS )z�Turn a value into a date and a timedelta which represents how long ago it was.
If that's not possible, return `(None, value)`.
)�secondsN) r* �
isinstancer'