
    <#(iDN                    8   d Z ddlmZ ddlmZ ddlmZ ddlmZ	 ddlm
Z
 ddlmZ d	Zerdd
lZddlmZ ddlmZ g dZe G d de                      ZdCdZdDdZd
d	ddEdZ	 	 dFdGd%Z	 	 	 	 dHdId)ZdJd+ZdKdLd/ZdMd0ZdNd7ZdOd9ZdPd;Z 	 	 	 dQdRd@Z!dSdBZ"d
S )TzYTime humanizing functions.

These are largely borrowed from Django's `contrib.humanize`.
    )annotations)Enum)total_ordering   )_gettext)	_ngettext)intcommaFN)Iterable)Any)naturaldate
naturaldaynaturaldeltanaturaltimeprecisedeltac                  6    e Zd ZdZdZdZdZdZdZdZ	dZ
ddZdS )Unitr   r                     otherr   returnc                L    | j         |j         u r| j        |j        k     S t          S )N)	__class__valueNotImplemented)selfr   s     M/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/humanize/time.py__lt__zUnit.__lt__)   s&    >U_,,:++    N)r   r   r   r   )__name__
__module____qualname__MICROSECONDSMILLISECONDSSECONDSMINUTESHOURSDAYSMONTHSYEARSr!    r"   r    r   r      sP        LLGGEDFE     r"   r   r   dt.datetimec                 <    dd l } | j                                         S )Nr   )datetimenow)dts    r    _nowr4   /   s     ;??r"   deltadt.timedeltac                H    | j         dk     rt                      }||| z   z
  S | S )zReturn an "absolute" value for a timedelta, always representing a time distance.

    Args:
        delta (datetime.timedelta): Input timedelta.

    Returns:
        datetime.timedelta: Absolute timedelta.
    r   )daysr4   )r5   r2   s     r    _abs_timedeltar9   5   s,     zA~~ffcEk""Lr"   )r2   preciser   r   r2   dt.datetime | Noner:   booltuple[Any, Any]c               L   ddl }|st                      }t          | |j                   r| }|| z
  }nct          | |j                  r|| z
  }| }nF	 |r| nt	          |           }  |j        |           }||z
  }n# t
          t          f$ r d| fcY S w xY w|t          |          fS )zTurn a value into a date and a timedelta which represents how long ago it was.

    If that's not possible, return `(None, value)`.
    r   Nseconds)r1   r4   
isinstance	timedeltaint
ValueError	TypeErrorr9   )r   r2   r:   r3   dater5   s         r    _date_and_deltarG   D   s      ff%%% e	E2<	(	( 	U{	$4EE#e**E BL///E;DDI& 	 	 	;	&&&&s   )A: :BBTr@   dt.timedelta | floatmonthsminimum_unitstrc                |   ddl }t          |                                         }|t          j        t          j        t          j        fvrd| d}t          |          |}t          | |j                  r| }nW	 t          |            t          |           }  |j        |           }n&# t          t          f$ r t          |           cY S w xY w|}t          |          }|j        dz  }	|j        dz  }
t          |
dz            }|	s|
dk     r|j        dk    r|t          j        k    r)|j        d	k     rt#          d
d|j                  |j        z  S |t          j        k    s%|t          j        k    r@d	|j        cxk    rdk     r.n n+|j        d	z  }t#          ddt          |                    |z  S t%          d          S |j        dk    rt%          d          S |j        dk     rt#          dd|j                  |j        z  S d|j        cxk    rdk     rn nt%          d          S d|j        cxk    rdk     r!n n|j        dz  }t#          dd|          |z  S d|j        cxk    rdk     rn nt%          d          S d|j        k     r|j        dz  }t#          dd|          |z  S n|	dk    rj|
dk    rt%          d          S |st#          dd|
          |
z  S |st#          dd|
          |
z  S |dk    rt%          d           S t#          d!d"|          |z  S |	dk    rh|s|
st%          d#          S |st#          d$d%|
          |
