B #a@s|dZddlZddlmZddlmZddlmZmZm Z ddl m Z ddl m Z mZgZdd Zd d Zee fd d ZdS)z This modules provides a method to parse an ISO 8601:2004 time string to a Python datetime.time instance. It supports all basic and extended formats including time zone specifications as described in the ISO standard. N)Decimal)time)strftimeTIME_EXT_COMPLETETZ_EXT) ISO8601Error)TZ_REGEX build_tzinfocCsltshttdtttdtttdtttdtttdttS)z Build regular expressions to parse ISO time string. The regular expressions are compiled and stored in TIME_REGEX_CACHE for later reuse. zKT?(?P[0-9]{2}):(?P[0-9]{2}):(?P[0-9]{2}([,.][0-9]+)?)zIT?(?P[0-9]{2})(?P[0-9]{2})(?P[0-9]{2}([,.][0-9]+)?)z6T?(?P[0-9]{2}):(?P[0-9]{2}([,.][0-9]+)?)z5T?(?P[0-9]{2})(?P[0-9]{2}([,.][0-9]+)?)z!T?(?P[0-9]{2}([,.][0-9]+)?))TIME_REGEX_CACHEappendrecompilerrr6/tmp/pip-target-jgxl_w8r/lib/python/isodate/isotime.pybuild_time_regexps.s          rc Cst}x|D]}||}|r|}x,|D] \}}|dk r4|dd||<q4Wt|d|dt|dprdt|dpd}d |krt|d td }|t|td } t t|d t|d t|t| |Sd |krFt|d } | t| d}|t|td } t t|d t| t|t| |Sd\} }} t|d } | t| d} | t| d}|t|td } t t| t| t|t| |SqWt d|dS)a Parses ISO 8601 times into datetime.time objects. Following ISO 8601 formats are supported: (as decimal separator a ',' or a '.' is allowed) hhmmss.ssTZD basic complete time hh:mm:ss.ssTZD extended compelte time hhmm.mmTZD basic reduced accuracy time hh:mm.mmTZD extended reduced accuracy time hh.hhTZD basic reduced accuracy time TZD is the time zone designator which can be in the following format: no designator indicates local time zone Z UTC +-hhmm basic hours and minutes +-hh:mm extended hours and minutes +-hh hours N,.tznametzsignZtzhourrZtzminsecondz.000001g.Ahourminute<)rrrz%Unrecognised ISO 8601 time format: %r) rmatch groupdictitemsreplacer intrquantizer to_integralr) Z timestringZisotimespatternrgroupskeyvaluetzinfor microsecondrrrrr parse_time`s>     r&cCs t||S)z Format time strings. This method is just a wrapper around isodate.isostrf.strftime and uses Time-Extended-Complete with extended time zone as default format. )r)Zttimeformatrrrtime_isoformatsr()__doc__r decimalrdatetimerZisodate.isostrfrrrZisodate.isoerrorrZisodate.isotzinforr r rr&r(rrrr!s   27