-í
wH<c       sï    d  Z  ! " d k l Z # d k Z ( d Z ) d Z * d Z - e d e d e d Z . e d e d e d Z / e d e d e d Z	 0 e i
 e e i ƒ Z 1 e i
 e e i ƒ Z 2 e i
 e	 e i ƒ Z 3 h  e d	 <e d
 <e d <Z 5 d Z 6 d Z 7 d Z 8 e d e d e d Z 9 e i
 e e i ƒ Z < d e e i ƒ  i d ƒ d Z > d „  Z K d d „ Z ˆ d „  Z   d d „ Z ² d d „ Z Ä d d „ Z ö e d j o ÷ e ƒ  n d S(   sP  
The functions in this module are useful for data entry or bulk data
import, where dates are in an all-numeric format.  Because of the
possibility that the user might type the wrong thing in a numeric
field, or a data file might contain other data or garbage where a date
is expected, it is desirable to return None or raise an exception
when an invalid expression is encountered.

Dates can be in any of these formats: ymd, dmy, or mdy
with any single-character nondigit separator, two- or four-digit
year, and one- or two-digit month and day; or they can be in all-digits
ymd format with no separator, four-digit year, and two-digit
month and day (e.g. 20010803). 

In accordance with ISO 8601, two-digit years in all-numeric dates
are interpreted as referring to the current century.

Synopsis:
    DateTime = numericDateTime(datetimestring, formats='ymd mdy dmy'))
        Return value is based on date and (if any) time data in the string.
    DateTime = numericDate(datestring, formats='ymd mdy dmy'))
        Return value is based on date data in the string.
    DateTimeDelta = numericTime(timestring)
        Return value is based on time data in the string.

20010804 JJD Created, borrowing some regular expressions and
         ideas from mxDateTime's Parser module.

COPYRIGHT:
Placed into the Public Domain by J.J. Dukarm (jdukarm@hydracen.com).

