move timezone to initialization instead of implicit localization

This commit is contained in:
Jakob Ketterl 2020-07-01 19:10:46 +02:00
parent 929cf5e230
commit e0129fd0f7
1 changed files with 4 additions and 4 deletions

View File

@ -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)