z  S |r)|dk    rt%          d&          S t#          d'd(|          |z  S t#          d$d%|
          |
z  S t#          d)d*|	                              d+d,          t)          |	          z  S )-a  Return a natural representation of a timedelta or number of seconds.

    This is similar to `naturaltime`, but does not add tense to the result.

    Args:
        value (datetime.timedelta, int or float): A timedelta or a number of seconds.
        months (bool): If `True`, then a number of months (based on 30.5 days) will be
            used for fuzziness between years.
        minimum_unit (str): The lowest unit that can be used.

    Returns:
        str (str or `value`): A natural representation of the amount of time
            elapsed unless `value` is not datetime.timedelta or cannot be
            converted to int (cannot be float due to 'inf' or 'nan').
            In that case, a `value` is returned unchanged.

    Raises:
        OverflowError: If `value` is too large to convert to datetime.timedelta.

    Examples:
        Compare two timestamps in a custom local timezone::

        ```pycon
        >>> import datetime as dt
        >>> from dateutil.tz import gettz

        >>> berlin = gettz("Europe/Berlin")
        >>> now = dt.datetime.now(tz=berlin)
        >>> later = now + dt.timedelta(minutes=30)

        >>> assert naturaldelta(later - now) == "30 minutes"
        True
        ```

    r   NzMinimum unit 'z' not supportedr?   m       >@r     %d microsecond%d microsecondsi@B %d millisecond%d millisecondsa momentza second<   	%d second
%d secondsx   za minute  	%d minute
%d minutesi   zan hour%d hour%d hoursza day%d day%d daysza month%d month	%d monthsza yearz1 year, %d dayz1 year, %d daysz1 year, 1 monthz1 year, %d monthz1 year, %d months%d year%d years%d%s)r1   r   upperr(   r'   r&   rD   rA   rB   rC   floatrE   rK   absr8   r@   microsecondsr   _replacer	   )r   rI   rJ   r3   tmpmsgmin_unitr5   
use_monthsyearsr8   
num_monthsmillisecondsminuteshourss                  r    r   r   _   sr   P 
|!!##
$C
4<!2D4EFFF<|<<<ooH%&& 	JJJ%LLE BL///EEI& 	 	 	u::	 JJJEJ#E:DTT\""J EKTAXX=A4,,,1Cd1J1J.0A5CUVV()
 4,,,D---$%:L2X2X2X2Xy2X2X2X2X2X$1D8.0A3|CTCTUU"# Z== =AZ== =2[,FFVV$$$$$$$$$Z== %-&&&&$&&&&&mr)G[,@@7JJ5=++++8+++++Y<<%-MT)EY
E::UBB   
!199W:: 	?Xy$77$>> 	?Xy$77$>>??Y<<[*==
JJ	! 	$ 	X;; 	O-/@$GG$NN 	Q*+++ ,.A:NN
 )+<dCCdJJY
E22::4FFRWXXs   9/B) ) CC"dt.datetime | dt.timedelta | floatfuturewhenc                   ddl }t          |           } t          |          }|pt                      }t          | |          \  }}|t	          |           S t          | |j         |j        f          r||k    }|rt          d          nt          d          }	t          |||          }|t          d          k    rt          d          S t	          |	|z            S )a  Return a natural representation of a time in a resolution that makes sense.

    This is more or less compatible with Django's `naturaltime` filter.

    Args:
        value (datetime.datetime, datetime.timedelta, int or float): A `datetime`, a
            `timedelta`, or a number of seconds.
        future (bool): Ignored for `datetime`s and `timedelta`s, where the tense is
            always figured out based on the current time. For integers and floats, the
            return value will be past tense by default, unless future is `True`.
        months (bool): If `True`, then a number of months (based on 30.5 days) will be
            used for fuzziness between years.
        minimum_unit (str): The lowest unit that can be used.
        when (datetime.datetime): Point in time relative to which _value_ is
            interpreted.  Defaults to the current time in the local timezone.

    Returns:
        str: A natural representation of the input in a resolution that makes sense.
    r   N)r2   z%s from nowz%s agorT   r2   )	r1   _convert_aware_datetimer4   rG   rK   rA   rB   rj   r   )
