a
    Dųgß  ć                   @   sL   d dl Z d dlmZ d dlmZmZ d dlmZ dd Zdd Z	d	d
 Z
dS )é    N)Śsettings)ŚformatsŚtimezone)Śparse_datetimec                 C   sD   t jr@t | ”r0t ” }t | |” tjj”} nt 	| tjj”} | S )z®
    Similar to how django-modelcluster stores the revision's data and similar to how
    django stores dates in the database, this converts the date to UTC if required.
    )
r   ŚUSE_TZr   Śis_naiveŚget_default_timezoneŚ
make_awareŚ
astimezoneŚdatetimeŚutcŚ	localtime)ŚvalueZdefault_timezone© r   śW/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/utils/timestamps.pyŚ
ensure_utc   s    
’r   c                 C   s.   t | }tjr*t |”r*tj|t ” d}|S )zR
    Uses Django's parse_datetime(), but ensures to return an aware datetime.
    )r   )r   r   r   r   r   r	   r   )Zdate_stringŚdtr   r   r   Śparse_datetime_localized   s    r   c                 C   s    t  | ”rt  | ”} t | d”S )z~
    Helper function to format a possibly-timezone-aware datetime into the format
    used by Django (e.g. in templates).
    ZDATETIME_FORMAT)r   Zis_awarer   r   Zdate_format)Ś	timestampr   r   r   Śrender_timestamp$   s    

r   )r   Zdjango.confr   Zdjango.utilsr   r   Zdjango.utils.dateparser   r   r   r   r   r   r   r   Ś<module>   s   
