
    J/Ph                         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                              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dS )'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                 J    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     [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/np/npdatetime_helpers.py	same_kindr&   (   s#     3!#)=)ABB    c                     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"   s     r%   can_cast_timedelta_unitsr)   /   sk    
 
C$D
d{{t
byyt
Tzzurzzu
axxD1HHu4r'   )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dS | }d}||k     r.	 t           |         \  }}n# t          $ r Y dS w xY w||z  }||k     .||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)big_unit_codesmall_unit_codecfactormults        r%   _get_conversion_multiplierr5   U   s     qAF
o

	qkGAtt 	 	 	44	 	$ o

 	Ots   % 
33c                 N    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 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   s    "-0L!.1Lr\R//a""aLA--l+mm^^^= > > 	>Iy q1&IILLQ&IIL			1&I ILLQ&I$IL|##+L,GG!!L,#?!!!y619<<+L,GG!!L,#?!!!iV);;;r'   c                     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    )r=   r>   r?   r@   s       r%    combine_datetime_timedelta_unitsrE      sk     "-0L!.1Lr			aLA--tl""r'   c                 j    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    )unit_aunit_babs       r%   get_best_unitrK      sG     	vAvABwwBww1uuMr'   c                     d S N rI   rJ   s     r%   datetime_minimumrP          Dr'   c                     d S 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?        
	
	
	
	
	
	

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