def Time2Internaldate(date_time):
 if isinstance(date_time, (int, float)):
  tt = time.localtime(date_time)
 elif isinstance(date_time, (tuple, time.struct_time)):
  tt = date_time
 elif (isinstance(date_time, str) and ((date_time[0], date_time[(-1)]) == ('"', '"'))):
  return date_time
 else:
  raise ValueError('date_time not of a known type')
 dt = time.strftime('%d-%b-%Y %H:%M:%S', tt)
 if (dt[0] == '0'):
  dt = (' ' + dt[1:])
 if (time.daylight and tt[(-1)]):
  zone = (- time.altzone)
 else:
  zone = (- time.timezone)
 return ((('"' + dt) + (' %+03d%02d' % divmod((zone // 60), 60))) + '"')

def Time2Internaldate ( date_time ) : if isinstance ( date_time , ( int , float ) ) : tt = time . localtime ( date_time ) elif isinstance ( date_time , ( tuple , time . struct_time ) ) : tt = date_time elif ( isinstance ( date_time , str ) and ( ( date_time [ 0 ] , date_time [ ( - 1 ) ] ) == ( '"' , '"' ) ) ) : return date_time else : raise ValueError ( 'date_time not of a known type' ) dt = time . strftime ( '%d-%b-%Y %H:%M:%S' , tt ) if ( dt [ 0 ] == '0' ) : dt = ( ' ' + dt [ 1 : ] ) if ( time . daylight and tt [ ( - 1 ) ] ) : zone = ( - time . altzone ) else : zone = ( - time . timezone ) return ( ( ( '"' + dt ) + ( ' %+03d%02d' % divmod ( ( zone // 60 ) , 60 ) ) ) + '"' )
convert date_time to imap4 internaldate representation .