Validate timestamp specified by request.

    See `validate.request` for additional info.

    Args:
        stamp: str. Time request was made as ISO 8601 timestamp.
        tolerance: int. Number of seconds request remains valid from timestamp.

    Returns
        bool: True if valid, False otherwise.

def timestamp(stamp, tolerance=150):
    """Validate timestamp specified by request.

    See `validate.request` for additional info.

    Args:
        stamp: str. Time request was made as ISO 8601 timestamp.
        tolerance: int. Number of seconds request remains valid from timestamp.

    Returns
        bool: True if valid, False otherwise.
    """
    try:
        tolerance = datetime.timedelta(0, tolerance)
        timestamp_low = dateutil.parser.parse(stamp)
        timestamp_high = timestamp_low + tolerance
        now = datetime.datetime.now(timestamp_low.tzinfo)
    except ValueError:
        return False

    return now >= timestamp_low and now <= timestamp_high