Browse Source

qvm-template: Fix timezone issues by storing timezone explictly in features

WillyPillow 3 years ago
parent
commit
205eee4d80
2 changed files with 7 additions and 6 deletions
  1. 4 4
      qubesadmin/tests/tools/qvm_template.py
  2. 3 2
      qubesadmin/tools/qvm_template.py

+ 4 - 4
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'),

+ 3 - 2
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'] = \