# `Crontab.CronExpression`
[🔗](https://github.com/maennchen/crontab/blob/v1.2.1/lib/crontab/cron_expression.ex#L1)

The `Crontab.CronExpression` module / struct.

# `ambiguity_opt`

```elixir
@type ambiguity_opt() :: :prior | :subsequent
```

# `condition`

```elixir
@type condition() ::
  condition(:second, Calendar.second())
  | condition(:minute, Calendar.minute())
  | condition(:hour, Calendar.hour())
  | condition(:day, Calendar.day())
  | condition(:month, Calendar.month())
  | condition(:weekday, Calendar.day_of_week())
  | condition(:year, Calendar.year())
  | condition(:ambiguity_opts, [ambiguity_opt()])
```

# `condition`

```elixir
@type condition(name, time_unit) :: {name, [value(time_unit) | ambiguity_opt()]}
```

# `condition_list`

```elixir
@type condition_list() :: [condition()]
```

# `day`

> This type is deprecated. Use Calendar.day/0 instead.

```elixir
@type day() :: Calendar.day()
```

# `hour`

> This type is deprecated. Use Calendar.hour/0 instead.

```elixir
@type hour() :: Calendar.hour()
```

# `interval`

```elixir
@type interval() ::
  :second | :minute | :hour | :day | :month | :weekday | :year | :ambiguity_opts
```

# `min_max`

> This type is deprecated. Use Crontab.CronExpression.min_max/1 instead.

```elixir
@type min_max() :: {:-, time_unit(), time_unit()}
```

# `min_max`

```elixir
@type min_max(time_unit) :: {:-, time_unit, time_unit}
```

# `minute`

> This type is deprecated. Use Calendar.minute/0 instead.

```elixir
@type minute() :: Calendar.minute()
```

# `month`

> This type is deprecated. Use Calendar.month/0 instead.

```elixir
@type month() :: Calendar.month()
```

# `second`

> This type is deprecated. Use Calendar.second/0 instead.

```elixir
@type second() :: Calendar.second()
```

# `t`

```elixir
@type t() :: %Crontab.CronExpression{
  day: [value(day())],
  extended: boolean(),
  hour: [value(hour())],
  minute: [value(minute())],
  month: [value(month())],
  on_ambiguity: [ambiguity_opt()],
  reboot: boolean(),
  second: [value(second())],
  weekday: [value(weekday())],
  year: [value(year())]
}
```

# `time_unit`

> This type is deprecated. Use Calendar.[second|minute|hour|day|month|day_of_week|year]/0 instead.

```elixir
@type time_unit() ::
  second() | minute() | hour() | day() | month() | weekday() | year()
```

# `value`

```elixir
@type value() ::
  value(Calendar.second())
  | value(Calendar.minute())
  | value(Calendar.hour())
  | value(Calendar.day())
  | value(Calendar.month())
  | value(Calendar.day_of_week())
  | value(Calendar.year())
```

# `value`

```elixir
@type value(time_unit) ::
  time_unit
  | :*
  | :L
  | {:L, value(time_unit)}
  | {:/, time_unit | :* | min_max(time_unit), pos_integer()}
  | min_max(time_unit)
  | {:W, time_unit | :L}
  | {:&quot;#&quot;, time_unit, pos_integer()}
```

# `weekday`

> This type is deprecated. Use Calendar.day_of_week/0 instead.

```elixir
@type weekday() :: Calendar.day_of_week()
```

# `year`

> This type is deprecated. Use Calendar.year/0 instead.

```elixir
@type year() :: Calendar.year()
```

# `__struct__`
*struct* 

Defines the Cron interval.

    * * * * * * *
    | | | | | | |
    | | | | | | +-- :year Year                 (range: 1900-3000)
    | | | | | +---- :weekday Day of the Week   (range: 1-7, 1 standing for Monday)
    | | | | +------ :month Month of the Year   (range: 1-12)
    | | | +-------- :day Day of the Month      (range: 1-31)
    | | +---------- :hour Hour                 (range: 0-23)
    | +------------ :minute Minute             (range: 0-59)
    +-------------- :second Second             (range: 0-59)

The `:extended` attribute defines if the second is taken into account.
When using localized DateTime, the `:on_ambiguity` attribute defines
whether the scheduler should return the prior or subsequent time when
the next run DateTime is ambiguous. `:on_ambiguity` defaults to `[]`
which means run DateTimes that fall within the ambiguous times would
be skipped. To run on both, set it as `[:prior, :subsequent]`.

# `sigil_e`

```elixir
@spec sigil_e(binary(), charlist()) :: t()
```

Create a `%Crontab.CronExpression{}` via sigil.

## Examples

    iex> ~e[*]
    %Crontab.CronExpression{
      extended: false,
      on_ambiguity: [],
      second: [:*],
      minute: [:*],
      hour: [:*],
      day: [:*],
      month: [:*],
      weekday: [:*],
      year: [:*]
    }

    iex> ~e[*]ep
    %Crontab.CronExpression{
      extended: true,
      on_ambiguity: [:prior],
      second: [:*],
      minute: [:*],
      hour: [:*],
      day: [:*],
      month: [:*],
      weekday: [:*],
      year: [:*]
    }

    iex> ~e[1 2 3 4 5 6 7]eps
    %Crontab.CronExpression{
      extended: true,
      on_ambiguity: [:prior, :subsequent],
      second: [1],
      minute: [2],
      hour: [3],
      day: [4],
      month: [5],
      weekday: [6],
      year: [7]
    }

    iex> ~e[1 2 3 4 5 6 7]e
    %Crontab.CronExpression{
      extended: true,
      on_ambiguity: [],
      second: [1],
      minute: [2],
      hour: [3],
      day: [4],
      month: [5],
      weekday: [6],
      year: [7]
    }

# `to_condition_list`

```elixir
@spec to_condition_list(t()) :: condition_list()
```

Convert `Crontab.CronExpression` struct to tuple List.

## Examples

    iex> Crontab.CronExpression.to_condition_list(%Crontab.CronExpression{
    ...>   minute: [1],
    ...>   hour: [2],
    ...>   day: [3],
    ...>   month: [4],
    ...>   weekday: [5],
    ...>   year: [6]
    ...> })
    [
      {:minute, [1]},
      {:hour, [2]},
      {:day, [3]},
      {:month, [4]},
      {:weekday, [5]},
      {:year, [6]},
      {:ambiguity_opts, []}
    ]

    iex> Crontab.CronExpression.to_condition_list(%Crontab.CronExpression{
    ...>   extended: true,
    ...>   second: [0],
    ...>   minute: [1],
    ...>   hour: [2],
    ...>   day: [3],
    ...>   month: [4],
    ...>   weekday: [5],
    ...>   year: [6]
    ...> })
    [
      {:second, [0]},
      {:minute, [1]},
      {:hour, [2]},
      {:day, [3]},
      {:month, [4]},
      {:weekday, [5]},
      {:year, [6]},
      {:ambiguity_opts, []}
    ]

---

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