[web/request] don't play tricks with utc offset

We need an UTC datetime from a time.time()-type value. It turns out datetime provides a method to do just that. Related to #2154655.

authorJulien Cristau <julien.cristau@logilab.fr>
changesetb6c55274135a
branchdefault
phasepublic
hiddenno
parent revision#593e63a68429 [server/test] Drop dependency on folder cube
child revision#937deb71a681 [web] kill GMTOFFSET (closes #2154655)
files modified by this revision
web/request.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1427355287 -3600
# Thu Mar 26 08:34:47 2015 +0100
# Node ID b6c55274135aa46a82f4dd274146db48acec490b
# Parent 593e63a684295bba522c44d9c5e4547af2364676
[web/request] don't play tricks with utc offset

We need an UTC datetime from a time.time()-type value. It turns out
datetime provides a method to do just that. Related to #2154655.

diff --git a/web/request.py b/web/request.py
@@ -809,12 +809,11 @@
1          """If the HTTP header If-modified-since is set, return the equivalent
2          date time value (GMT), else return None
3          """
4          mtime = self.get_header('If-modified-since', raw=False)
5          if mtime:
6 -            # :/ twisted is returned a localized time stamp
7 -            return datetime.fromtimestamp(mtime) + GMTOFFSET
8 +            return datetime.utcfromtimestamp(mtime)
9          return None
10 
11      ### outcoming headers
12      def set_header(self, header, value, raw=True):
13          """set an output HTTP header"""