o
    �ôjþ  ã                   @   sª   d Z ddlZdddddddd	d
ddddddœZe dd¡ ej¡Zdd„ Zdd„ Z	dddddddddd d!d"œZ
d#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ ZdS )1z�
Helper functions for np.timedelta64 and np.datetime64.
For now, multiples-of-units (for example timedeltas expressed in tens
of seconds) are not supported.
é    Né   é   é   é   é   é   é   é	   é
   é   é   é   é   )ÚYÚMÚWÚDÚhÚmÚsÚmsÚusÚnsÚpsÚfsÚasÚ Znatr   c                 C   s   t |  dk t | dk kS )zB
    Whether the *src* and *dest* units are of the same kind.
    r   ©ÚDATETIME_UNITS©ÚsrcÚdest© r"   úl/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/numba/np/npdatetime_helpers.pyÚ	same_kind(   s   r$   c                 C   sX   t |  } t | }| |krdS | dkrdS | |krdS |dkr dS | dkr*|dkr*dS dS )NTr   Fr   r   r   r"   r"   r#   Úcan_cast_timedelta_units/   s   r%   )r   r   )r   r   )r   é   )r   é<   )r   r'   )r   éè  )r	   r(   )r
   r(   )r   r(   )r   r(   )r   r(   )r   r   r   r   r   r   r   r	   r
   r   r   c                 C   sb   | dkrdS | }d}||k r)zt | \}}W n
 ty    Y dS w ||9 }||k s||kr/|S dS )zÍ
    Return an integer multiplier allowing to convert from *big_unit_code*
    to *small_unit_code*.
    None is returned if the conversion is not possible through a
    simple integer multiplication.
    r   r   N)Ú_factorsÚKeyError)Zbig_unit_codeZsmall_unit_codeÚcÚfactorÚmultr"   r"   r#   Ú_get_conversion_multiplierU   s   	þúr.   c                 C   s   t t|  t| ƒS )zl
    Return an integer multiplier allowing to convert from timedeltas
    of *src_unit* to *dest_unit*.
    )r.   r   )Zsrc_unitZ	dest_unitr"   r"   r#   Úget_timedelta_conversion_factoro   s   ÿr/   c                 C   s  t |  }t | }|dks|dkr| ddfS |dk r%|dkr%td| |f ƒ‚d\}}|dkrC|dkr8d}d	}d}n$|dkrBd}d
}d}n|dkr\|dkrRd}d}d}n
|dkr\d}d}d}||krvt||ƒ}|dusoJ ||fƒ‚||| |fS t||ƒ}|dus…J ||fƒ‚| ||| fS )a  
    Compute a possible conversion for combining *datetime_unit* and
    *timedelta_unit* (presumably for adding or subtracting).
    Return (result unit, integer datetime multiplier, integer timedelta
    multiplier). RuntimeError is raised if the combination is impossible.
    r   r   r   z1cannot combine datetime64(%r) and timedelta64(%r))r   r   r   r   i±: i�  ið
  iÀ  i@ƒ  N)r   ÚRuntimeErrorr.   )Údatetime_unitÚtimedelta_unitÚdt_unit_codeÚtd_unit_codeZ	dt_factorZ	td_factorr,   r"   r"   r#   Ú!get_datetime_timedelta_conversionx   sF   
ÿ€

r5   c                 C   sL   t |  }t | }|dkr|S |dkr| S |dk r|dkrdS ||kr$| S |S )zµ
    Return the unit result of combining *datetime_unit* with *timedelta_unit*
    (e.g. by adding or subtracting).  None is returned if combining
    those units is forbidden.
    r   r   Nr   )r1   r2   r3   r4   r"   r"   r#   Ú combine_datetime_timedelta_units¬   s   r6   c                 C   s8   t |  }t | }|dkr|S |dkr| S ||kr|S | S )z9
    Get the best (i.e. finer-grained) of two units.
    r   r   )Zunit_aZunit_bÚaÚbr"   r"   r#   Úget_best_unitÀ   s   r9   c                 C   ó   d S ©Nr"   ©r7   r8   r"   r"   r#   Údatetime_minimumÏ   ó   r=   c                 C   r:   r;   r"   r<   r"   r"   r#   Údatetime_maximumÓ   r>   r?   )Ú__doc__ÚnumpyÚnpr   Útimedelta64ÚastypeÚint64ZNATr$   r%   r)   r.   r/   r5   r6   r9   r=   r?   r"   r"   r"   r#   Ú<module>   sN    ñõ	4