Timestamp function fails on timestamps larger than sys.maxint

The timestamp function uses time.localtime to convert a timestamp
to a time object. According to the Python docs, this module falls
back to C library functions that handle int-sized values only (i.e.
up to the year 2038). If values larger than sys.maxint are passed,
the function throws an exception (at least on my x86 system).

Now, apparently, in some cases the ratio estimation can come up with
interesting values, such as reaching ratio 990 sometimes in 2077,
which would result in trc crashing when viewing the torrent detail
page.

Work around this issue by using the datetime module in cases timestamp
is larger than sys.maxint. datetime.timedelta does not use C library
functions and handles large values. By adding the timedelta to a
datetime object, a new datetime object is created which is then
converted to a normal time object.
import datetime