Convert `time` to a datetime.

def to_datetime(time):
    '''Convert `time` to a datetime.'''
    if type(time) == IntType or type(time) == LongType:
        time = datetime.fromtimestamp(time // 1000)
    return time