r   rv   rI   rJ   rw   r3   r2   rF   r5   agos
             r    r   r      s    4 #E**E"4((D
.$&&C!%S111KD%|5zz%"+r|455 $
5!M


!H++C55E*xxsU{r"   )dt.datetime | dt.timedelta | float | Nonec                    ddl }t          | |j                   r3| j        ,|j                             |                                           } | S )zIConvert aware datetime to naive datetime and pass through any other type.r   N)r1   rA   tzinfofromtimestamp	timestamp)r   r3   s     r    ry   ry     sO     %%% =%,*B))%//*;*;<<Lr"   %b %ddt.date | dt.datetimeformatc                   ddl }	  |j        | j        | j        | j                  } n@# t
          $ r t          |           cY S t          t          f$ r t          |           cY S w xY w| |j        	                                z
  }|j
        dk    rt          d          S |j
        dk    rt          d          S |j
        dk    rt          d          S |                     |          S )zReturn a natural day.

    For date values that are tomorrow, today or yesterday compared to
    present day return representing string. Otherwise, return a string
    formatted according to `format`.

    r   Ntodayr   tomorrow	yesterday)r1   rF   yearmonthdayAttributeErrorrK   OverflowErrorrD   r   r8   rj   strftime)r   r   r3   r5   s       r    r   r   &  s     
EK;;   5zz:&   5zz BGMMOO#EzQzzzQ}}zR~~>>&!!!   !( A%A%$A%c                v   ddl }	  |j        | j        | j        | j                  } n@# t
          $ r t          |           cY S t          t          f$ r t          |           cY S w xY wt          | |j        
                                z
            }|j        dk    rt          | d          S t          |           S )zKLike `naturalday`, but append a year for dates more than ~five months away.r   Ngc@z%b %d %Y)r1   rF   r   r   r   r   rK   r   rD   r9   r   r8   r   )r   r3   r5   s      r    r   r   F  s    
EK;;   5zz:&   5zz 527==??233Ez\!!%,,,er   rg   divisorunitsuppressIterable[Unit]tuple[float, float]c                    ||k    rt          || |z            dfS ||v rd| fS t          | |          \  }}|t          |          fS )a  Divide `value` by `divisor`, returning the quotient and remainder.

    If `unit` is `minimum_unit`, the quotient will be the rounding of `value / divisor`
    according to the `format` string and the remainder will be zero. The rationale is
    that if `unit` is the unit of the quotient, we cannot represent the remainder
    because it would require a unit smaller than the `minimum_unit`.

    >>> from humanize.time import _quotient_and_remainder, Unit
    >>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.DAYS, [], "%0.2f")
    (1.5, 0)

    If `unit` is in `suppress`, the quotient will be zero and the remainder will be the
    initial value. The idea is that if we cannot use `unit`, we are forced to use a
    lower unit, so we cannot do the division.

    >>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.HOURS, [Unit.DAYS], "%0.2f")
    (0, 36)

    In other cases, return the quotient and remainder as `divmod` would do it.

    >>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.HOURS, [], "%0.2f")
    (1, 12)

    r   )_rounding_by_fmtdivmodrC   )r   r   r   rJ   r   r   qrs           r    _quotient_and_remainderr   X  sb    @ |88!;;x%x
 %!!DAqc!ff9r"   rn   c                `    | |v r)t           D ]}|| k    r||vr|c S d}t          |          | S )a  Return a minimum unit suitable that is not suppressed.

    If not suppressed, return the same unit:

    >>> from humanize.time import _suitable_minimum_unit, Unit
    >>> _suitable_minimum_unit(Unit.HOURS, []).name
    'HOURS'

    But if suppressed, find a unit greater than the original one that is not
    suppressed:

    >>> _suitable_minimum_unit(Unit.HOURS, [Unit.HOURS]).name
    'DAYS'

    >>> _suitable_minimum_unit(Unit.HOURS, [Unit.HOURS, Unit.DAYS]).name
    'MONTHS'
    z@Minimum unit is suppressed and no suitable replacement was found)r   rD   )rn   r   r   rm   s       r    _suitable_minimum_unitr     sQ    $ 8 	 	Dh4x#7#7PooOr"   	set[Unit]c                r    t          |          }t          D ]}|| k    r n|                    |            |S )a  Extend suppressed units (if any) with all units lower than the minimum unit.

    >>> from humanize.time import _suppress_lower_units, Unit
    >>> [x.name for x in sorted(_suppress_lower_units(Unit.SECONDS, [Unit.DAYS]))]
    ['MICROSECONDS', 'MILLISECONDS', 'DAYS']
    )setr   add)rn   r   r   s      r    _suppress_lower_unitsr     sH     8}}H  8ETOr"   r.   %0.2fdt.timedelta | float | NoneIterable[str]c           
        t          | d          \  }}|t          |           S d |D             }t          |                                         }t	          ||          }~t          ||          }|j        }|j        }	|j        }
