• File: datetimeutil.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyc
  • Date Modified: 08/01/2016 7:39 PM
  • File size: 9.86 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

bNc@sdZddlmZmZmZddlmZddlZddddd	d
gZdZdZ	d
Z
dZdZeddZ
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@ZedAZdS(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|dSd|kpgd|k}d|kpd|k}d|k}x#d	D]}tj||d
}qWtj|}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|dk}dtj|dk}x#dD]}tj||d}qZWtj|}t|dkrt|d}t|d}n|d}t|dkrnd|krt}|d	}|d
}nd|krd}nt|d	kret|}|r|r|d
kr|d7}qnEt|dkrt|d }t|d}nt|d }|r|dkr|d}n|r|dkr|d}nt	||S(Niitatps: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.|dkrd}|dkr|d}qnd||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.pyRs		tdaysitjanitfebitmaritapritmayitjunitjulitaugi	tsepi
toctitnovitdeccCsAx*tjD]\}}||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_monthsiiitJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDecRJttuetwedtthutfritsattsuncCs|s
dStj|}d}|jd}t|dkr|\}}}d|krq|jdd}nd|kr|jdd}ny6tt|t|t|}d|d}Wqtk
rqXn|se|d }|dkrtj}qe|t	kretj}t
t	j|d
}x#|j|kr^|t
7}q?Wqen|r|dj}|jddjdd}xK|jD]=}	yt|	}
Wntk
rqX|td
|
7}qW|Sd}}}
x#dD]}tj||d}qWx#t	D]}tj||d}q&Wg}t}t}xs|D]k}|jr|r|r|jdnt}}n"|r|jdt}nt}|j|q^Wtjdj|}dt|krt|d}t|d
}t|d}t|ddkrq|}|rX|}|}
qt|d
}|}
qG|dkr|}t|ddkrtdn|r|}
|}q|}
t|d
}qG|}
|}t|ddkrtdnt|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}|jsmt|}|dk	rDd
}
qDqGt|}t|}dt|krt|d }t|dd!}t|d}
qGt|dkr#|dkr|}d
}d
}
qDt|d }t|d}
qG|dkr8|}
qGtdnt}|dkri|d
}n|
dkr|d}
n|dkr|d}nt|||
S(Nt-it+iRtxxxi
R,ttodis +s -R9t/t,t*R%iisfour digit year requirediiiiii (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.pyRs
$








								
			


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_monthRRgRRoR	(((sH/opt/alt/python27/lib/python2.7/site-packages/paste/util/datetimeutil.pyt<module>7s,					&	--	----