o
    vh                     @   sx   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZ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)
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
   K/var/www/html/hyperkenya/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$   


r2   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*   r2   r,   r-   openzoneinfoZoneInfo	from_fileZoneInfoNotFoundError)r/   tznametzfiler	   r
   r
   r   _tz_from_envM   s.    

r<   )T)N)r   r   loggingr"   r   r   r6   r   r   	getLoggerr%   r   r   r2   r<   r
   r
   r
   r   <module>   s    


#