
    Jf8                        d Z ddlmZ ddlmZ 	 ddlmZ eZddl	m	Z	m
Z
 ddlmZ ddlmZ dd	lmZmZ dd
ZddZddZ G d de      Zy# e$ r dZY =w xY w)z(
Tests for L{twisted.python._tzhelper}.
    )annotations)environ)tzsetN)datetime	timedelta)mktime)FixedOffsetTimeZone)SkipTestTestCasec                P    	 t        |       S # t        $ r t        d|       w xY w)z
    Call L{mktime_real}, and if it raises L{OverflowError}, catch it and raise
    SkipTest instead.

    @param t9: A time as a 9-item tuple.
    @type t9: L{tuple}

    @return: A timestamp.
    @rtype: L{float}
    z(Platform cannot construct time zone for )mktime_realOverflowErrorr
   )t9s    \/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/twisted/python/test/test_tzhelper.pyr   r      s6    J2 JA"HIIJs   
 %c                    t         y| 	 t        d= t                y| t        d<   t                y# t        $ r Y t                yw xY w)zR
    Set time zone.

    @param name: a time zone name
    @type name: L{str}
    NTZ)r   r   KeyError)names    r   setTZr   0   sO     }|	
 
G 	G	  	 
G		s   1 	AAc                \    t        j                  dd      | j                  dfd       }y)z
    Add cleanup hooks to a test case to reset timezone to original value.

    @param testCase: the test case to add the cleanup to.
    @type testCase: L{unittest.TestCase}
    r   Nc                     t                y )N)r   )tzIns   r   resetTZzaddTZCleanup.<locals>.resetTZM   s
    d    returnNone)r   get
addCleanup)testCaser   r   s     @r   addTZCleanupr!   D   s-     ;;tT"D r   c                      e Zd ZdZddZy)FixedOffsetTimeZoneTestsz+
    Tests for L{FixedOffsetTimeZone}.
    c                     t         t        d      	 	 	 	 	 	 	 	 d fd}t                 |ddd        |ddd        |d	d
d        |ddd       y)z
        Test that timezone attributes respect the timezone as set by the
        standard C{TZ} environment variable and L{tzset} API.
        Nz:Platform cannot change timezone; unable to verify offsets.c                   t        |        t        d      }t        j                  |      }t        d      }t        j                  |      }t	        j
                  |      }t	        j
                  |      }
j                  |j                  |      d|        
j                  |j                  |      d|        
j                  |j                  |      t        d             
j                  |j                  |      t        d             dd}	
j                  |j                  |       |	|             
j                  |j                  |       |	|             y )N)	i        r   r   r            )	i  r*      r   r   r      r+   r   UTCr   c                    t        |       dk(  sJ | d   }t        | dd       }t        | dd       }|dk(  r| }| }n|dk(  sJ t        ||      S )N   r   r*      -+)hoursminutes)lenintr   )offsetsignr3   r4   s       r   timeDeltaFromOffsetzZFixedOffsetTimeZoneTests.test_tzinfo.<locals>.testForTimeZone.<locals>.timeDeltaFromOffsetr   sk    6{a'''ayF1QK(fQqk*3;"FE&hG3;&; ug>>r   )r7   strr   r   )r   r   r   fromtimestampr	   fromLocalTimeStampassertEqualtznamedstr   	utcoffset)r   expectedOffsetDSTexpectedOffsetSTDlocalDST
localDSTdtlocalSTD
localSTDdttzDSTtzSTDr9   selfs             r   testForTimeZonez=FixedOffsetTimeZoneTests.test_tzinfo.<locals>.testForTimeZone_   s/    $K?@H!//9J>?H!//9J'::8DE'::8DEU\\*5=N<O7PQU\\*5=N<O7PQUYYz2IaLAUYYz2IaLA? 
+-@AR-S 
+-@AR-Sr   zUTC+00z+0000zEST+05EDT,M4.1.0,M10.5.0z-0400z-0500zCEST-01CEDT,M4.1.0,M10.5.0z+0200z+0100zCST+06z-0600)r   r:   rA   r:   rB   r:   r   r   )r   r
   r!   )rI   rJ   s   ` r   test_tzinfoz$FixedOffsetTimeZoneTests.test_tzinfoW   sz    
 =WXX'	'	*-'	BE'	'	R 	T 	'732GWE4gwG'73r   Nr   )__name__
__module____qualname____doc__rK    r   r   r#   r#   R   s    :4r   r#   )r   z2tuple[int, int, int, int, int, int, int, int, int]r   float)r   z
str | Noner   r   )r    r   r   r   )rO   
__future__r   osr   timer   _tzsetImportErrorr   r   r   r   twisted.python._tzhelperr	   twisted.trial.unittestr
   r   r   r!   r#   rP   r   r   <module>rY      s`    # $ E ( & 8 5J"(?4x ?4I  Es   A AA