(   s   DateTimeNs$   (?P<year>(?<![\d:])\d{2,4}(?![\d:]))s%   (?P<month>(?<![\d:])\d{1,2}(?![\d:]))s#   (?P<day>(?<![\d:])\d{1,2}(?![\d:]))s   (?P<sep>\D)s   (?P=sep)s   (?!\d)s   ymds   dmys   mdys   (?P<hour>[012]?\d)s   (?P<minute>[0-6]\d)s   (?P<second>[0-6]\d(?:\.\d+)?)s   :s   (?::s   )?iè  i    c    sL   > D E d |  j o
 d j  n o F |  t } n
 H |  } I | Sd S(   sÏ   
    According to ISO 8601, a two-digit year in an all-numeric date
    expression refers to the current century.
    If year has exactly two digits, add the century. Otherwise, return
    it unchanged.
    i    id   N(   s   years   _THIS_CENTURYs   result(   s   years   result(    (    sF   /mit/seven/lib/python2.2/site-packages/mx/DateTime/Examples/numdate.pys   _iso_add_century> s
   !	s   ymd mdy dmyc    sé  K \ ] |  t j o ] t Sn ^ t } _ | i ƒ  }
 ` t |
 ƒ d j } a t |  ƒ i	 ƒ  } b t | ƒ } c | d d f j o
 |  i ƒ  oÚ e | d } | d } | d } f t t | d | !ƒ ƒ } g t | | | !ƒ } h t | | | !ƒ } i y j t i | | | ƒ } WnK k t i j
 o9 } l t } m | o n t i d | | f ‚ n n Xnpq x>|
 Dq ]3} r t | i ƒ  }	 s |	 i | ƒ } t | t j o
 u qyn v | i d ƒ } w | i d	 ƒ } x | i d
 ƒ } y t t | ƒ ƒ } z t | ƒ } { t | ƒ } | y } t i | | | ƒ } WnK ~ t i j
 o9 }  t } € | o  t i d | | f ‚ n n X‚ | t j	 o ƒ Pn qyW„ | t j o | o … t" d | ‚ n † | Sd S(   sØ  
    If the input string s is a valid numeric date 
    expression according to one of the formats given, return
    a DateTime object with default time components.
    Date formats, separated by a single space character, are
    packed into a string.

    If only one date format is given, raise a ValueError if
    the string cannot be interpreted, and raise a DateTime
    RangeError if it can be interpreted but is not a valid date.

    If more than one date format is given, try each of them in order
    until a valid interpretation is found.  If the string does
    not represent a valid date, return None.  You can use one
    format twice (e.g. ['ymd', 'ymd']) to test only one format but
    suppress exceptions.
    i   i   i   i   i   i    s   '%s' invalid: %ss   years   months   days   unrecognized date format: '%s'N(#   s   ss   Nones   dts   formatss   splits
   formatlists   lens   exceptions_oks   strs   strips   _ss   len_ss   isdigits   k0s   k1s   k2s   _iso_add_centurys   ints   yys   mms   dds   DateTimes
   RangeErrors   whys   formats   _formatdicts   lowers	   format_res   searchs   matchs   groups   years   months   days
   ValueError(   s   ss   formatss   formats   months   dds   yys   years   dts   whys	   format_res
   formatlists   mms   _ss   days   k2s   k1s   k0s   len_ss   exceptions_oks   match(    (    sF   /mit/seven/lib/python2.2/site-packages/mx/DateTime/Examples/numdate.pys   numericDateK sT    	#!	
&
 	
	
"c 	   s  ˆ  Ž |  t j o Ž t Sn  t }  t i |  ƒ } ‘ | t j	 oÂ ’ | i d ƒ } “ | i d ƒ } ” | i d ƒ } • t
 | ƒ } t
 | ƒ } – | o — t | ƒ } n
 ™ d } š y › t i d | | | ƒ } Wn" œ t i j
 o  t } n Xn ž | Sd S(   s¶   
    If the input string s is a valid time expression of the
    form hh:mm:ss.sss or hh:mm:ss or hh:mm, return
    a corresponding DateTimeDelta object. Otherwise, return None.
    s   hours   minutes   secondf0.0i    N(   s   ss   Nones   dts   _timeREs   searchs   matchs   groups   hours   minutes   seconds   ints   hhs   mms   floats   sss   DateTimes   DateTimeDeltas
   RangeError(	   s   ss   mms   sss   hours   hhs   matchs   dts   minutes   second(    (    sF   /mit/seven/lib/python2.2/site-packages/mx/DateTime/Examples/numdate.pys   numericTimeˆ s$    	
	c    sÊ     ¥ |  t j o ¥ t Sn § t |  ƒ i ƒ  i d d ƒ } ¨ | i ƒ  } © t | d | ƒ } ª | t j	 o t | ƒ d j o8 « t | d ƒ } ¬ | t j	 o ­ | | } n n ® | Sd  S(   Ns   Ts    i    i   (   s   ss   Nones   strs   strips   replaces   _ss   splits	   date_times   numericDates   formatss   ds   lens   numericTimes   t(   s   ss   formatss	   date_times   ds   _ss   t(    (    sF   /mit/seven/lib/python2.2/site-packages/mx/DateTime/Examples/numdate.pys   numericDateTime  s    !#c    s6  ² ³ t  } ´ | o‹ µ yL ¶ t |  d ƒ } · | |  d j o! ¸ d |  d t | ƒ f } n Wn5 ¹ t j
 o& } º d |  d t	 | ƒ f } n Xn‹ ¼ yO ½ t
 |  d | ƒ } ¾ | |  d j o! ¿ d |  d t | ƒ f } n Wn5 À t j
 o& } Á d |  d t	 | ƒ f } n XÂ | Sd  S(   Ni    i   s   >>> '%s' --> %ss   >>> '%s' -- %s(   s   Nones   results   timeonlys   numericTimes   testcases   dtd0s   reprs	   Exceptions   es   strs   numericDateTimes   formatss   dt0(   s   testcases   formatss   timeonlys   dtd0s   es   results   dt0(    (    sF   /mit/seven/lib/python2.2/site-packages/mx/DateTime/Examples/numdate.pys   _test_it² s   	
%&%"c 	   sÂ  Ä Å d k  l } Æ d t i d d d d ƒ f d t i d d d d ƒ f d	 t i d d d d ƒ f d
 t f d t i d d d ƒ f d t i d d d ƒ f d t i d d d d d d ƒ f d t i d d d d d d ƒ f d t i d d d ƒ f d t i d d d ƒ f d t i d d d ƒ f d t i d d d d d d ƒ f d t i d d d d d d ƒ f d t i d d d ƒ f d t i d d d ƒ f d t i d d d d d d ƒ f d t i d d d d d d ƒ f d t i d d d ƒ f d t i d d d ƒ f d t i d d d d d d ƒ f d t i d d d ƒ f d  t i d d d ƒ f d! t i d d d d d d ƒ f g } ä d" d# i |  i ƒ  ƒ GHå | ƒ  } æ d } ç xà t d$ ƒ Dç ]Ï } è x` | d d !Dè ]N } é t | |  d% d& ƒ} ê | d& } ë | o
 | d j o ì | GHn qàWî x] | d Dî ]N } ï t | |  d% d ƒ} ð | d& } ñ | o
 | d j o ò | GHn qCWqÆWó | ƒ  } ô d' | | | f GHd  S((   N(   s   clocks   12:13:14.56i    i   i   f14.56s   12:13:14i   s   12:13s   Ceci n'est pas une dates   010803iÑ  i   i   s   20010803s   20010803 12:13:14.56s   20010803T12:13:14.56s   01-08-03s
   2001-08-03s   2001-8-3s   2001-08-03 12:13:14.56s   2001-08-03T12:13:14.56s
   08/03/2001s   8/3/2001s   08/03/2001 12:13:14.56s   08/03/2001T12:13:14.56s
   08/23/2001i   s	   8/23/2001s   08/23/2001 12:13:14.56s
   23.08.2001s	   23.8.2001s   23.08.2001 12:13:14.56s%   
Testing numdate.py with format(s) %ss   , id   s   timeonlyi   s$   Done - %d cases tested in %1.5f sec.(   s   times   clocks   DateTimes   DateTimeDeltas   Nones	   testcasess   joins   formatss   splits   t0s   casess   ranges   is   testcases   _test_its   results   t1(	   s   formatss   clocks   is   t0s   testcases	   testcasess   results   casess   t1(    (    sF   /mit/seven/lib/python2.2/site-packages/mx/DateTime/Examples/numdate.pys   testÄ s.   ÿ ÿ u	 	 	 	s   __main__(    s   __doc__s   mxs   DateTimes   res   _years   _months   _days   _ymds   _dmys   _mdys   compiles   Is   _ymdREs   _dmyREs   _mdyREs   _formatdicts   _hours   _minutes   _seconds   _times   _timeREs   divmods   nows   years   _THIS_CENTURYs   _iso_add_centurys   numericDates   numericTimes   numericDateTimes   _test_its   tests   __name__(   s   _test_its   numericDateTimes   _formatdicts   _months   numericTimes   _iso_add_centurys   _THIS_CENTURYs   _years   _hours   _ymds   DateTimes   _seconds   _mdys   _days   _times   _timeREs   _minutes   numericDates   _dmys   res   _mdyREs   _ymdREs   tests   _dmyRE(    (    sF   /mit/seven/lib/python2.2/site-packages/mx/DateTime/Examples/numdate.pys   ?! s4   			$			#=2