Changeset 16:44fc74571ee8 in livinglogic.python.nightshade

Show
Ignore:
Timestamp:
05/19/06 11:12:35 (14 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Fix handling of UTC timestamps (offset was substracted twice).

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • nightshade.py

    r15 r16  
    99weekdayname = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] 
    1010monthname = [None, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] 
     11 
     12 
     13class UTC(datetime.tzinfo): 
     14    def utcoffset(self, dt): 
     15        return datetime.timedelta(0) 
     16 
     17    def dst(self, dt): 
     18        return datetime.timedelta(0) 
     19 
     20    def tzname(self, dt): 
     21        return "UTC" 
     22 
     23utc = UTC() 
    1124 
    1225 
     
    2134    """ 
    2235    if dt.tzinfo is None: 
    23         offset = [time.timezone, time.altzone][time.daylight] 
     36        dt += datetime.timedelta(seconds=[time.timezone, time.altzone][time.daylight]) 
    2437    else: 
    25         offset = -60*dt.tzinfo.utcoffset(dt) 
    26     dt += datetime.timedelta(seconds=offset) 
     38        dt -= dt.tzinfo.utcoffset(dt) 
    2739    return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (weekdayname[dt.weekday()], dt.day, monthname[dt.month], dt.year, dt.hour, dt.minute, dt.second) 
    2840 
     
    5163            if cherrypy.request.method != "GET": 
    5264                return func(*args, **kwargs) 
    53             now = datetime.datetime.utcnow() 
     65            now = datetime.datetime.utcnow().replace(tzinfo=utc) 
    5466            cachekey = (args, tuple(sorted(kwargs.iteritems()))) 
    5567            self.lock.acquire() 
     
    150162        """ 
    151163         
    152         now = datetime.datetime.utcnow() 
     164        now = datetime.datetime.utcnow().replace(tzinfo=utc) 
    153165        if self.pool is not None: 
    154166            while 1: 
  • setup.py

    r13 r16  
    5252tools.setup( 
    5353    name="ll-nightshade", 
    54     version="0.2.2", 
     54    version="0.2.3", 
    5555    description="Serve the output of TOXIC functions/procedures with CherryPy", 
    5656    long_description=DESCRIPTION,