Changeset 4237

Show
Ignore:
Timestamp:
07/04/08 17:19:43 (3 months ago)
Author:
ed
Message:

Added the 'webHeaderFormat()' method that takes a datetime value and returns a formatted string that conforms with the standard expected by HTTP headers.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/lib/dates.py

    r4183 r4237  
    266266 
    267267 
     268def webHeaderFormat(dtm): 
     269    """Takes a datetime value and returns a string in the format required by  
     270    HTTP headers, such as an 'If-Modified-Since' header. 
     271    """ 
     272    hereNow, utcNow = datetime.datetime.now(), datetime.datetime.utcnow() 
     273    offset = utcNow - hereNow 
     274    adjusted = dtm + offset 
     275    return adjusted.strftime("%a, %d %b %Y %H:%M:%S GMT") 
     276 
     277 
     278 
    268279if __name__ == "__main__": 
    269280    print "testing converting strings to dates:"