#NEWLINE# def localtime( t = None ) : #NEWLINE# #INDENT# if ( tm_mday is None ) : #NEWLINE# #INDENT# t = time ( ) #NEWLINE# #UNINDENT# date = JS ( 'new Date(@{{t}}*1000)' ) #NEWLINE# dateOffset = date . getTimezoneOffset ( ) #NEWLINE# tm = struct_time ( ) #NEWLINE# tm_year = tm . tm_year = int ( date . getFullYear ( ) ) #NEWLINE# tm_mon = tm . tm_mon = ( int ( date . getMonth ( ) ) + 1 ) #NEWLINE# tm_mday = tm . tm_mday = int ( date . getDate ( ) ) #NEWLINE# tm . tm_hour = int ( date . getHours ( ) ) #NEWLINE# tm . tm_min = int ( date . getMinutes ( ) ) #NEWLINE# tm . tm_sec = int ( date . getSeconds ( ) ) #NEWLINE# tm . tm_wday = ( ( int ( date . getDay ( ) ) + 6 ) % 7 ) #NEWLINE# tm . tm_isdst = ( 0 if ( timezone == ( 60 * date . getTimezoneOffset ( ) ) ) else 1 ) #NEWLINE# startOfYear = JS ( 'new Date(@{{tm_year}},0,1)' ) #NEWLINE# startOfYearOffset = startOfYear . getTimezoneOffset ( ) #NEWLINE# startOfDay = JS ( 'new Date(@{{tm_year}},@{{tm_mon}}-1,@{{tm_mday}})' ) #NEWLINE# dt = ( float ( ( startOfDay . getTime ( ) - startOfYear . getTime ( ) ) ) / 1000 ) #NEWLINE# dt = ( dt + ( 60 * ( startOfYearOffset - dateOffset ) ) ) #NEWLINE# tm . tm_yday = ( 1 + int ( ( dt / 86400.0 ) ) ) #NEWLINE# return tm