From e0129fd0f772e35af516e7f78c34044312f8f81e Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Wed, 1 Jul 2020 19:10:46 +0200 Subject: [PATCH] move timezone to initialization instead of implicit localization --- owrx/controllers/assets.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/owrx/controllers/assets.py b/owrx/controllers/assets.py index 5c4bb61..b15ff64 100644 --- a/owrx/controllers/assets.py +++ b/owrx/controllers/assets.py @@ -14,7 +14,7 @@ class ModificationAwaraController(Controller, metaclass=ABCMeta): def wasModified(self, file): try: - modified = self.getModified(file).astimezone(timezone.utc).replace(microsecond=0) + modified = self.getModified(file).replace(microsecond=0) if modified is not None and "If-Modified-Since" in self.handler.headers: client_modified = datetime.strptime( @@ -30,7 +30,7 @@ class ModificationAwaraController(Controller, metaclass=ABCMeta): class AssetsController(ModificationAwaraController, metaclass=ABCMeta): def getModified(self, file): - return datetime.fromtimestamp(os.path.getmtime(self.getFilePath(file))) + return datetime.fromtimestamp(os.path.getmtime(self.getFilePath(file)), timezone.utc) def openFile(self, file): return open(self.getFilePath(file), "rb") @@ -138,5 +138,5 @@ class CompiledAssetsController(ModificationAwaraController): return f.read() def getModified(self, files): - modified = [datetime.fromtimestamp(os.path.getmtime(f)) for f in files] - return max(*modified) + modified = [os.path.getmtime(f) for f in files] + return datetime.fromtimestamp(max(*modified), timezone.utc)