U
    Jµ^œ  ã                   @   s4   d dl Z d dlZd dlZdd„ Zdd„ Zdd„ ZdS )é    Nc                  C   sJ   t  t ¡ ¡} t  t ¡ ¡}||  }t|tj ƒdk r>tj S tj S dS )a~  Get system's timezone offset using built-in library time.

    For the Timezone constants (altzone, daylight, timezone, and tzname), the
    value is determined by the timezone rules in effect at module load time or
    the last time tzset() is called and may be incorrect for times in the past.

    To keep compatibility with Windows, we're always importing time module here.
    é<   N)ÚcalendarÚtimegmÚtimeÚ	localtimeÚgmtimeÚabsÚaltzoneÚtimezone)r   r   Úoffset© r   úl/mounts/lovelace/software/anaconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/tzlocal/utils.pyÚget_system_offset   s    
r   c                 C   s   t tj | ¡ ¡  ¡ ƒS )zCGet timezone's offset using built-in function datetime.utcoffset().)ÚintÚdatetimeÚnowÚ	utcoffsetÚtotal_seconds)Útzr   r   r   Úget_tz_offset   s    r   c                 C   s.   t | ƒ}tƒ }||kr*d ||¡}t|ƒ‚dS )zã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.zZTimezone offset does not match system offset: {0} != {1}. Please, check your config files.N)r   r   ÚformatÚ
ValueError)r   Z	tz_offsetZsystem_offsetÚmsgr   r   r   Úassert_tz_offset"   s     þr   )r   r   r   r   r   r   r   r   r   r   Ú<module>   s
   