On 3 Apr 2001 18:25:45 GMT, brey at ductape.net <brey at ductape.net> wrote: >Is there a module that I'm missing that will take a time tuple and output the >proper RFC 822 date string? Ed, I'll append what I do in Swallow. I think it's right. Regards, Matt def getRfc822Date(): # Can't use the strings from the time module since they # vary by locale and RFC822 (amended by RFC1123) requires # English. dayNames=("Mon","Tue","Wed","Thu","Fri","Sat","Sun") monthNames=("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug", \ "Sep","Oct","Nov","Dec") timeTuple=time.localtime(time.time()) timeStr=dayNames[timeTuple[6]]+", "+str(timeTuple[2])+" "+ \ monthNames[timeTuple[1]]+" "+str(timeTuple[0])+" " timeStr=timeStr+time.strftime("%H:%M:%S ",timeTuple) if timeTuple[8]<>0: zoneSecs=time.altzone else: zoneSecs=time.timezone zoneAbsSecs=abs(zoneSecs) zoneMins=zoneSecs/60 zoneHours=int(zoneMins/60) # Actually already integer division zoneLeftoverMins=zoneMins-zoneHours*60 if zoneSecs>0: timeStr=timeStr+"-" timeStr=timeStr+"%02i%02i " % (zoneHours,zoneLeftoverMins) timeStr=timeStr+"("+time.tzname[timeTuple[8]]+")" return timeStr
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4