%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/paste/util/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/paste/util/__pycache__/datetimeutil.cpython-37.pyc

B

b�N�+�
@s�dZddlmZmZmZddlmZddlZddddd	d
gZdd�Zd
d�Z	dd�Z
dd�Zdd�Zedd�Z
ddddddddddddd�Zdd �Zd!d"d!d#d!d#d!d!d#d!d#d!d$�Zd%d&d'd(d)d*d+d,d-d.d/d0d$�Zd1Zd2d	�Zd5d4d
�ZdS)6a.	
Date, Time, and Timespan Parsing Utilities

This module contains parsing support to create "human friendly"
``datetime`` object parsing.  The explicit goal of these routines is
to provide a multi-format date/time support not unlike that found in
Microsoft Excel.  In most approaches, the input is very "strict" to
prevent errors -- however, this approach is much more liberal since we
are assuming the user-interface is parroting back the normalized value
and thus the user has immediate feedback if the data is not typed in
correctly.

  ``parse_date`` and ``normalize_date``

     These functions take a value like '9 jan 2007' and returns either an
     ``date`` object, or an ISO 8601 formatted date value such
     as '2007-01-09'.  There is an option to provide an Oracle database
     style output as well, ``09 JAN 2007``, but this is not the default.

     This module always treats '/' delimiters as using US date order
     (since the author's clients are US based), hence '1/9/2007' is
     January 9th.  Since this module treats the '-' as following
     European order this supports both modes of data-entry; together
     with immediate parroting back the result to the screen, the author
     has found this approach to work well in pratice.

  ``parse_time`` and ``normalize_time``

     These functions take a value like '1 pm' and returns either an
     ``time`` object, or an ISO 8601 formatted 24h clock time
     such as '13:00'.  There is an option to provide for US style time
     values, '1:00 PM', however this is not the default.

  ``parse_datetime`` and ``normalize_datetime``

     These functions take a value like '9 jan 2007 at 1 pm' and returns
     either an ``datetime`` object, or an ISO 8601 formatted
     return (without the T) such as '2007-01-09 13:00'. There is an
     option to provide for Oracle / US style, '09 JAN 2007 @ 1:00 PM',
     however this is not the default.

  ``parse_delta`` and ``normalize_delta``

     These functions take a value like '1h 15m' and returns either an
     ``timedelta`` object, or an 2-decimal fixed-point
     numerical value in hours, such as '1.25'.  The rationale is to
     support meeting or time-billing lengths, not to be an accurate
     representation in mili-seconds.  As such not all valid
     ``timedelta`` values will have a normalized representation.

�)�	timedelta�time�date)�	localtimeN�parse_timedelta�normalize_timedelta�
parse_time�normalize_time�
parse_date�normalize_datecCsy
t�|�SdSdS)N)�string�atoi)�val�r�H/opt/alt/python37/lib/python3.7/site-packages/paste/util/datetimeutil.py�_number@s
rcCs�|sdSt�|�}d|kr:t|�}tt|�d|dd�Sd|kpHd|k}d|kpXd|k}d|k}xd	D]}t�||d
�}qhWt�|�}t�|�}d}d}|��|r�t|�	��}|r�t|�	��}t
|�dkr�|s�t|�	��}t||d�S)
z1
    returns a ``timedelta`` object, or None
    N�.�<g�?)�hours�minutes�h�:�mzminu:teshour()� gr)r�lower�floatr�int�replace�strip�split�reverse�pop�len)rZfHourZfMinZ	fFraction�noise�hr�mirrrrIs.



cCsHt|�tkrt|�}|sdS|jd}|jdd}d||ddfS)z�
    produces a normalized string value of the timedelta

    This module returns a normalized time span value consisting of the
    number of hours in fractional form. For example '1h 15min' is
    formatted as 01.25.
    �irz%d.%02d�d)�type�strr�seconds)rr$Zmnrrrres
