diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 2d70b1ac5ba..4142d733f04 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -35,6 +35,11 @@ jobs: scripts/install/core scripts/install/frontend + - name: ⏲️ Set time zone + uses: szenius/set-timezone@v2.0 + with: + timezoneLinux: 'Asia/Singapore' + - name: 🏃 Run tests env: PYTEST: true @@ -69,6 +74,11 @@ jobs: scripts/install/core_dev scripts/install/frontend + - name: ⏲️ Set time zone + uses: szenius/set-timezone@v2.0 + with: + timezoneLinux: 'Asia/Singapore' + - name: 🏃 Run tests env: PYTEST: true diff --git a/custom_components/hacs/repositories/base.py b/custom_components/hacs/repositories/base.py index ba8be0e89b6..82c533b1e3b 100644 --- a/custom_components/hacs/repositories/base.py +++ b/custom_components/hacs/repositories/base.py @@ -2,7 +2,7 @@ from __future__ import annotations from asyncio import sleep -from datetime import datetime +from datetime import datetime, UTC import os import pathlib import shutil @@ -196,7 +196,7 @@ def update_data(self, data: dict, action: bool = False) -> None: continue if key == "last_fetched" and isinstance(value, float): - setattr(self, key, datetime.fromtimestamp(value)) + setattr(self, key, datetime.fromtimestamp(value, UTC)) elif key == "id": setattr(self, key, str(value)) elif key == "country": @@ -501,7 +501,7 @@ async def common_registration(self) -> None: if self.repository_object: self.data.last_updated = self.repository_object.attributes.get("pushed_at", 0) - self.data.last_fetched = datetime.utcnow() + self.data.last_fetched = datetime.now(UTC) @concurrent(concurrenttasks=10, backoff_time=5) async def common_update(self, ignore_issues=False, force=False, skip_releases=False) -> bool: @@ -549,7 +549,7 @@ async def common_update(self, ignore_issues=False, force=False, skip_releases=Fa self.additional_info = await self.async_get_info_file_contents() # Set last fetch attribute - self.data.last_fetched = datetime.utcnow() + self.data.last_fetched = datetime.now(UTC) return True diff --git a/custom_components/hacs/utils/data.py b/custom_components/hacs/utils/data.py index 12e9db73e49..93ac665bc31 100644 --- a/custom_components/hacs/utils/data.py +++ b/custom_components/hacs/utils/data.py @@ -2,7 +2,7 @@ from __future__ import annotations import asyncio -from datetime import datetime +from datetime import datetime, UTC from typing import Any from homeassistant.core import callback @@ -308,7 +308,7 @@ def async_restore_repository(self, entry: str, repository_data: dict[str, Any]): repository.data.manifest_name = repository_data.get("manifest_name") if last_fetched := repository_data.get("last_fetched"): - repository.data.last_fetched = datetime.fromtimestamp(last_fetched) + repository.data.last_fetched = datetime.fromtimestamp(last_fetched, UTC) repository.repository_manifest = HacsManifest.from_dict( repository_data.get("manifest") or repository_data.get("repository_manifest") or {}