def strftime(s):
+ if s is None:
+ return s
+ n = int(s)
+ if n > 10**9:
+ n /= 10**6
try:
- return time.strftime("%a %d %b %Y %T", time.localtime(int(s)))
+ return time.strftime("%a %d %b %Y %T", time.localtime(n))
except (TypeError, ValueError): # s is None or is already formatted
return s