rfwtools.timestamp.is_datetime_in_range
- rfwtools.timestamp.is_datetime_in_range(dt, range_list)[source]
Check if the supplied datetime object is in any of the specified ranges.
Note: If you are giving a single range, use a list, not a tuple. Seems tuples are reduced to the single inner list if only one element is supplied.
- Parameters:
dt (
datetime) – A datetime object to comparerange_list (
List[Tuple[datetime,datetime]]) – A list of 2-tuples of datetime’s. Each pair describes a time range for which dt may be in. Ranges are inclusive on both ends. Leaving an end point in a range as None is treated though it were infinity.
- Return type:
bool- Returns:
True if dt is an any of the supplied ranges. False otherwise.