
    ThV                        d Z ddlmZmZmZ ddlmZmZ ddlmZm	Z	 ddlm
Z
 	 ddlmZmZ g dZ ed      ZefZd Zd Zd Zedk(  rddlZ ej:                          yy# e$ r ddlZddlZej"                  j%                  ej&                  d         d	k(  s+ej"                  j%                  ej&                  d         d
k(  r" edej(                         d ed      fiZdZn Y w xY w)a  Phone number to time zone mapping functionality

>>> import phonenumbers
>>> from phonenumbers.timezone import time_zones_for_number
>>> ro_number = phonenumbers.parse("+40721234567", "RO")
>>> tzlist = time_zones_for_number(ro_number)
>>> len(tzlist)
1
>>> str(tzlist[0])
'Europe/Bucharest'
>>> dual_number = phonenumbers.parse("+976136234567", "US")
>>> tzlist = time_zones_for_number(dual_number)
>>> len(tzlist)
2
>>> str(tzlist[0])
'Asia/Choibalsan'
>>> str(tzlist[1])
'Asia/Ulaanbaatar'

   )prntuU_PLUS)PhoneNumberTypenumber_type)PhoneNumberFormatformat_number)is_number_type_geographical)TIMEZONE_DATATIMEZONE_LONGEST_PREFIX    Nzbuildmetadatafromxml.pyzbuildprefixdata.pyzAFailed to import generated data (but OK as during autogeneration))file4411zEurope/London   )UNKNOWN_TIMEZONE"time_zones_for_geographical_numbertime_zones_for_numberzEtc/Unknownc                     t        | t        j                        }|j                  t              st        d      t        t        dd      D ]  }|dd|z    }|t        v st        |   c S  t        S )aN  Returns a list of time zones to which a phone number belongs.

    This method assumes the validity of the number passed in has already been
    checked, and that the number is geo-localizable. We consider fixed-line
    and mobile numbers possible candidates for geo-localization.

    Arguments:
    numobj -- a valid phone number for which we want to get the time zones
                  to which it belongs
    Returns a list of the corresponding time zones or a single element list
    with the default unknown time zone if no other time zone was found or if
    the number was invalidz"Expect E164 number to start with +r   r   )
r	   r   E164
startswithr   	Exceptionranger   r   _UNKNOWN_TIME_ZONE_LIST)numobje164_num
prefix_lenprefixs       U/opt/server/standalone/crm/venv/lib/python3.12/site-packages/phonenumbers/timezone.pyr   r   @   sw     V%6%;%;<Hv& <==3Q; )
!Q^-]" (() #"    c                     t        |       }|t        j                  k(  rt        S t	        || j
                        st        |       S t        |       S )a  As time_zones_for_geographical_number() but explicitly checks the
    validity of the number passed in.

    Arguments:
    numobj -- a valid phone number for which we want to get the time zones to which it belongs
    Returns a list of the corresponding time zones or a single element list with the default
    unknown time zone if no other time zone was found or if the number was invalid)r   r   UNKNOWNr   r
   country_code$_country_level_time_zones_for_numberr   )r   ntypes     r   r   r   Y   sH     E'''&&(0C0CD3F;;-f55r    c                     t        | j                        }t        t        dd      D ]  }|dd|z    }|t        v st        |   c S  t
        S )a>  Returns the list of time zones corresponding to the country calling code of a number.
    Arguments:
    numobj -- the phone number to look up
    Returns a list of the corresponding time zones or a single element list with the default
    unknown time zone if no other time zone was found or if the number was invalidr   r   Nr   )strr#   r   r   r   r   )r   ccr   r   s       r   r$   r$   i   sY     
V  	!B3Q; )
%a*n&]" (() #"r    __main__)__doc__utilr   r   r   phonenumberutilr   r   r   r	   r
   tzdatar   r   ImportErrorossyspathbasenameargvstderr__all__r   r   r   r   r$   __name__doctesttestmod r    r   <module>r:      s   H " ! 9 = 8> ^ ]# +- #26 # zGOO Y   
!%)BB
!%)==PWZWaWab!O"4!67"# 	 s   A   BC)(C)