From 205eee4d805079bfe46346d501f4dd0c80a6016a Mon Sep 17 00:00:00 2001 From: WillyPillow Date: Sat, 5 Sep 2020 01:51:45 +0800 Subject: [PATCH] qvm-template: Fix timezone issues by storing timezone explictly in features --- qubesadmin/tests/tools/qvm_template.py | 8 ++++---- qubesadmin/tools/qvm_template.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/qubesadmin/tests/tools/qvm_template.py b/qubesadmin/tests/tools/qvm_template.py index dbbc687..99691a5 100644 --- a/qubesadmin/tests/tools/qvm_template.py +++ b/qubesadmin/tests/tools/qvm_template.py @@ -149,8 +149,8 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase): mock_rename, mock_remove): self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = b'0\0' - build_time = '2020-09-01 22:30:00' # 1598970600 - install_time = '2020-09-01 23:30:00.508230' + build_time = '2020-09-01 14:30:00+00:00' # 1598970600 + install_time = '2020-09-01 15:30:00.508230+00:00' for key, val in [ ('name', 'test-vm'), ('epoch', '2'), @@ -280,8 +280,8 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase): mock_rename, mock_remove): self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = b'0\0' - build_time = '2020-09-01 22:30:00' # 1598970600 - install_time = '2020-09-01 23:30:00.508230' + build_time = '2020-09-01 14:30:00+00:00' # 1598970600 + install_time = '2020-09-01 15:30:00.508230+00:00' for key, val in [ ('name', 'test-vm'), ('epoch', '2'), diff --git a/qubesadmin/tools/qvm_template.py b/qubesadmin/tools/qvm_template.py index 6e43282..fcc3fdc 100644 --- a/qubesadmin/tools/qvm_template.py +++ b/qubesadmin/tools/qvm_template.py @@ -923,9 +923,10 @@ def install( tpl.features['template-reponame'] = reponame tpl.features['template-buildtime'] = \ str(datetime.datetime.fromtimestamp( - int(package_hdr[rpm.RPMTAG_BUILDTIME]))) + int(package_hdr[rpm.RPMTAG_BUILDTIME]), + tz=datetime.timezone.utc)) tpl.features['template-installtime'] = \ - str(datetime.datetime.today()) + str(datetime.datetime.today(tz=datetime.timezone.utc)) tpl.features['template-license'] = \ package_hdr[rpm.RPMTAG_LICENSE] tpl.features['template-url'] = \