[enh] Use aware UTC date in backup settings and app

This commit is contained in:
ljf 2018-12-09 21:08:36 +01:00
parent c417c62894
commit 60843edc0f
3 changed files with 6 additions and 5 deletions

View file

@ -1762,8 +1762,7 @@ def _get_app_status(app_id, format_date=False):
if not v: if not v:
status[f] = '-' status[f] = '-'
else: else:
status[f] = time.strftime(m18n.n('format_datetime_short'), status[f] = datetime.utcfromtimestamp(v).replace(tzinfo=pytz.utc)
time.gmtime(v))
return status return status

View file

@ -33,6 +33,8 @@ import shutil
import subprocess import subprocess
import csv import csv
import tempfile import tempfile
import pytz
from datetime import datetime
from glob import glob from glob import glob
from collections import OrderedDict from collections import OrderedDict
@ -2266,8 +2268,8 @@ def backup_info(name, with_details=False, human_readable=False):
result = { result = {
'path': archive_file, 'path': archive_file,
'created_at': time.strftime(m18n.n('format_datetime_short'), 'created_at': datetime.utcfromtimestamp(info['created_at'])
time.gmtime(info['created_at'])), .replace(tzinfo=pytz.utc),
'description': info['description'], 'description': info['description'],
'size': size, 'size': size,
} }

View file

@ -154,7 +154,7 @@ def settings_reset_all():
# addition but we'll see if this is a common need. # addition but we'll see if this is a common need.
# Another solution would be to use etckeeper and integrate those # Another solution would be to use etckeeper and integrate those
# modification inside of it and take advantage of its git history # modification inside of it and take advantage of its git history
old_settings_backup_path = SETTINGS_PATH_OTHER_LOCATION % datetime.now().strftime("%F_%X") old_settings_backup_path = SETTINGS_PATH_OTHER_LOCATION % datetime.utcnow().strftime("%F_%X")
_save_settings(settings, location=old_settings_backup_path) _save_settings(settings, location=old_settings_backup_path)
for value in settings.values(): for value in settings.values():