Open iliyan85 opened 3 months ago
Thanks. I haven't taken a deeper look into it, but I think it can be fixed by changing the following line: https://github.com/jazzband/imaplib2/blob/615419b705ba46f8326e5c38cfe48170501c39ef/imaplib2/imaplib2.py#L2388
to dt = datetime.fromtimestamp(time.mktime(time.localtime(date_time)))
.
But again, I haven't had time to actually test it.
time.time() or other int or float value throws an exception when it is using as date_time input for Time2Internaldate function.
The error message is: UnboundLocalError: cannot access local variable 'dt' where it is not associated with a value
if isinstance(date_time, (int, float)): #time.time() returns True tt = time.localtime(date_time)
and after that fmt = '"%d-{}-%Y %H:%M:%S %z"'.format(MonthNames[dt.month])
'dt' cannot be used.
Time2Internaldate works correctly by the following way:
dt = datetime.datetime.now(pytz.timezone('Europe/Sofia')) imaplib2.Time2Internaldate(dt)