# Scheduler

### Overview

The **Scheduler Component** triggers jobs periodically at fixed times, dates, or intervals using cron syntax. It is useful for automating recurring tasks within a workflow.

### Usage

This component enables users to schedule execution times based on minutes, hours, days, and specific time zones. It supports immediate triggering when a flow starts.

#### Output Ports

| Port  | Description                                                    |
| ----- | -------------------------------------------------------------- |
| `out` | Emits scheduled timestamps based on the defined cron schedule. |

**Output Properties**

| Property       | Type     | Description                                          |
| -------------- | -------- | ---------------------------------------------------- |
| `previousDate` | `string` | The last scheduled execution time (ISO 8601 format). |
| `now`          | `string` | The current execution time (ISO 8601 format).        |
| `nextDate`     | `string` | The next scheduled execution time (ISO 8601 format). |

#### Properties

| Property    | Type      | Description                                                          |
| ----------- | --------- | -------------------------------------------------------------------- |
| `minute`    | `string`  | Cron expression for minutes (\*, -, /, 0-59, etc.).                  |
| `hour`      | `string`  | Cron expression for hours (\*, -, /, 0-23, etc.).                    |
| `dayMonth`  | `string`  | Cron expression for days of the month (\*, -, /, 1-31, etc.).        |
| `dayWeek`   | `string`  | Cron expression for days of the week (\*, -, /, 0-6, SUN-SAT, etc.). |
| `immediate` | `boolean` | If `true`, triggers execution immediately upon starting the flow.    |
| `timezone`  | `string`  | Timezone for scheduling (e.g., 'Europe/Prague', defaults to GMT).    |

#### Processing Logic

1. **Define Scheduling Rules**: The user sets up cron-like expressions to determine execution times.
2. **Trigger Execution**: The component schedules the task based on the defined rules.
3. **Generate Timestamps**: Outputs `previousDate`, `now`, and `nextDate` at execution time.

### Notes

* **Flexible Scheduling**: Supports standard cron expressions for precise scheduling.
* **Immediate Execution**: Can trigger immediately when a flow starts if `immediate` is set to `true`.
* **Timezone Support**: Users can specify a timezone for accurate scheduling across different regions.

This component is ideal for time-based automation, recurring task execution, and scheduling workflows efficiently.
