o
    j                     @   s   d Z ddlmZmZmZ ddlmZ dZdZedZeddZ	G dd	 d	eZ
e
 Zd
d Zdd Zedkr@ddlZe  dS dS )zHTools to convert between Python datetime instances and Microsoft times.
    )datetime	timedeltatzinfo)timegml     }*{Gi    )hoursc                   @   s(   e Zd Zd Zdd Zdd Zdd ZdS )UTCc                 C      t S NZEROselfdt r   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pypykatz/commons/filetime.py	utcoffset,      zUTC.utcoffsetc                 C   s   dS )Nr   r   r   r   r   r   tzname/   r   z
UTC.tznamec                 C   r	   r
   r   r   r   r   r   dst2   r   zUTC.dstN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   *   s
    r   c                 C   s:   | j du s| j | du r| jtd} tt|  t  S )ag  Converts a datetime to Microsoft filetime format. If the object is
	time zone-naive, it is forced to UTC before conversion.

	>>> "%.0f" % dt_to_filetime(datetime(2009, 7, 25, 23, 0))
	'128930364000000000'

	>>> dt_to_filetime(datetime(1970, 1, 1, 0, 0, tzinfo=utc))
	116444736000000000L

	>>> dt_to_filetime(datetime(1970, 1, 1, 0, 0))
	116444736000000000L
	N)r   )r   r   replaceutcEPOCH_AS_FILETIMEr   	timetupleHUNDREDS_OF_NANOSECONDS)r   r   r   r   dt_to_filetime9   s   r   c                 C   s   t j| t t tdS )a&  Converts a Microsoft filetime number to a Python datetime. The new
	datetime object is time zone-naive but is equivalent to tzinfo=utc.
	>>> filetime_to_dt(116444736000000000)
	datetime.datetime(1970, 1, 1, 0, 0)

	>>> filetime_to_dt(128930364000000000)
	datetime.datetime(2009, 7, 25, 23, 0)
	)tz)r   fromtimestampr   r   r   )ftr   r   r   filetime_to_dtK   s   	r#   __main__N)r   r   r   r   calendarr   r   r   r   HOURr   r   r   r#   r   doctesttestmodr   r   r   r   <module>   s   
