
    MiP                       S r SSKJr  SSKJr  SSKJr  SSKJr	  SSKJ
r
  SSKJr  S	r\(       a  SS
KrSSKJr  SSKJr  / SQr\ " S S\5      5       rSS jrSS jrS
S	S.       S S jjr  S!       S"S jjr    S#           S$S jjr    S%S jrS&S'S jjrS(S jr              S)S jrS*S jrS+S jr    S,         S-S jjr!S.S jr"g
)/zYTime 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                  >    \ rS rSrSrSrSrSrSrSr	Sr
S	rSS
 jrSrg)Unit   r   r                     c                r    U R                   UR                   L a  U R                  UR                  :  $ [        $ )N)	__class__valueNotImplemented)selfothers     g/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/humanize/time.py__lt__Unit.__lt__)   s+    >>U__,::++     N)r   r   returnr   )__name__
__module____qualname____firstlineno__MICROSECONDSMILLISECONDSSECONDSMINUTESHOURSDAYSMONTHSYEARSr!   __static_attributes__r$   r#   r    r   r      s/    LLGGEDFEr#   r   c                 >    SS K n U R                   R                  5       $ )Nr   )datetimenow)dts    r    _nowr7   /   s    ;;??r#   c                H    U R                   S:  a  [        5       nXU -   -
  $ U $ )zReturn an "absolute" value for a timedelta, always representing a time distance.

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

Returns:
    datetime.timedelta: Absolute timedelta.
