Logo Search packages:      
Sourcecode: offlineimap version File versions  Download package

def offlineimap::imaplib::Time2Internaldate (   date_time  ) 

Convert 'date_time' to IMAP4 INTERNALDATE representation.

Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'

Definition at line 1301 of file imaplib.py.

01301                                 :

    """Convert 'date_time' to IMAP4 INTERNALDATE representation.

    Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'
    """

    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        # Assume in correct format
    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) + '"'



if __name__ == '__main__':


Generated by  Doxygen 1.6.0   Back to index