m ].5?c @sdZdkZdkZdkZdkZdkZdkZdkZdZdZ dZ de dZ de dZ dZ dZd Zd Zhd d <d d<dd<dd<dd<dd<dd<dd<dd<dd<dd <d!d"<d#d<d$d<d%d<d&d<d'd<d(d"<d)d<d*d<d+d<d,d<d-d<d.d<d/d"<d0d <d1d<d2d<d3d"<d4dd<d?d<d@d<dAd <dBd<dCd<dDd<dEd<dFd<dGd<dd <dHd<dId<dJd<dEd<dKd<dLd<dMd<dNd<dOd<dPd<dQd<dRd <dSd<dTd<dUdei<e*ei=Z?ei<e/ei=Z@ei<e0ei=ZAei<e,ei=ZBei<e-ei=ZCei<e.ei=ZDei<e1ei=ZEei<e2ei=ZFei<e3ei=ZGei<e5ei=ZHei<e6ei=ZIei<e8ZJei<e9ZKei<e:ZLei<e;ZMei<e7ei=ZNdddddddddf ZOeOePeiQeiReiSeiTeiUdZVddfeiQeiRdZWeOePedZXeOePedZYeOdZZeOdZ[e\edZ]e]Z^e]Z_eiQeiRdZ`eiQeiRdZaeibdZceibdZdeibdZedZfegdjo efndS(s Date/Time string parsing module. Note about the Y2K problems: The parser can only handle years with at least 2 digits. 2 digit year values get expanded by adding the century using DateTime.add_century(), while 3 digit year get converted literally. To have 2 digit years also be interpreted literally, add leading zeros, e.g. year 99 must be written as 099 or 0099. The literal string encoding used in this file is Latin-1. Copyright (c) 1998-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com See the documentation for further information on copyrights, or contact the author. All Rights Reserved. Nis(?P-?\d+\d(?!:))s(?P-?\d+\d\d(?!:))s(?:s(?P *[ABCDE\.]+)?)s(?:\((?P[-+]?\d+)\))s(?P\d?\d(?!:))s(?P\d\d(?!:))s(?Pjan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|mr|mae|mrz|mai|okt|dez|fev|avr|juin|juil|aou|ao|dc|ene|abr|ago|dic|out)[a-z,\.;]*tjanitfebitmaritapritmayitjunitjulitaugitsepi tocti tnovi tdeci smrtmaetmrztmaitokttdeztfevtavrtjuintjuiltaousaosdctenetabrtagotdictouts(?:\((?P[-+]?\d+)\))s(?P\d?\d(?!:))s*(?P\d?\d(?!:))(?:st|nd|rd|th|[,\.;])?s(?P\d\d(?!:))s(?Pmon|tue|wed|thu|fri|sat|sun|die|mit|don|fre|sam|son|lun|mar|mer|jeu|ven|sam|dim|mie|jue|vie|sab|dom|pri|seg|ter|cua|qui)[a-z]*tmonttuetwedtthutfritsattsuntdietmittdontfretsamtsontluntmertjeutventdimtmietjuetvietsabtdomtpritsegttertcuatquis(?:\((?P[-+]?\d+)\))s(?P[012]?\d)s(?P[0-6]\d)s(?P[0-6]\d(?:\.\d+)?)s(?P\d*\d(?:\.\d+)?)s(?P\d*\d(?:\.\d+)?)s(?P\d*\d(?:\.\d+)?)s(?P\d*\d(?:\.\d+)?)s'(?:\((?P[-+]?\d+(?:\.\d+)?)\))s((?:\((?P[-+]?\d+(?:\.\d+)?)\))s*(?:\((?P[-+]?\d+(?:\.\d+)?)\))s*(?:\((?P[-+]?\d+(?:\.\d+)?)\))s(?:(?P[-+]) *)sW(?P\d?\d)s(?P[ap][m.]+)t:s(?::s)? *s? *t?s:?s-?(?:s-?s?)?s\.t/s(?:/s)?t-s?(?!:)s(?!:)s,? )? *s *s [- ] *(?:t|s ) *[- ] *s [ ,.a-z]+s (?:[ a-z]+s ,?[ a-z]+)? *s [ a-z]+)? *s (?:[ ,.a-z]+s [*%?a-zA-Z]+s(?:(?:s)-s))s) *[- ]s (?:[0-9: ]+)s):t)s(?::(?:s))?)s *d[a-z]*[,; ]*)?s *h[a-z]*[,; ]*)?s *m[a-z]*[,; ]*)?s *s[a-z]*[,; ]*)?teurotustaltustisotaltisotlittaltlitteurlittunknowncCsd}d} x|D]}|djoti|}|dj o|i\}} } } | o9t | djo||| } q|| } n$|djo |}n|i } | od| jo| d} n|| } | djp | djoqn||}Pqq|djp |d jo-|djoti|}nti|}|dj o|i\} }} } | o9t | djo||| } q|| } n$|djo |}n|i } | od| jo| d} n|| } | djp | djoqn|o||}nd}Pqq|d jp |d jo|d joti|}n_ti|}|dj oB|i\}}|djo||d|!d joqqn|dj o|i\} } }t | djo||| } n || } | p d} n || } |p d}n ||}Pqq|d joCti|}|dj o#|i\} }}} } } Pqq|djoFti|}|dj o&|i\} }}} } d} Pqq|djoFti|}|dj o&|i\} }}} } d} Pqq|djo@|djo |}n|i } |i } |i }|} PqqW|dj of|i\}}do1to*dGt|||!GdG| G| G|GHn|| ||}|} n| pt d|n| djo)doto|iGHn| p'|djo |}n|i } n6t | djo||| } n || } | od| jo| d} n|oA||}yt"|} Wqt#j ot d|qXn| o|| } nd} |o||}qd}n||| | | fS(s Parses the date part given in text and returns a tuple (text,day,month,year,style) with the following meanings: * text gives the original text without the date part * day,month,year give the parsed date * style gives information about which parser was successful: 'euro' - the European date parser 'us' - the US date parser 'altus' - the alternative US date parser (with '-' instead of '/') 'iso' - the ISO date parser 'altiso' - the alternative ISO date parser (without '-') 'lit' - the US literal date parser 'altlit' - the alternative US literal date parser 'eurlit' - the Eurpean literal date parser 'unknown' - no date part was found, defaultdate was used formats may be set to a tuple of style strings specifying which of the above parsers to use and in which order to try them. Default is to try all of them in the above order. defaultdate provides the defaults to use in case no date part is found. Most other parsers default to the current year January 1 if some of these date parts are missing. If 'unknown' is not given in formats and the date cannot be parsed, a ValueError is raised. tR=itBii iR>R?R@RAtTRBRCs RDREs parsed date:sgiving:sunknown date format: "%s"swrong month name: "%s"N(RBRCRD($tNonetmatchtstyletformatstformatt _eurodateREtsearchttexttgroupstdaytmonthtyeartepochtlent add_centurytatoit defaultdatetnowt _usdateREt _altusdateREt _isodateREt _altisodateREtspantlefttrightt _litdateREtlitdaytlitmontht _altlitdateREt _eurlitdateREt_debugtreprt ValueErrortlowert litmonthtabletKeyError(RPRLRYRXtatofRjRWRZRaRSRTRKRURcRJRMRRRdR`((t=/data/zmath/lib/python2.4/site-packages/mx/DateTime/Parser.pyt _parse_dates$                 %                         *        cCsd }d}x|D]} | djoFti|}|d j o&|i\} } }} }d}Pqln| djoIti|}|d j o)|i\} } }}d } d}Pqq| djod\} } }} d}PqqW|ptd|n|d j o|oti|} nd} || } | o#| ddjo| d } qkn| o|| } nd} |p d}n ||}|i\}}do5to.d Gt|||!Gd G| G| G|G| GHn|| ||}n|| | || |fS(s^ Parses a time part given in text and returns a tuple (text,hour,minute,second,offset,style) with the following meanings: * text gives the original text without the time part * hour,minute,second give the parsed time * offset gives the time zone UTC offset * style gives information about which parser was successful: 'standard' - the standard parser 'iso' - the ISO time format parser 'unknown' - no time part was found formats may be set to a tuple specifying the parsers to use: 'standard' - standard time format with ':' delimiter 'iso' - ISO time format (superset of 'standard') 'unknown' - default to 0:00:00, 0 zone offset If 'unknown' is not given in formats and the time cannot be parsed, a ValueError is raised. RFtstandardR@REif0.0sunknown time format: "%s"tptPi s parsed time:sgiving:N(iif0.0i(RqRr(RIRJRKRLRMt_timeRERORPRQthourtminutetsecondtampmtzonet _isotimeREtoffsetRitTimezonet utc_offsetRXRmR_R`RaRgRh(RPRLRXRmRaRvRKRxRJRMRzRuRtRwR`((Rnt _parse_timesV            .cCs|}t|}|tjpd|jp d|jo|dd jont|d \}}}} } }t ||d |\}} } }}dotod|||fGHqnd}|djojt |||\}} } }}t|d\}}}} } }dotod|||fGHq5q{nCt|d\}}}} } }t |||\}} } }}|djp |djo'd|jotd|||fny$|i|| | ||| | SWn.|ij o} |id || fnXd S(s  DateTimeFromString(text, [formats, defaultdate]) Returns a DateTime instance reflecting the date and time given in text. In case a timezone is given, the returned instance will point to the corresponding UTC time value. Otherwise, the value is set as given in the string. formats may be set to a tuple of strings specifying which of the following parsers to use and in which order to try them. Default is to try all of them in the order given below: 'euro' - the European date parser 'us' - the US date parser 'altus' - the alternative US date parser (with '-' instead of '/') 'iso' - the ISO date parser 'altiso' - the alternative ISO date parser (without '-') 'lit' - the US literal date parser 'altlit' - the alternative US literal date parser 'eurlit' - the Eurpean literal date parser 'unknown' - if no date part is found, use defaultdate defaultdate provides the defaults to use in case no date part is found. Most other parsers default to the current year January 1 if some of these date parts are missing. If 'unknown' is not given in formats and the date/time cannot be parsed, a ValueError is raised. R@RAiRpREs'tried time/date on %s, date=%s, time=%ss!tried ISO on %s, date=%s, time=%ss0Failed to parse "%s": found "%s" date, "%s" timesFailed to parse "%s": %sN(sisosaltiso(sstandardsisosunknown(sunknown(sisosunknown(sisosunknown(sstandardsunknown(RPtorigtextttupleRLt _date_formatsR}RtRuRvRzt timestyleRoRYRRRSRTt datestyleRgRitDateTimet RangeErrortwhy(RPRLRYRRRtRRTR~RRvRzRSRRRu((RntDateTimeFromStrings@  ' '$c Cst|||\}} }}}|djo$d|jot dt |fny|i ||| SWn.|i j o}|i d||fnXdS(s DateFromString(text, [formats, defaultdate]) Returns a DateTime instance reflecting the date given in text. A possibly included time part is ignored. formats and defaultdate work just like for DateTimeFromString(). REs%Failed to parse "%s": found "%s" datesFailed to parse "%s": %sN(RoRPRLRYt_textRRRSRTRRiR~RRR( RPRLRYRRRTRRRSRR((RntDateFromString;s !cCsdt|}d|jo|idnyt||Wn"titfj o }dSnXdS(s validateDateTimeString(text, [formats, defaultdate]) Validates the given text and returns 1/0 depending on whether text includes parseable date and time values or not. formats works just like for DateTimeFromString() and defines the order of date/time parsers to apply. It defaults to the same list of parsers as for DateTimeFromString(). XXX Undocumented ! REiiN( tlistRLtremoveRRPRRRiR(RPRLR((RntvalidateDateTimeStringVs    cCsdt|}d|jo|idnyt||Wn"titfj o }dSnXdS(s validateDateString(text, [formats, defaultdate]) Validates the given text and returns 1/0 depending on whether text includes a parseable date value or not. formats works just like for DateTimeFromString() and defines the order of date/time parsers to apply. It defaults to the same list of parsers as for DateTimeFromString(). XXX Undocumented ! REiiN( RRLRRRPRRRiR(RPRLR((RntvalidateDateStringms    c Csti|} | dj o| i\}}}}}nt i|} | dj o"| i\}}}}d}nt i|} | dj o%| i\}}}d}d}nIt i|} | dj o| i\}}}}}n|idS|o||}nd}|o||}nd}|o||}nd}|o||}nd}|djo d}nd}y|i||||}Wn.|ij o} |id|| fnX|djo | Sn|SdS(s DateTimeDeltaFromString(text) Returns a DateTimeDelta instance reflecting the delta given in text. Defaults to 0:00:00:00.00 for parts that are not included in the textual representation or cannot be parsed. f0.0R:iisFailed to parse "%s": %siN(t _isodelta1RERORPRJRIRQtsigntdaysthourstminutestsecondst _isodelta2REt _isodelta3REt _litdeltaRERt DateTimeDeltatfloattdtdRR( RPRRRRRRRRRRJ((RntDateTimeDeltaFromStringsN            c Csti|} | dj o| i}doto |GHn|\}}}}} }|o||}n|o||}nd}|o||}n|o||}nd}| o|| } n|o||}nd}||||| |fSndSdS(Ni(NiNiNi(t _relisodateRERORPRJRIRQRgRTtyearsRStmonthsRRRRXRm( RPRXRmRRRRQRTRSRRRJ((Rnt_parse_reldates.   c Csti|} | dj o| i}doto |GHn|\}}} }}}|o||}n|o||}nd}| o|| } n|o||}nd}|o||}n|o||}nd}||| |||fSndSdS(Ni(NiNiNi(t _relisotimeRERORPRJRIRQRgRtRRuRRvRRXRm( RPRXRmRQRRRtRRvRuRJ((Rnt_parse_reltimes.   cCst|\} }} }} }t|\}}} } }}|d| d|d| d|d| d|d|d|d | d | d |d | S(s RelativeDateTimeFromString(text) Returns a RelativeDateTime instance reflecting the relative date and time given in text. Defaults to wildcards for parts or values which are not included in the textual representation or cannot be parsed. The format used in text must adhere to the following syntax: [YYYY-MM-DD] [HH:MM[:SS]] with the usual meanings. Values which should not be altered may be replaced with '*', '%', '?' or any combination of letters, e.g. 'YYYY'. Relative settings must be enclosed in parenthesis if given and should include a sign, e.g. '(+0001)' for the year part. All other settings are interpreted as absolute values. Date and time parts are both optional as a whole. Seconds in the time part are optional too. Everything else (including the hyphens and colons) is mandatory. RTRRSRRRRRtRRuRRvRN(RRPRTRRSRRRRRRtRRuRRvRtRelativeDateTime(RPRRtRRRRRRvRTRSRRRRu((RntRelativeDateTimeFromStrings    c CsIt|\}}}}}}|d|d|d|d|d|d|S(s RelativeDateFromString(text) Same as RelativeDateTimeFromString(text) except that only the date part of text is taken into account. RTRRSRRRRN( RRPRTRRSRRRRR(RPRRRRRTRSRR((RntRelativeDateFromString5s  c CsIt|\}}}}}}|d|d|d|d|d|d|S(s RelativeTimeFromString(text) Same as RelativeDateTimeFromString(text) except that only the time part of text is taken into account. RtRRuRRvRN( RRPRtRRuRRvRR(RPRRtRRRvRRu((RntRelativeTimeFromStringDs  c PCsndk}ti}dGHddfddfddfddfddfddfd d fd d fd d |ifdd|ifddfddfdd|ifdd|ifdd|ifdd|ifdd|ifdd|ifddfddfddfddfd dfd!dfd"dfd#d$fd$d$fd%d&fd'd$fd(d&fd)d*fd+d,fd-d.fd/d0fd1d0fd2d3fd4d0fd1d0fd0d0fd5d6|ifd7d8fd9dfd:d;fd<d;fd=d|ifd>d|ifd?d|ifd@d|ifdAdfdBdfdCdfdDdfdEdfdFdfdGdfdHdfdIdfdJdfdKdL|ifdMdN|ifdOdP|ifdQdR|ifdSdR|ifdTdU|ifdVdR|ifdWdU|ifdXdY|ifdZd[fd\d[fd]d[fd^d[fd_d[fd`d[fdad[fdbd[fdcd[fddd[fded[fdfd[fgO}x|D]\}}yt |}Wn1|t joqnt |i dg}nXt|}t|}t ||jo |d[j o&dh|GHdi|pdjGHdk|GHnto dl|GHnto.| o dm|GHn| o dn|GHnnqWti}do||iGHdpGHti}ddqfdrdsfdtdufdvdqfdwdxfdydzfd{d|fd}d~fddfd"dqfddufddqfddfddfddfddfddfddfddfddfddfddufddfddfddfg}x|D]\}}yt|}Wn1|t joqnt |i dg}nXt ||jo |d[j o&dh|GHdi|pdjGHdk|GHnto dl|GHnqWti}do||iGHdS(NsTesting DateTime Parser...sSun Nov 6 08:49:37 1994s1994-11-06 08:49:37.00ssun nov 6 08:49:37 1994ssUN NOV 6 08:49:37 1994sSunday, 06-Nov-94 08:49:37 GMTsSun, 06 Nov 1994 08:49:37 GMTs06-Nov-94 08:49:37s 06-Nov-94s1994-11-06 00:00:00.00s 06-NOV-94sNovember 19 08:49:37s%s-11-19 08:49:37.00sNov. 9s%s-11-09 00:00:00.00s+Sonntag, der 6. November 1994, 08:49:37 GMTs6. November 2001, 08:49:37s2001-11-06 08:49:37.00ssep 6s%s-09-06 00:00:00.00s September 29s%s-09-29 00:00:00.00sSep. 29s6 seps 29 Septembers29 Sep.s sep 6 2001s2001-09-06 00:00:00.00s Sep 6, 2001sSeptember 6, 2001ssep 6 01s Sep 6, 01sSeptember 6, 01s1994-11-06 08:49:37t010203s2001-02-03 00:00:00.00s2001-02 00:00:00.00s2001-02-01 00:00:00.00s 2001-02-03s2001-02s 20000824/2300s2000-08-24 23:00:00.00s 20000824/0102s2000-08-24 01:02:00.00t20000824s2000-08-24 00:00:00.00s20000824/020301s2000-08-24 02:03:01.00s20000824 020301s-20000824 020301s-2000-08-24 02:03:01.00t20000824T020301tT020311s%s 02:03:11.00s06/11/94 08:49:37s1994-06-11 08:49:37.00s11/06/94 08:49:37s 9/23/2001s2001-09-23 00:00:00.00s 9-23-2001s9/6s09/6s9/06s09/06s9/6/2001s 09/6/2001s 9/06/2001s 09/06/2001s9-6-2001s 09-6-2001s 9-06-2001s 09-06-2001s6.11.2001, 08:49:37s06.11.2001, 08:49:37s06.11. 08:49:37s%s-11-06 08:49:37.00s01:03s%s 01:03:00.00s01:03:11s%s 01:03:11.00s 01:03:11.50s%s 01:03:11.50s01:03:11.50 AMs01:03:11.50 PMs%s 13:03:11.50s01:03:11.50 a.m.s01:03:11.50 p.m.s6..2001, 08:49:37s%s 08:49:37.00s9//2001tignores06--94 08:49:37t20000824020301s20-03 00:00:00.00s9/2001s9-6s09-6s9-06s09-06s 20000824/23sNovember 1994 08:49:37sNov. 94isFailed to parse "%s"s expected: %ss s parsed: %ssParsed "%s" successfullys" "%s" failed date/time validations "%s" failed date validationsdone. (after %f seconds)sTesting DateTimeDelta Parser...s 08:49:37.00s&1 day, 8 hours, 49 minutes, 37 secondss 1:08:49:37.00s(10 days, 8 hours, 49 minutes, 37 secondss10:08:49:37.00s8 hours, 49 minutes, 37 secondss49 minutes, 37 secondss 00:49:37.00s 37 secondss 00:00:37.00s 37.5 secondss 00:00:37.50s 8 hours laters 08:00:00.00RFs 00:00:00.00s 10:08:49:37s08:49:37s08:49s 08:49:00.00s -10:08:49:37s-10:08:49:37.00s -08:49:37s -08:49:37.00s-08:49s -08:49:00.00s - 10:08:49:37s - 08:49:37s- 08:49s 10:08:49:37.5s10:08:49:37.50s 08:49:37.5s 08:49:37.50s 10:8:49:37s8:9:37s 08:09:37.00s8:9s 08:09:00.00t8(tsysRRZttRTtdatetlRPt referenceRtvalueRItstrtexc_infoRtvalid_datetimeRt valid_dateRgtetRR( RRRPRRRRRR((Rnt_testUsb  j_    !      %  !   t__main__(ht__doc__ttypestretstringRtISOtARPAR{Rgt_yeart _fullyeart _year_epocht_fullyear_epocht_relyeart_montht _fullmontht _litmonthRkt _relmontht_dayt_usdayt_fulldayt_litdayt litdaytablet_reldayt_hourt_minutet_secondt_dayst_hourst_minutest_secondst_reldayst _relhourst _relminutest _relsecondst_signt_weekRxt_zonet_ampmt_timet_isotimet _weekdatet _eurodatet_usdatet _altusdatet_isodatet _altisodatet_litdatet _altlitdatet _eurlitdatet_relanyt _relisodatet_asctimet _relisotimet _isodelta1t _isodelta2t _isodelta3t _litdeltatcompiletIRsRyR]R^RNR[R\RbReRfRt _asctimeRERRRRRRRIRXRmRjRWRZRoR}RRRRRRtTimeFromStringtTimeDeltaFromStringRRRRRRRt__name__([RRRRRRRgRRRkRRRRRRfRRRRRRsRRRRRRRRbRRRRRRRRRRNRRRRR]RRR{RRRRRRRRRRRRoRR}RRR\RRRRReRRRRRRRRRRyR^RRRRRRR[RRR((RnR8s$  *"2&*V6V&:!-Y[  D%