a
    ¥Q•hº  ã                   @   sœ   d Z ddlZddlZddlmZmZ ddlZe d¡Zg d¢Zg d¢Z	ddd„Z
d	d
„ Zdd„ Zdd„ Zdd„ Zedkr˜ddlZddlZe e ¡ j¡ dS )zKfontTools.misc.timeTools.py -- tools for working with OpenType timestamps.
é    N)ÚdatetimeÚtimezone)	ip  é   r   r   r   r   r   r   r   )ÚMonÚTueÚWedÚThuÚFriÚSatÚSun)NÚJanÚFebÚMarÚAprÚMayÚJunÚJulÚAugÚSepÚOctÚNovÚDecc                 C   s:   | du rt  ¡ } dt| j t| j | jt  d| ¡f }|S )aˆ  
    Convert a tuple or struct_time representing a time as returned by gmtime()
    or localtime() to a 24-character string of the following form:

    >>> asctime(time.gmtime(0))
    'Thu Jan  1 00:00:00 1970'

    If t is not provided, the current time as returned by localtime() is used.
    Locale information is not used by asctime().

    This is meant to normalise the output of the built-in time.asctime() across
    different platforms and Python versions.
    In Python 3.x, the day of the month is right-justified, whereas on Windows
    Python 2.7 it is padded with zeros.

    See https://github.com/fonttools/fonttools/issues/455
    Nz%s %s %2s %sz%H:%M:%S %Y)ÚtimeÚ	localtimeÚDAYNAMESÚtm_wdayÚ
MONTHNAMESÚtm_monÚtm_mdayÚstrftime)ÚtÚs© r"   úQ/var/www/sistema_ama/venv/lib/python3.9/site-packages/fontTools/misc/timeTools.pyÚasctime   s    
ür$   c                 C   s   t t td| t ƒ¡ƒS )Nr   )r$   r   ÚgmtimeÚmaxÚ
epoch_diff©Úvaluer"   r"   r#   ÚtimestampToString;   s    r*   c                 C   st   | d d…   ¡ \}}t | dd … d¡}|jt |¡tjd�}t |¡}| 	¡ |ksdJ d|  d ƒ‚t
| ¡ ƒt S )Né   z %d %H:%M:%S %Y)ÚmonthÚtzinfoú"z" has inconsistent weekday)Úsplitr   ÚstrptimeÚreplacer   Úindexr   Úutcr   ÚweekdayÚintÚ	timestampr'   )r)   ZwkdayZmnthr    Z	wkday_idxr"   r"   r#   ÚtimestampFromString?   s    
r7   c                  C   s0   t j d¡} | d ur t| ƒt S tt ¡ t ƒS )NÚSOURCE_DATE_EPOCH)ÚosÚenvironÚgetr5   r'   r   )Zsource_date_epochr"   r"   r#   ÚtimestampNowH   s    r<   c                 C   s   t | t ƒS )N)r5   r'   r(   r"   r"   r#   ÚtimestampSinceEpochP   s    r=   Ú__main__)N)Ú__doc__r9   r   r   r   ÚcalendarÚtimegmr'   r   r   r$   r*   r7   r<   r=   Ú__name__ÚsysÚdoctestÚexitÚtestmodÚfailedr"   r"   r"   r#   Ú<module>   s    

	