Merge pull request #2 from ShaYmez/copilot/fix-datetime-utc-attribute-error

Replace datetime.UTC with datetime.timezone.utc for Python <3.11 compatibility
This commit is contained in:
M0VUB 2025-12-25 19:52:58 +00:00 committed by GitHub
commit f69dca1510
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -836,7 +836,7 @@ def printlog(log_level, mess):
global debug
if file_rotate == "1":
log_file = log_basename + '-' + str(datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d')) + '.log'
log_file = log_basename + '-' + str(datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d')) + '.log'
else:
log_file = log_basename + '.log'
try:
@ -850,10 +850,10 @@ def printlog(log_level, mess):
str_log = None
if isinstance(log_level, int):
if file_level <= log_level:
str_log = check_string('M: ' + str(datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d %H:%M:%S.%f'))[:-3] + ' ' + mess)
str_log = check_string('M: ' + str(datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d %H:%M:%S.%f'))[:-3] + ' ' + mess)
else:
if log_level == "d" and debug == 1:
str_log = check_string('D: ' + str(datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d %H:%M:%S.%f'))[:-3] + ' ' + mess)
str_log = check_string('D: ' + str(datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d %H:%M:%S.%f'))[:-3] + ' ' + mess)
if str_log is not None:
try:
filelog.write(str_log + '\n')
@ -910,7 +910,7 @@ debug = config[13]
### log
if file_rotate == "1":
log_file = log_basename + '-' + str(datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d')) + '.log'
log_file = log_basename + '-' + str(datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%d')) + '.log'
else:
log_file = log_basename + '.log'
try: