fix displayname property for directories
[pandav-og.git] / util.py
blob980e9a205b10c16e476ff876c517dfac97e25330
1 # Copyright (c) 2005.-2006. Ivan Voras <ivoras@gmail.com>
2 # Released under the Artistic License
4 from time import time, timezone, strftime, localtime, gmtime
7 def unixdate2iso8601(d):
8 tz = timezone / 3600 # can it be fractional?
9 tz = '%+03d' % tz
10 return strftime('%Y-%m-%dT%H:%M:%S', localtime(d)) + tz + ':00'
12 def unixdate2httpdate(d):
13 return strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime(d))
16 def dict2xml(d):
17 r = ''
18 for k in d:
19 if d[k] != None:
20 if type(d[k]) == type(d):
21 r += '<%s>%s</%s>' % (k, dict2xml(d[k]), k)
22 else:
23 r += '<%s>%s</%s>' % (k, d[k], k)
24 else:
25 r += '<%s/>' % k
26 return r