move timezone to initialization instead of implicit localization
This commit is contained in:
parent
929cf5e230
commit
e0129fd0f7
@ -14,7 +14,7 @@ class ModificationAwaraController(Controller, metaclass=ABCMeta):
|
|||||||
|
|
||||||
def wasModified(self, file):
|
def wasModified(self, file):
|
||||||
try:
|
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:
|
if modified is not None and "If-Modified-Since" in self.handler.headers:
|
||||||
client_modified = datetime.strptime(
|
client_modified = datetime.strptime(
|
||||||
@ -30,7 +30,7 @@ class ModificationAwaraController(Controller, metaclass=ABCMeta):
|
|||||||
|
|
||||||
class AssetsController(ModificationAwaraController, metaclass=ABCMeta):
|
class AssetsController(ModificationAwaraController, metaclass=ABCMeta):
|
||||||
def getModified(self, file):
|
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):
|
def openFile(self, file):
|
||||||
return open(self.getFilePath(file), "rb")
|
return open(self.getFilePath(file), "rb")
|
||||||
@ -138,5 +138,5 @@ class CompiledAssetsController(ModificationAwaraController):
|
|||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
def getModified(self, files):
|
def getModified(self, files):
|
||||||
modified = [datetime.fromtimestamp(os.path.getmtime(f)) for f in files]
|
modified = [os.path.getmtime(f) for f in files]
|
||||||
return max(*modified)
|
return datetime.fromtimestamp(max(*modified), timezone.utc)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user