[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:
status[f] = '-'
else:
status[f] = time.strftime(m18n.n('format_datetime_short'),
time.gmtime(v))
status[f] = datetime.utcfromtimestamp(v).replace(tzinfo=pytz.utc)
return status

View file

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

View file

@ -154,7 +154,7 @@ def settings_reset_all():
# addition but we'll see if this is a common need.
# Another solution would be to use etckeeper and integrate those
# 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)
for value in settings.values():