o
    5c                     @  sj   d dl mZ d dlmZmZ d dlZd dlmZ d dlm	Z	m
Z
 d dlmZ dd	d
Zg dZdd ZdS )    )annotations)datetimetimeN)is_list_like)ABCIndex	ABCSeries)notnaFraisec                   s    fdd}| du r| S t | tr| S t | tr)|| j|}| j|| j| jdS t | tr3|| |S t| r<|| |S |t	
| g|d S )a  
    Parse time strings to time objects using fixed strptime formats ("%H:%M",
    "%H%M", "%I:%M%p", "%I%M%p", "%H:%M:%S", "%H%M%S", "%I:%M:%S%p",
    "%I%M%S%p")

    Use infer_time_format if all the strings are in the same format to speed
    up conversion.

    Parameters
    ----------
    arg : string in time format, datetime.time, list, tuple, 1-d array,  Series
    format : str, default None
        Format used to convert arg into a time object.  If None, fixed formats
        are used.
    infer_time_format: bool, default False
        Infer the time format based on the first non-NaN element.  If all
        strings are in the same format, this will speed up conversion.
    errors : {'ignore', 'raise', 'coerce'}, default 'raise'
        - If 'raise', then invalid parsing will raise an exception
        - If 'coerce', then invalid parsing will be set as None
        - If 'ignore', then invalid parsing will return the input

    Returns
    -------
    datetime.time
    c                   s  t | ttfrtj| dd} nt| dddkrtdtj| dd} r,|d u r,t| }g }|d ur~| D ]G}z|	t
||  W q4 ttfy{ } z* dkr^d| d| }t|| d	krl| W  Y d }~  S |	d  W Y d }~q4d }~ww |S td d  }d
}| D ]g}d }zt|}W n8 ttfy   |D ]*}	zt
||	 }|s|||	}
|d|
 d}W  n ttfy   Y qw Y nw |d ur|	| q dkrtd|  d d	kr|   S |	d  q|S )NO)dtypendim   zAarg must be a string, datetime, list, tuple, 1-d array, or Seriesr	   zCannot convert z to a time with given format ignoreFr   TzCannot convert arg z
 to a time)
isinstancelisttuplenparraygetattr	TypeErrorasarray_guess_time_format_for_arrayappendr   strptimer   
ValueError_time_formatsfromisoformatpopindexinsert)argformattimeselementerrmsgformatsformat_foundtime_objecttime_formatfmterrorsinfer_time_format M/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/core/tools/times.py_convert_listlike/   sn   
(z"to_time.<locals>._convert_listlikeN)r   namer   )r   r   r   _values_constructorr   r1   r   r   r   r   )r    r!   r-   r,   r0   valuesr.   r+   r/   to_time   s   >




r5   )z%H:%Mz%H%Mz%I:%M%pz%I%M%pz%H:%M:%Sz%H%M%Sz
%I:%M:%S%pz%I%M%S%pc              	   C  sZ   t |  d }t|r+| |d  }tD ]}zt|| |W   S  ty*   Y qw d S )Nr   )r   nonzerolenr   r   r   r   )arrnon_nan_elementsr#   r)   r.   r.   r/   r      s   
r   )NFr	   )
__future__r   r   r   numpyr   pandas._libs.libr   pandas.core.dtypes.genericr   r   pandas.core.dtypes.missingr   r5   r   r   r.   r.   r.   r/   <module>   s    
j