Ñò ô†³Kc @sÈdZddklZlZlZddklZddkZddddd d gZd „Zd „Z d „Z d„Z d„Z eddƒZ h dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6Zd)„Zh d*d6d+d6d*d6d,d6d*d6d,d6d*d6d*d6d,d!6d*d#6d,d%6d*d'6Zh 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 yti|ƒSWndSXdS(N(tstringtatoitNone(tval((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyt_number@scCsl|pd Sti|ƒ}d|jo.t|ƒ}tdt|ƒdd|dƒSd|jp d|j}d|jp d|j}d|j}x#d D]}ti||d ƒ}q›Wti|ƒ}ti|ƒ}d }d }|i ƒ|ot|i ƒƒ}n|ot|i ƒƒ}nt |ƒd jo| ot|i ƒƒ}ntd|d|ƒS(s1 returns a ``timedelta`` object, or None t.thourstminutesi<gð?tht:tmsminu:teshour()t giN( R R tlowertfloatRtinttreplacetstriptsplittreversetpoptlen(R tfHourtfMint fFractiontnoisethrtmi((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyRIs0  "  cCsct|ƒtjot|ƒ}n|pdS|id}|idd}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((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyRes cCs |pdSd}}ti|ƒ}dti|dƒj}dti|dƒj}x#dD]}ti||dƒ}q\Wti|ƒ}t|ƒdjo$t|dƒ}t|dƒ}nü|d}t|ƒdjonÛd|jo!tƒ}|d }|d }n­d |jo d }n–t|ƒd jo;t|ƒ}| o#| o|d jo|d 7}q¼nHt|ƒdjo$t|d ƒ}t|dƒ}nt|d ƒ}|o|d jo|d }n|o|d jo|d }nt ||ƒS(Niiÿÿÿÿtatps:amp.Ritnowiitnooni iiiþÿÿÿ( R R RtfindRRRRRR(R R#R$tamflagtpmflagR"ttm((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyRxsF        cCsÄ|pdSt|ƒtjot|ƒ}n|pd|i|ifS|i}d}|djp |djo d}n3|djo%d}|djo|d}q°nd||i|fS( NR%s %02d:%02dtAMiii tPMs %02d:%02d %s(R&R'Rthourtminute(tvaluetampmR#tam((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyRžs    tdaysitjanitfebitmaritapritmayitjunitjulitaugi tsepi tocti tnovi tdeccCsCx,tiƒD]\}}||jo|Sq Wtd|ƒ‚dS(Nsunknown month '%s'(t_str2numtitemst TypeError(R tkeytmon((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyt_month¸s    iiitJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDecRJttuetwedtthutfritsattsuncCsø|pdSti|ƒ}d}|idƒ}t|ƒdjo§|\}}}d|jo|idƒd}nd|jo|idƒd}ny6tt|ƒt|ƒt|ƒƒ}d|d}Wqêtj oqêXn|p†|d }|djotiƒ}qw|t joNtiƒ}t t ƒi |ƒd }x&|i ƒ|jo|t 7}qMWqwn|oƒ|diƒ}|idd ƒidd ƒ}xM|iƒD]?} yt| ƒ} Wntj oq¹X|td | ƒ7}q¹W|Sd} } } x#dD]}ti||dƒ}qWx#t D]}ti||dƒ}q<Wg}t}t}xz|D]r}|iƒo.|o| o|idƒnt}}n%|o|idƒt}nt}|i|ƒqtWtidi|ƒƒ}dt|ƒjo0t|dƒ}t|d ƒ}t|dƒ}t|dƒdjo7|} |o|} |} qAt|d ƒ} |} qŽ|djo^|} t|dƒdjotdƒ‚n|o|} |} qA|} t|d ƒ} qŽ|} |} t|dƒdjotdƒ‚nt|dƒ} nJdt|ƒjot|dƒ}t|d ƒ}|djo7|} d } |djo |} qVt|d ƒ} qŽ|djoZ|djo|} |} d } qV|djo|} |} qV|} t|d ƒ} qŽ|djo|} d } n|} t|dƒ} n5d t|ƒjo!|d}|iƒp't|ƒ} | dj o d } qŠqŽt|ƒ}t|ƒ}dt|ƒjo7t|d ƒ} t|dd!ƒ} t|dƒ} qŽt|ƒdjoG|djo|} d } d } qŠt|d ƒ} t|dƒ} qŽ|djo |} qŽtdƒ‚ntƒ}| djo|d } n| djo|d} n| djo|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((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyRÆs  $                                     cCso|pdSt|ƒtjot|ƒ}n|od|i|i|ifSd|it|i|ifS(NR%s %4d-%02d-%02ds %02d %s %4d(R&R'Rtyeartmonthtdayt_num2str(R tiso8601((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyR bs(smonRXRYRZR[R\R](t__doc__tdatetimeRRRRR t__all__RRRRRRkRFRKt_days_in_monthR…RgRRoR (((s;/usr/lib/python2.6/site-packages/paste/util/datetimeutil.pyt7s,     & -- ---- œ