o
    Ϊ-g                     @   s   d dl Z d dlZd dlZd dlZd dlZd dlZzd dlZW n ey-   d dlmZ Y nw d dl	m
Z
 edZdd Zddd	Zdd
dZdddZdS )    N)zoneinfo)
windows_tztzlocalc                 C   s   t tj|   S )zCGet timezone's offset using built-in function datetime.utcoffset().)intdatetimenow	utcoffsettotal_seconds)tz r   N/var/www/html/django-vendor/venv/lib/python3.10/site-packages/tzlocal/utils.pyget_tz_offset   s   r   Tc                 C   sd   t | }tt tt  }t|| dkr0d| d| d}|r)t|t	| dS dS )aJ  Assert that system's timezone offset equals to the timezone offset found.

    If they don't match, we probably have a misconfiguration, for example, an
    incorrect timezone set in /etc/timezone file in systemd distributions.

    If error is True, this method will raise a ValueError, otherwise it will
    emit a warning.
    <   z.Timezone offset does not match system offset: z != z". Please, check your config files.N)
r   calendartimegmtime	localtimegmtimeabs
ValueErrorwarningswarn)r
   error	tz_offsetsystem_offsetmsgr   r   r   assert_tz_offset   s   
r   c                 C   s   | d u r
t jd} | sd S td|   | d dkr"| dd  } | tjv r)| S t j| rZt j	| rZt j
| t j}d|dd  }|tjv rO|S |d tjv rZ|d S td	 d S )
NTZzFound a TZ environment: r   :   /z$TZ does not contain a time zone name)osenvirongetlogdebugr   tz_winpathisabsexistsrealpathsplitsepjoin)tzenvpartspossible_tzr   r   r   _tz_name_from_env.   s$   


r3   c                 C   s   | d u r
t jd} | sd S | d dkr| dd  } t j| rQt j| rQt| }|s4| t jd }t	| d}t
jj||dW  d    S 1 sLw   Y  zt
| }|W S  t
jyk   t
d|  d	d w )
Nr   r   r   r   r"   rb)keyz7tzlocal() does not support non-zoneinfo timezones like z6. 
Please use a timezone in the form of Continent/City)r#   r$   r%   r)   r*   r+   r3   r-   r.   openr   ZoneInfo	from_fileZoneInfoNotFoundError)r0   tznametzfiler
   r   r   r   _tz_from_envQ   s.    

r<   )T)N)r   r   loggingr#   r   r   r   ImportError	backportsr   r   	getLoggerr&   r   r   r3   r<   r   r   r   r   <module>   s"    


#