# `OpenHours.TimeSlot`
[🔗](https://github.com/hopsor/open_hours/blob/v1.0.1/lib/open_hours/time_slot.ex#L1)

This module contains all functions to work with time slots.

# `t`

```elixir
@type t() :: %OpenHours.TimeSlot{ends_at: DateTime.t(), starts_at: DateTime.t()}
```

Struct composed by a start datetime and an end datetime.

# `between`

```elixir
@spec between(OpenHours.Schedule.t(), DateTime.t(), DateTime.t()) :: [t()]
```

Calculates a list of time slots between two dates based on a Schedule. It follows the same rules
as `OpenHours.Schedule.in_hours?/2`.

# `next`

```elixir
@spec next(OpenHours.Schedule.t(), DateTime.t(), keyword()) :: [t()]
```

Returns the next time slots from the given DateTime, looking forward in the schedule.

## Options

  * `:limit` - number of slots to return (default: `1`)
  * `:include_overlap` - if `true`, includes the slot containing the given DateTime
    (default: `true`)

Returns a list of `%TimeSlot{}` structs ordered chronologically.

# `previous`

```elixir
@spec previous(OpenHours.Schedule.t(), DateTime.t(), keyword()) :: [t()]
```

Returns the previous time slots from the given DateTime, looking backward in the schedule.

## Options

  * `:limit` - number of slots to return (default: `1`)
  * `:include_overlap` - if `true`, includes the slot containing the given DateTime
    (default: `true`)

Returns a list of `%TimeSlot{}` structs ordered from most recent to least recent.

# `stream_next`

```elixir
@spec stream_next(OpenHours.Schedule.t(), DateTime.t(), keyword()) :: Enumerable.t()
```

Returns a lazy stream of time slots from the given DateTime, looking forward
in the schedule.

The stream is infinite and respects holidays, shifts, and breaks.

## Options

  * `:include_overlap` - if `true`, includes the slot containing the given
    DateTime (default: `true`)

## Examples

    schedule
    |> TimeSlot.stream_next(datetime)
    |> Enum.take(5)

# `stream_previous`

```elixir
@spec stream_previous(OpenHours.Schedule.t(), DateTime.t(), keyword()) ::
  Enumerable.t()
```

Returns a lazy stream of time slots from the given DateTime, looking backward
in the schedule.

The stream is infinite and respects holidays, shifts, and breaks.

## Options

  * `:include_overlap` - if `true`, includes the slot containing the given
    DateTime (default: `true`)

## Examples

    schedule
    |> TimeSlot.stream_previous(datetime)
    |> Enum.take(5)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
