
    xKg                         d Z ddlZdddddddd	d
ddddddZ ej                  d      j                  ej                        Zd Zd Z	ddddddddddddZ
d  Zd! Zd" Zd# Zd$ Zd% Zd& Zy)'z
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 natc                 4    t         |    dk  t         |   dk  k(  S )zB
    Whether the *src* and *dest* units are of the same kind.
    r   DATETIME_UNITSsrcdests     _/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/np/npdatetime_helpers.py	same_kindr&   (   s#     3!#)=)ABB    c                 n    t         |    } t         |   }| |k(  ry| dk(  ry| |kD  ry|dk(  ry| dk  r|dkD  ryy)NTr   Fr   r    r"   s     r%   can_cast_timedelta_unitsr)   /   sS    
 
C$D
d{
by
Tzrz
axD1H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                 ~    | dk(  ry| }d}||k  r	 t         |   \  }}||z  }||k  r||k(  r|S y# t        $ r Y yw xY w)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)big_unit_codesmall_unit_codecfactormults        r%   _get_conversion_multiplierr5   U   sn     AF
o
	qkGAt 	$ o
 	O  		s   0 	<<c                 6    t        t        |    t        |         S )zl
    Return an integer multiplier allowing to convert from timedeltas
    of *src_unit* to *dest_unit*.
    )r5   r!   )src_unit	dest_units     r%   get_timedelta_conversion_factorr9   o   s"    
 &nX&>&4Y&?A Ar'   c                 ~   t         |    }t         |   }|dk(  s|dk(  r| ddfS |dk  r|dk\  rt        d| d|d      d\  }}|dk(  r|d	k\  rd
}d}d	}n(|dk(  r#d
}d}d}n|dk(  r|d	k\  rd
}d}d	}n|dk(  rd
}d}d}||k\  rt        ||      }|	J ||f       |||z  |fS t        ||      }|	J ||f       | |||z  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   zcannot combine datetime64(z) and timedelta64())r   r   r   r   i: i  i
  i  i@  )r!   RuntimeErrorr5   )datetime_unittimedelta_unitdt_unit_codetd_unit_code	dt_factor	td_factorr3   s          r%   !get_datetime_timedelta_conversionrC   x   sB    "-0L!.1Lr\R/a""aLA-+^= > 	>Iy q1&IILQ&IIL		1&I ILQ&I$IL|#+L,G!?L,#??!y619<<+L,G!?L,#??!iV);;;r'   c                 j    t         |    }t         |   }|dk(  r|S |dk(  r| S |dk  r|dk\  ry||kD  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    )r=   r>   r?   r@   s       r%    combine_datetime_timedelta_unitsrE      sZ     "-0L!.1Lr		aLA-l"r'   c                 T    t         |    }t         |   }|dk(  r|S |dk(  r| S ||kD  r|S | S )z9
    Get the best (i.e. finer-grained) of two units.
    r   r    )unit_aunit_babs       r%   get_best_unitrK      sA     	vAvABwBw1uMr'   c                      y N rI   rJ   s     r%   datetime_minimumrP          r'   c                      y rM   rN   rO   s     r%   datetime_maximumrS      rQ   r'   )__doc__numpynpr!   timedelta64astypeint64NATr&   r)   r.   r5   r9   rC   rE   rK   rP   rS   rN   r'   r%   <module>r[      s     
	
	
	
	
	
	







$ bnnU""288,C0 4A1<h(		r'   