
    ]hp
                     n    d Z ddlZddlmZ ddlmZmZmZ dZ ej                  e      Z
d	dZd Zd
dZy)z
This module provides an ISO 8601:2004 time zone info parser.

It offers a function to parse the time zone offset as specified by ISO 8601.
    N)ISO8601Error)UTCZEROFixedOffsetzM(?P<tzname>(Z|(?P<tzsign>[+-])(?P<tzhour>[0-9]{2})(:?(?P<tzmin>[0-9]{2}))?)?)c                 h    | | dk(  ry| dk(  rt         S |dk(  xr dxs d}t        ||z  ||z  |       S )z
    create a tzinfo instance according to given parameters.

    tzname:
      'Z'       ... return UTC
      '' | None ... return None
      other     ... return FixedOffset
    N Z-   )r   r   )tznametzsigntzhourtzmins       W/var/www/core.comfia.cic-ware.com/crm/lib/python3.12/site-packages/isodate/isotzinfo.pybuild_tzinfor      sH     ~2}
}$"*Fv??    c           	          t         j                  |       }|rD|j                         }t        |d   |d   t	        |d   xs d      t	        |d   xs d            S t        d| z        )a)  
    Parses ISO 8601 time zone designators to tzinfo objects.

    A time zone designator 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
    r   r   r   r   r   z%s not a valid time zone info)TZ_REmatch	groupdictr   intr   )tzstringr   groupss      r   parse_tzinfor   $   st     KK!E"88x %A&w$1%	
 	
 6A
BBr   c                    | j                   }||j                  |       y|j                  |       t        k(  r|j                  |       t        k(  ry|j                  |       }|j                  dz  dz  dz  |j
                  z   }|dk  xr dxs d}t        |      }t        |d      \  }}t        |d      \  }}|dkD  rt        d	      |d
k(  rd|||fz  S |dk(  rd|||fz  S |dk(  rd||fz  S t        d|z        )a?  
    return time zone offset ISO 8601 formatted.
    The various ISO formats can be chosen with the format parameter.

    if tzinfo is None returns ''
    if tzinfo is UTC returns 'Z'
    else the offset is rendered to the given format.
    format:
        %h ... +-HH
        %z ... +-HHMM
        %Z ... +-HH:MM
    r   r	      <   r   r
   +c   z%can not handle differences > 99 hours%Zz%s%02d:%02dz%zz
%s%02d%02dz%hz%s%02dzunknown format string "%s")
tzinfo	utcoffsetr   dstdayssecondsabsdivmodOverflowError
ValueError)dtformatr"   tdeltar&   signminuteshourss           r   tz_isoformatr1   ;   s$    YYFF,,R08t#

2$(>b!FkkB#b(6>>9Gq[!c)cD'lGgr*GWGR(NE7rzCDD~eW555	4tUG444	44-''
1F:
;;r   )r   r   r   )r!   )__doc__reisodate.isoerrorr   isodate.tzinfor   r   r   TZ_REGEXcompiler   r   r   r1    r   r   <module>r9      sF    
 ) 1 1 Y 	 	

8@"C. <r   