
    g@                        S SK r S SKJrJr  S SKr\" S\5      r\" S\5      r\" S5      r\ R                   " SSSS S S S \ R                  R                  S9rS	r\S
-  rS\SS4S jrS\ R                   S\4S jrS\4S jrS\S\ R                   4S jrS\ R$                  S\4S jrS\S\ R$                  4S jrS\S\4S jrSS\S\\   S\4S jjrg)    N)NewTypeOptionalNtTimeNtTimeDeltal    iA     )tzinfo
   i@B nt_timereturnc                     [        U [        5      (       d  [        U  S35      eSU s=::  a
  [        ::  d  O  [        U  S35      eg )Nz is not an integerr   z is out of range)
isinstanceint
ValueErrorNT_TIME_MAX)r
   s    //usr/lib/python3/dist-packages/samba/nt_time.py_validate_nt_timer   #   sG    gs##G9$6788&;&G9$4566 '    tmc                     U [         -
  n[        [        UR                  5       [        -  5      5      n[        U5        U$ N)NT_EPOCHr   roundtotal_secondsNT_TICKS_PER_SECr   )r   time_since_epochr
   s      r   nt_time_from_datetimer   *   s8    H}U+99;>NNOPGgNr   c                      [         R                   R                  [         R                  R                  5      n [	        U 5      $ r   )datetimenowtimezoneutcr   dts    r   nt_nowr$   1   s/    					x0044	5B $$r   c                 `    [        U 5        [        R                  " U [        -  S9n[        U-   $ N)microseconds)r   r   	timedelta   NT_TICKS_PER_μSECr   )r
   r   s     r   datetime_from_nt_timer*   6   s-    g))wAS7ST&&&r   r#   c                 T    [        [        U R                  5       [        -  5      5      $ r   )r   r   r   r   r"   s    r   nt_time_delta_from_timedeltar,   <   s!    uR--/2BBCDDr   nt_time_deltac                 8    [         R                  " U [        -  S9$ r&   )r   r(   r)   )r-   s    r   timedelta_from_nt_time_deltar/   @   s    =;M+MNNr   sc                     U S:X  a8  [         R                   R                  [         R                  R                  5      nO][        R
                  " SU 5      (       a!  [         R                   R                  U S5      nO [         R                   R                  U 5      n UR                  c  UR                  5       n[        U5      $ ! [         a    [        SU  S35      ef = f)a  Convert a subset of ISO 8601 date/time strings, ldap timestamps,
and the string 'now' into NT time.

The ldap format is

   YYYYmmddHHMMSS.0Z

which is 14 digits followed by the fixed string '.0Z'. This is
used in LDIF and internally by ldb.

The ISO format is

YYYY-mm-dd[*HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]]]

where the '*' can be any character, and the optional last
'[+HH:MM[:SS[.ffffff]]]' is a timezone offset (use '+00:00' for
UTC).
r   z^\d{14}\.0Z$z%Y%m%d%H%M%S.0ZzExpected a date in either ISO8601 'YYYY-MM-DD HH:MM:SS' format, LDAP timestamp 'YYYYmmddHHMMSS.0Z', or the literal string 'now'.  Got 'z'.)r   r   r    r!   rematchstrptimefromisoformatr   r   
astimezoner   )r0   r#   s     r   nt_time_from_stringr7   D   s    &
:""&&x'8'8'<'<=BXXoq))""++A/@AB""003B 
yy ]]_ $$  
 Cr	
 	

s   =C  <C =C Cnttimeformatc                 `    [        U 5      nUb  UR                  U5      $ UR                  5       $ )z[Format an NtTime date as a string.

If format is not provided, an ISO 8601 string is used.
)r*   strftime	isoformat)r8   r9   r#   s      r   string_from_nt_timer=   q   s/    
 
v	&B{{6""<<>r   r   )r   typingr   r   r2   r   r   r   r   r    r!   r   r)   r   r   r   r$   r*   r(   r,   r/   strr7   r=    r   r   <module>rA      s*  (  $ 	 
3	mS)]#T1aAq!H<M<M<Q<QR %	1 7v 7$ 7h// F % %
'6 'h.?.? 'EX%7%7 EK EO O@R@R O*%3 *%6 *%Z
 
 
 
r   