cCsr|sdSd}}t�|�}dt�|d�k}dt�|d�k}xdD]}t�||d�}q@Wt�|�}t|�dkr�t|d�}t|d�}n�|d}t|�dkr�n�d|kr�t�}|d	}|d
}n|d|kr�d}nnt|�d	kr�t|�}|s�|s�|d
kr�|d7}n@t|�dk�r(t|dd��}t|dd��}nt|dd��}|�rP|dk�rP|d}|�rh|dk�rh|d}t||�S)Nr����a�pz:amp.r��now��Znoon������)	rr�findrrr"rrr)rr$r%ZamflagZpmflagr#�tmrrrrxsD




cCs||sdSt|�tkrt|�}|s0d|j|jfS|j}d}|dksJ|dkrPd}n|dkrld}|dkrl|d}d||j|fS)	Nr&z	%02d:%02dZAMr.�r2ZPMz%02d:%02d %s)r(r)r�hour�minute)�valueZampmr$�amrrrr	�sr.)�days�r0r1r4�r3��	�
�r2)�jan�feb�mar�apr�may�jun�jul�aug�sep�oct�nov�deccCs2x t��D]\}}||kr
|Sq
Wtd|��dS)Nzunknown month '%s')�_str2num�items�	TypeError)r�key�monrrr�_month�srU���)r.r>r0r1r4r?r3r@rArBrCr2�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Dec)rT�tue�wed�thu�fri�sat�sunc	Cs|sdSt�|�}d}|�d�}t|�dkr�|\}}}d|krL|�d�d}d|krb|�d�d}y,tt|�t|�t|��}d|dd�}Wntk
r�YnX|�s|dd�}|dkr�t��}n@|tk�rt��}t	t��
|�d	}x|��|k�r|t7}q�W|�r||dd��
�}|�dd
��dd�}xD|��D]8}	yt|	�}
Wntk
�rbYnX|t|
d�7}�q<W|Sd}}}
xd
D]}t�||d�}�q�WxtD]}t�||d�}�q�Wg}d}d}xZ|D]R}|���r|�r�|�s�|�d�d}}n|�r|�d�d}d}|�|��q�Wt�d�|��}dt|�k�r"t|d�}t|d	�}t|d�}t|d�dk�r�|}|�r�|}|}
nt|d	�}|}
nx|dk�r�|}t|d�dk�r�td��|�r�|}
|}n|}
t|d	�}n.|}
|}t|d�dk�rtd��t|d�}�n�dt|�k�r�t|d�}t|d	�}|dk�rx|}d	}
|dk�rj|}nt|d	�}nl|dk�r�|dk�r�|}|}d	}
n$|dk�r�|}|}
n|}
t|d	�}n$|dk�r�|}d	}
n|}
t|d�}n�d	t|�k�r�|d}|���st|�}|dk	�r�d	}
n�t|�}t|�}dt|�k�rnt|dd��}t|dd��}t|dd��}
n`t|�dk�r�|dk�r�|}d	}d	}
n t|dd��}t|dd��}
n|dk�r�|}
ntd��t�}|dk�r�|d	}|
dk�r�|d}
|dk�r
|d}t|||
�S)N�-r0�+rrZxxxrB)r/Ztodr.z +z -)r=)�/rk�,�*FTr&r>r1zfour digit year requiredi�r@r?)r0r1ir5� )rrrr"rr�
ValueError�today�_wkdy�list�index�
isoweekday�_one_dayrrr�isdigit�append�joinrrUrRr)r)rr/�strict�yr�dZchk�idx�tail�itemr=Zyr�moZdyr#�out�lastZldig�chr,�b�c�vr7rrrr
�s


























TcCsL|sdSt|�tkrt|�}|r4d|j|j|jfSd|jt|j|jfS)Nr&z
%4d-%02d-%02dz%02d %s %4d)r(r)r
�year�month�day�_num2str)rZiso8601rrrrbs)T)�__doc__�datetimerrrrr�__all__rrrrr	rwrPrUZ_days_in_monthr�rsr
rrrrr�<module>7s.	&


Zerion Mini Shell 1.0