def within_time_range(d1, d2, maxdiff_seconds):
    """Return true if two datetime.datetime object differs less than the given seconds"""
    delta = d2 - d1 if d2 > d1 else d1 - d2
    diff = (delta.microseconds + (delta.seconds + delta.days * 24 * 3600) *
        1000000.0) / 1000000.0
    return diff < maxdiff_seconds
