%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/util/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyc

�
b�Nc@s�dZddlmZmZmZddlmZddlZddddd	d
gZd�Zd�Z	d
�Z
d�Zd�Zedd�Z
idd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6Zd)�Zid*d6d+d6d*d6d,d6d*d6d,d6d*d6d*d6d,d!6d*d#6d,d%6d*d'6Zid-d6d.d6d/d6d0d6d1d6d2d6d3d6d4d6d5d!6d6d#6d7d%6d8d'6ZdBZd@�ZedA�ZdS(Cs.	
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.

i����(t	timedeltattimetdate(t	localtimeNtparse_timedeltatnormalize_timedeltat
parse_timetnormalize_timet
parse_datetnormalize_datecCs ytj|�SWndSXdS(N(tstringtatoitNone(tval((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyt_number@scCs_|s
d
Stj|�}d|krRt|�}tdt|�dd|d�Sd|kpgd|k}d|kpd|k}d|k}x#d	D]}tj||d
�}q�Wtj|�}tj|�}d}d}|j	�|rt|j
��}n|rt|j
��}nt|�dkrL|rLt|j
��}ntd|d|�S(s1
    returns a ``timedelta`` object, or None
    t.thourstminutesi<g�?tht:tmsminu:teshour()t giN(RR
tlowertfloatRtinttreplacetstriptsplittreversetpoptlen(R
tfHourtfMint	fFractiontnoisethrtmi((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyRIs.!

cCs_t|�tkr!t|�}n|s+dS|jd}|jdd}d||ddfS(s�
    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.
    tii<s%d.%02did(ttypetstrRtseconds(R
R#tmn((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyRes
cCs�|s
dSd}}tj|�}dtj|d�k}dtj|d�k}x#dD]}tj||d�}qZWtj|�}t|�dkr�t|d�}t|d�}n�|d}t|�dkr�n�d|krt�}|d	}|d
}n�d|krd}n�t|�d	kret|�}|r�|r�|d
kr�|d7}q�nEt|�dkr�t|d �}t|d�}nt|d �}|r�|dkr�|d}n|r�|dkr�|d}nt	||�S(Nii����tatps:amp.Ritnowiitnooniiii����(
RR
RtfindRRRRRR(R
R#R$tamflagtpmflagR"ttm((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyRxsD


	

	

cCs�|s
dSt|�tkr+t|�}n|sEd|j|jfS|j}d}|dksl|dkrud}n.|dkr�d}|dkr�|d}q�nd||j|fS(	NR%s	%02d:%02dtAMiiitPMs%02d:%02d %s(R&R'Rthourtminute(tvaluetampmR#tam((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyR�s		tdaysitjanitfebitmaritapritmayitjunitjulitaugi	tsepi
toctitnovitdeccCsAx*tj�D]\}}||kr
|Sq
Wtd|��dS(Nsunknown month '%s'(t_str2numtitemst	TypeError(R
tkeytmon((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyt_month�siiitJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDecRJttuetwedtthutfritsattsuncCs�|s
dStj|�}d}|jd�}t|�dkr�|\}}}d|krq|jd�d}nd|kr�|jd�d}ny6tt|�t|�t|��}d|d}Wq�tk
r�q�Xn|se|d }|dkrtj�}qe|t	kretj�}t
t	�j|�d
}x#|j�|kr^|t
7}q?Wqen|r�|dj�}|jdd�jdd�}xK|j�D]=}	yt|	�}
Wntk
r�q�X|td
|
�7}q�W|Sd}}}
x#dD]}tj||d�}qWx#t	D]}tj||d�}q&Wg}t}t}xs|D]k}|j�r�|r�|r�|jd�nt}}n"|r�|jd�t}nt}|j|�q^Wtjdj|��}dt|�krt|d�}t|d
�}t|d�}t|d�dkrq|}|rX|}|}
qt|d
�}|}
qG|dkr�|}t|d�dkr�td��n|r�|}
|}q|}
t|d
�}qG|}
|}t|d�dkrtd��nt|d�}n-dt|�kr!t|d�}t|d
�}|dkr�|}d
}
|dkry|}qt|d
�}qG|dkr�|dkr�|}|}d
}
q|dkr�|}|}
q|}
t|d
�}qG|dkr|}d
}
n|}
t|d�}n&d
t|�krG|d}|j�smt|�}|dk	rDd
}
qDqGt|�}t|�}dt|�kr�t|d �}t|dd!�}t|d�}
qGt|�dkr#|dkr|}d
}d
}
qDt|d �}t|d�}
qG|dkr8|}
qGtd��nt�}|dkri|d
}n|
dkr�|d}
n|dkr�|d}nt|||
�S(Nt-it+iRtxxxi
R,ttodis +s -R9t/t,t*R%iisfour digit year requiredi�iiii����i (snowRa(RbR^RcRd(ii(RR
RRRRRt
ValueErrorttodayt_wkdytlisttindext
isoweekdayt_one_dayRRRtFalsetisdigittappendtTruetjoinRRKRHR'R(R
R,tstricttyRtdtchktidxttailtitemR9tyrtmotdyR"touttlasttldigtchR*tbtctvR1((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyR�s
$








								
			


cCsi|s
dSt|�tkr+t|�}n|rKd|j|j|jfSd|jt|j|jfS(NR%s
%4d-%02d-%02ds%02d %s %4d(R&R'Rtyeartmonthtdayt_num2str(R
tiso8601((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyR	bs(smonRXRYRZR[R\R](t__doc__tdatetimeRRRRR
t__all__RRRRRRkRFRKt_days_in_monthR�RgRRoR	(((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyt<module>7s,					&	--	----	�

Zerion Mini Shell 1.0