t          t                    \  }}}}}}}}t          |d||||          \  }}t          |d||||          \  }}|dz  dz  |	z   }	t          |	d	||||          \  }}	t          |	d||||          \  }}	t          |	d
||||          \  }}	|	dz  |
z   }
t          |
d||||          \  }	}
t          |
d||||          \  }}
|dk    r||vr
|dz  }|	dz  }	|	d
k    r||vr
|	d
z  }	|dz  }|d
k    r||vr
|d
z  }|dz  }|dk    r||vr
|dz  }|dz  }|dk    r||vr
|dz  }|dz  }|dk    r||vr
|dz  }|dz  }dd|fdd|fdd|fdd|fdd|fdd|	fdd|fdd|
fg}g }t          t          t                    |          D ]\  }}|\  }}}|d k    s	|s ||k    rd|cxk     rd!k     rn nd!nt          |          }t          |||          } d dl}!||k    r6|!                    |          d          d k    r|                     d"|          } np||k    rj|!                    |          d          d k    rt          |          }|                     d"d#          } |                    | t'          |          z             |                    | |z             ||k    r nt)          |          dk    r|d          S d$                    |dd%                   }"|d%         }#t-          d&          |"|#fz  S )'a:  Return a precise representation of a timedelta or number of seconds.

    ```pycon
    >>> import datetime as dt
    >>> from humanize.time import precisedelta

    >>> delta = dt.timedelta(seconds=3633, days=2, microseconds=123000)
    >>> precisedelta(delta)
    '2 days, 1 hour and 33.12 seconds'

    ```

    A custom `format` can be specified to control how the fractional part
    is represented:

    ```pycon
    >>> precisedelta(delta, format="%0.4f")
    '2 days, 1 hour and 33.1230 seconds'

    ```

    Instead, the `minimum_unit` can be changed to have a better resolution;
    the function will still readjust the unit to use the greatest of the
    units that does not lose precision.

    For example setting microseconds but still representing the date with milliseconds:

    ```pycon
    >>> precisedelta(delta, minimum_unit="microseconds")
    '2 days, 1 hour, 33 seconds and 123 milliseconds'

    ```

    If desired, some units can be suppressed: you will not see them represented and the
    time of the other units will be adjusted to keep representing the same timedelta:

    ```pycon
    >>> precisedelta(delta, suppress=['days'])
    '49 hours and 33.12 seconds'

    ```

    Note that microseconds precision is lost if the seconds and all
    the units below are suppressed:

    ```pycon
    >>> delta = dt.timedelta(seconds=90, microseconds=100)
    >>> precisedelta(delta, suppress=['seconds', 'milliseconds', 'microseconds'])
    '1.50 minutes'

    ```

    If the delta is too small to be represented with the minimum unit,
    a value of zero will be returned:

    ```pycon
    >>> delta = dt.timedelta(seconds=1)
    >>> precisedelta(delta, minimum_unit="minutes")
    '0.02 minutes'

    >>> delta = dt.timedelta(seconds=0.1)
    >>> precisedelta(delta, minimum_unit="minutes")
    '0 minutes'

    ```
    T)r:   Nc                L    h | ]!}t           |                                         "S r.   )r   rf   ).0ss     r    	<setcomp>zprecisedelta.<locals>.<setcomp>  s$    666DO666r"   rM   rN      rY   iQ rU   g    .ArO   r         rb   rc   r`   ra   r^   r_   r\   r]   rZ   r[   rV   rW   rR   rS   rP   rQ   r   r   rd   re   z, r   z	%s and %s)rG   rK   r   rf   r   r   r8   r@   ri   listr   zipreversedrC   r   mathmodfrk   appendr	   lenjoinrj   )$r   rJ   r   r   rF   r5   suppress_setrn   r8   secsusecsr&   r'   r(   r)   r*   r+   r,   r-   rp   rI   rt   rs   msecsfmtstextsr   fmtsingular_txt
plural_txt	fmt_value
_fmt_valuefmt_txtr   headtails$                                       r    r   r     s   P "%666KD%|5zz66X666L L&&(()H%h==H )<@@L :D=DEOSP PLL,%vu  *c5(L& KE4 +dFHlF LFD "9td"D(ixv JD$ *dE8\6 KE4 ,b'8\6 MGT 3JE)sGX|V KD% +t\8\6 LE5 ~~'55	rzzg\11
1"}}l222
{{t<//	 rzzfL00
!||\11"
 
J&	[&)	9d#	J&	lG,	lD)	,e4	,e4	D E$..  	c.1+j)q===48+;+;)////a/////S^^Jj*EEGKKKxDIIi$8$8$;a$?$?!//$7799Y''*a// #II!//$55Wx	':'::;;;LL9,---8E  5zzQQx99U3B3Z  D9D[>>T4L((r"   float | intc                p    | |z  }	 t          |          }n# t          $ r t          |          }Y nw xY w|S )al  Round a number according to the string format provided.

    The string format is the old printf-style string formatting.

    If we are using a format which truncates the value, such as "%d" or "%i", the
    returned value will be of type `int`.

    If we are using a format which rounds the value, such as "%.2f" or even "%.0f",
    we will return a float.
    )rC   rD   rg   )r   r   results      r    r   r   }  sP     e^FF   f Ls    33)r   r/   )r5   r6   r   r6   )r   r   r2   r;   r:   r<   r   r=   )Tr@   )r   rH   rI   r<   rJ   rK   r   rK   )FTr@   N)r   ru   rv   r<   rI   r<   rJ   rK   rw   r;   r   rK   )r   r{   r   r   )r   )r   r   r   rK   r   rK   )r   r   r   rK   )r   rg   r   rg   r   r   rJ   r   r   r   r   rK   r   r   )rn   r   r   r   r   r   )rn   r   r   r   r   r   )r@   r.   r   )
r   r   rJ   rK   r   r   r   rK   r   rK   )r   rK   r   rg   r   r   )#__doc__
__future__r   enumr   	functoolsr   i18nr   rj   r   numberr	   TYPE_CHECKINGr1   r3   collections.abcr
   typingr   __all__r   r4   r9   rG   r   r   ry   r   r   r   r   r   r   r   r.   r"   r    <module>r      si   
 # " " " " "       $ $ $ $ $ $                   ((((((       4            .25' ' ' ' ' ': !HY HY HY HY HYZ !#. . . . .b   " " " " "@   $* * * *Z   :   $ " 	H) H) H) H) H)V     r"   