a
    xd                     @   s*   d dl Z d dlmZ dd ZdddZdS )    N)datetimec                 C   s0   g }| D ]"}t |}|||ddf q|S )z
    Given a list of timezones (either strings of timezone objects),
    return a list of choices with
        * values equal to what was passed in
        * display strings as the timezone name without underscores
    _ )strappendreplace)	timezoneschoicestztz_str r   N/var/www/html/Ranjet/env/lib/python3.9/site-packages/timezone_field/choices.pystandard   s
    r   c           	      C   s   |pt tj}g }| D ]|}t|}|t|}|jtjd| }dj|t	|krZdndtt	|
ddd |dd	d
}||||f q|jdd d dd |D }|S )aC  
    Given a list of timezones (either strings of timezone objects),
    return a list of choices with
        * values equal to what was passed in
        * display strings formated with GMT offsets and without
          underscores. For example: "GMT-05:00 America/New York"
        * sorted by their timezone offset
    )tzinfozGMT{sign}{gmt_diff} {timezone}+-   Nr   r   )signZgmt_difftimezonec                 S   s   | d S )Nr   r   )xr   r   r   <lambda>(       z!with_gmt_offset.<locals>.<lambda>)keyc                 S   s   g | ]\}}}||fqS r   r   ).0ZzeroZoneZtwor   r   r   
<listcomp>)   r   z#with_gmt_offset.<locals>.<listcomp>)r   nowpytzutcr   
astimezoner   r   formatabszfillr   sort)	r   r   Z_choicesr
   r   Znow_tzdeltaZdisplayr	   r   r   r   with_gmt_offset   s    	
r%   )N)r   r   r   r%   r   r   r   r   <module>   s   