r   )daysr7   )deltar5   s     r    _abs_timedeltar;   5   s(     zzA~fEk""Lr#   )r5   precisec               P   SSK nU(       d
  [        5       n[        XR                   5      (       a  U nX-
  nOJ[        XR                  5      (       a  X-
  nU nO) U(       a  U O
[	        U 5      n UR                  " U S9nX-
  nU[        U5      4$ ! [
        [        4 a    SU 4s $ f = f)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)r4   r7   
isinstance	timedeltaround
ValueError	TypeErrorr;   )r   r5   r<   r6   dater:   s         r    _date_and_deltarF   D   s     f%%%	E<<	(	({	$E%,ELL/E;D &&& I& 	;	s   (B B%$B%c                   SSK n[        UR                  5          nU[        R                  [        R                  [        R
                  4;  a  SU S3n[        U5      eUn[        XR                  5      (       a  U nO' [        U 5        [        U 5      n UR                  " U S9nUn[        U5      nUR                  S-  n	UR                  S-  n
[        U
S-  5      nU	S:X  Ga  U
S:  Ga  UR                   S:X  a  U[        R
                  :X  a4  UR"                  S	:  a$  [%        S
SUR"                  5      UR"                  -  $ U[        R                  :X  d.  U[        R
                  :X  aB  S	UR"                  s=::  a  S:  a+  O  O(UR"                  S	-  n[%        SS[        U5      5      U-  $ ['        S5      $ UR                   S:X  a  ['        S5      $ UR                   S:  a$  [%        SSUR                   5      UR                   -  $ SUR                   s=::  a  S:  aM  O  OJ[        UR                   S-  5      nUS:X  a  ['        S5      $ US:X  a  ['        S5      $ [%        SSU5      U-  $ SUR                   ::  aJ  [        UR                   S-  5      nUS:X  a  ['        S5      $ US:X  a  ['        S5      $ [%        SSU5      U-  $ OU	S:X  ap  U
S:X  a  ['        S5      $ U(       d  [%        SSU
5      U
-  $ US:X  a  [%        SSU
5      U
-  $ US:X  a  ['        S5      $ US :X  a  ['        S!5      $ [%        S"S#U5      U-  $ U	S:X  a  US:X  a  U
S:X  a  ['        S!5      $ US:X  a  [%        S$S%U
5      U
-  $ U(       a<  US:X  a  ['        S&5      $ US :X  a  U	S-  n	[%        S'S(U	5      U	-  $ [%        S)S*U5      U-  $ [%        S$S%U
5      U
-  $ [%        S'S(U	5      R)                  S+S,5      [+        U	5      -  $ ! [        [        4 a    [        U 5      s $ f = f)-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.

The timedelta will be rounded to the nearest unit that makes sense.

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 seconds  za minutezan hour	%d minute
%d minutes   za day%d hour%d hours%d day%d daysza month   za year%d month	%d monthsz1 year, %d dayz1 year, %d daysz1 year, 1 month%d year%d yearsz1 year, %d monthz1 year, %d months%d%s)r4   r   upperr,   r+   r*   rC   r@   rA   intfloatrD   strabsr9   rB   r?   microsecondsr   _replacer	   )r   monthsminimum_unitr6   tmpmsgmin_unitr:   
use_monthsyearsr9   
num_monthsmillisecondsminuteshourss                  r    r   r   _   s   T 
|!!#
$C
4<<!2!2D4E4EFF|nO<oH%&&	J%LELL/E JJEJJ#E::Dtd{#JzdQh==A4,,,1C1Cd1J.0A5CUCUV(()
 4,,,D---$%:L:L2Xy2X$11D8.0A3|CTU"# Z= ==AZ= ==2[,FVV%%EMMB./G!|}$"}|#[,@7JJ5== %--$./Ez|#{z!Y
E:UBB ! 
!19W:Xy$7$>>?Xy$7$>>?Y<X;[*=
JJ	!?tqyX;?-/@$G$NNQ*++R
 J>FF ,.A:N
 )+<dCdJJY
E2::4FRWXX} I& 	u:	s    &O- -P
Pc                   SSK n[        U 5      n [        U5      nU=(       d
    [        5       n[        XS9u  pxUc  [	        U 5      $ [        XR                   UR                  45      (       a  Xv:  nU(       a  [        S5      O
[        S5      n	[        XU5      nU[        S5      :X  a  [        S5      $ [	        X-  5      $ )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.

The time will be rounded to the nearest unit that makes sense.

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)r5   z%s from nowz%s agorO   r5   )	r4   _convert_aware_datetimer7   rF   re   r@   rA   rh   r   )
r   futurerj   rk   whenr6   r5   rE   r:   agos
             r    r   r      s    8 #E*E"4(D
.$&C!%1KD|5z%++r||455$!M
!H+C5E*xs{r#   c                    SSK n[        XR                   5      (       a6  U R                  b)  UR                   R                  U R	                  5       5      n U $ )zIConvert aware datetime to naive datetime and pass through any other type.r   N)r4   r@   tzinfofromtimestamp	timestamp)r   r6   s     r    rv   rv   ,  s?     %%%%,,*B))%//*;<Lr#   c                   SSK n UR                  " U R                  U R                  U R                  5      n XR                  R                  5       -
  nUR                  S:X  a  [        S5      $ UR                  S:X  a  [        S5      $ UR                  S:X  a  [        S5      $ U R                  U5      $ ! [
         a    [        U 5      s $ [        [        4 a    [        U 5      s $ f = f)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)r4   rE   yearmonthdayAttributeErrorre   OverflowErrorrC   r   r9   rh   strftime)r   formatr6   r:   s       r    r   r   7  s     

EKK; GGMMO#EzzQzzzQ}zzR~>>&!!#  5z:& 5zs   2B6 6C*C*)C*c                v   SSK n UR                  " U R                  U R                  U R                  5      n [        XR                  R                  5       -
  5      nUR                  S:  a  [        U S5      $ [        U 5      $ ! [
         a    [        U 5      s $ [        [        4 a    [        U 5      s $ f = f)zKLike `naturalday`, but append a year for dates more than ~five months away.r   Ngc@z%b %d %Y)r4   rE   r   r   r   r   re   r   rC   r;   r   r9   r   )r   r6   r:   s      r    r   r   W  s    

EKK; 577==?23Ezz\!%,,e  5z:& 5zs   2B B8B87B8c                r    X#:X  a  [        XPU-  5      S4$ X$;   a  SU 4$ [        X5      u  pgU[        U5      4$ )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   divisorunitrk   suppressr   qrs           r    _quotient_and_remainderr   i  sJ    @ 8!;;%x
 %!DAc!f9r#   c                d    X;   a*  [          H  nX :  d  M
  X!;  d  M  Us  $    Sn[        U5      eU $ )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   rC   )rn   r   r   rm   s       r    _suitable_minimum_unitr     s:    $ D4#7  QoOr#   c                h    [        U5      n[         H  nX :X  a    U$ UR                  U5        M     U$ )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     s<     8}H O 	T 
 Or#   c           
     ^   [        U SS9u  pEUc  [        U 5      $ U Vs1 s H  n[        UR                  5          iM     nn[        UR                  5          n[	        X5      nA[        X5      nUR                  n	UR                  n
UR                  n[        [        5      u  ppnnnn[        U	SUXU5      u  nn	[        U	SUXU5      u  nn	U	S-  S-  U
-   n
[        U
SUXU5      u  p[        U
SUXU5      u  nn
[        U
S	XXs5      u  nn
U
S
-  U-   n[        US
XXs5      u  p[        USXXs5      u  nnUS:  a  X;  a
  US-  nU
S-  n
U
S	:  a  X;  a
  U
S	-  n
US-  nUS	:  a  UU;  a
  US	-  nUS-  nUS:  a  UU;  a
  US-  nU	S-  n	U	S:  a  UU;  a
  U	S-  n	US-  nUS:  a  UU;  a
  US-  nUS-  nSSU4SSU4SSU	4SSU4SSU4SSU
4SSU4SSU4/n/ n[        [        [        5      U5       H  u  nnUu  nnnUS:  d  U(       d  UU:X  a  SUs=:  a  S :  a  O  OS O
[        U5      n [        UUU 5      n!SSKn"UU:X  a+  U"R!                  U5      S   S:  a  U!R#                  S!U5      n!OZUU:X  aT  U"R!                  U5      S   S:X  a  [        U5      nU!R#                  S!S"5      n!UR%                  U!['        U5      -  5        M  UR%                  U!U-  5        UU:X  d  M    O   [)        U5      S:X  a  US   $ S#R+                  USS$ 5      n#US$   n$[-        S%5      U#U$4-  $ s  snf )&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<   NrH   rI   rV   rS   iQ rP   g    .ArJ   r      r[   r^   r_   r\   r]   rY   rZ   rW   rX   rT   rU   rQ   rR   rM   rN   rK   rL   r   r   r`   ra   z, r   z	%s and %s)rF   re   r   rb   r   r   r9   r?   rg   listr   zipreversedrc   r   mathmodfri   appendr	   lenjoinrh   )%r   rk   r   r   rE   r:   ssuppress_setrn   r9   secsusecsr*   r+   r,   r-   r.   r/   r0   r1   rp   rj   rt   rs   msecsfmtstextsr   fmtsingular_txt
plural_txt	fmt_value
_fmt_valuefmt_txtr   headtails%                                        r    r   r     s   P "%6KD|5z-56XDOXL6 L&&()H%h=H )@L ::D==DEOSPLL%vu  *c5(&KE4 +dFHFLFD "9td"D(ixvJD *dE86KE4 ,b'\MGT 3JE)sG|KD +t\\LE5 ~'5	rzg1
1"}l22
{t</	 rzfL0
!|\1"
 
J&	[&)	9d#	J&	lG,	lD)	,e4	,e4	D E$.	c.1+j)q=48+;)/a/S^Jj*EGxDIIi$8$;a$?!//$799Y'*a/ #II!//$5Wx	'::;LL9,-8' /* 5zQQx99U3BZ D9D[>T4L((y 7s   !L*c                ^    X-  n [        U5      nU$ ! [         a    [        U5      n U$ f = f)aT  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   rC   rd   )r   r   results      r    r   r     s?     ^FF L  fLs    ,,)r%   zdt.datetime)r:   dt.timedeltar%   r   )r   r   r5   dt.datetime | Noner<   boolr%   ztuple[Any, Any])Tr?   )r   zdt.timedelta | floatrj   r   rk   re   r%   re   )FTr?   N)r   z"dt.datetime | dt.timedelta | floatrw   r   rj   r   rk   re   rx   r   r%   re   )r   z)dt.datetime | dt.timedelta | float | Noner%   r   )z%b %d)r   dt.date | dt.datetimer   re   r%   re   )r   r   r%   re   )r   rd   r   rd   r   r   rk   r   r   Iterable[Unit]r   re   r%   ztuple[float, float])rn   r   r   r   r%   r   )rn   r   r   r   r%   z	set[Unit])r?   r$   z%0.2f)
r   zdt.timedelta | float | Nonerk   re   r   zIterable[str]r   re   r%   re   )r   re   r   rd   r%   zfloat | int)#__doc__
__future__r   enumr   	functoolsr   i18nr   rh   r   numberr	   TYPE_CHECKINGr4   r6   collections.abcr
   typingr   __all__r   r7   r;   rF   r   r   rv   r   r   r   r   r   r   r   r$   r#   r    <module>r      s  
 #  $   ( 4     .25''*'<@'': !WYWYWY WY 		WYx !#0-00 0 	0
 0 	0f4"@$*** * 	*
 * * *Z:$ " 	H)&H)H) H) 	H)
 	H)Vr#   