# TimeWindow

A time window during which EventBridge Scheduler invokes the schedule.

Obtainable from: TimeWindow.flexible, TimeWindow.off

- Source: [`aws-scheduler/lib/schedule.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-scheduler/lib/schedule.ts#L41)
- Type last changed: v2.186.0 · 27 Mar 2025

## Example

TypeScript:

```ts
declare const target: targets.LambdaInvoke;

const schedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(Duration.hours(12)),
    target,
    timeWindow: TimeWindow.flexible(Duration.hours(10)),
});
```

Python:

```python
# target: targets.LambdaInvoke

schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.hours(12)),
    target=target,
    time_window=TimeWindow.flexible(Duration.hours(10))
)
```

Java:

```java
LambdaInvoke target;

Schedule schedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.hours(12)))
        .target(target)
        .timeWindow(TimeWindow.flexible(Duration.hours(10)))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
LambdaInvoke target;

var schedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Hours(12)),
    Target = target,
    TimeWindow = TimeWindow.Flexible(Duration.Hours(10))
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var target LambdaInvoke

schedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Hours(jsii.Number(12))),
	Target: Target,
	TimeWindow: awscdk.TimeWindow_Flexible(awscdk.Duration_*Hours(jsii.Number(10))),
})
```

## Properties

- `maxWindow`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The maximum time window during which the schedule can be invoked.

  **Default:** no value

  Must be between 1 to 1440 minutes.

- `mode`: string — Determines whether the schedule is invoked within a flexible time window.

## Methods

- `flexible(maxWindow: Duration): TimeWindow // chainable` (static) — TimeWindow is enabled.

- `off(): TimeWindow // chainable` (static) — TimeWindow is disabled.
