# CronOptionsWithTimezone

Options to configure a cron expression.

All fields are strings so you can use complex expressions. Absence of
a field implies '*' or '?', whichever one is appropriate.

Extends: [CronOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_events.CronOptions.html)
Used as argument in: [ScheduleExpression.cron](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_scheduler.ScheduleExpression.html#cron)

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

## Example

TypeScript:

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

const rateBasedSchedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.rate(Duration.minutes(10)),
    target,
    description: 'This is a test rate-based schedule',
});

const cronBasedSchedule = new Schedule(this, 'Schedule', {
    schedule: ScheduleExpression.cron({
        minute: '0',
        hour: '23',
        day: '20',
        month: '11',
        timeZone: TimeZone.AMERICA_NEW_YORK,
    }),
    target,
    description: 'This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone',
});
```

Python:

```python
# target: targets.LambdaInvoke

rate_based_schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.rate(Duration.minutes(10)),
    target=target,
    description="This is a test rate-based schedule"
)

cron_based_schedule = Schedule(self, "Schedule",
    schedule=ScheduleExpression.cron(
        minute="0",
        hour="23",
        day="20",
        month="11",
        time_zone=TimeZone.AMERICA_NEW_YORK
    ),
    target=target,
    description="This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone"
)
```

Java:

```java
LambdaInvoke target;

Schedule rateBasedSchedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.rate(Duration.minutes(10)))
        .target(target)
        .description("This is a test rate-based schedule")
        .build();

Schedule cronBasedSchedule = Schedule.Builder.create(this, "Schedule")
        .schedule(ScheduleExpression.cron(CronOptionsWithTimezone.builder()
                .minute("0")
                .hour("23")
                .day("20")
                .month("11")
                .timeZone(TimeZone.AMERICA_NEW_YORK)
                .build()))
        .target(target)
        .description("This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone")
        .build();
```

C# / .NET:

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

var rateBasedSchedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Rate(Duration.Minutes(10)),
    Target = target,
    Description = "This is a test rate-based schedule"
});

var cronBasedSchedule = new Schedule(this, "Schedule", new ScheduleProps {
    Schedule = ScheduleExpression.Cron(new CronOptionsWithTimezone {
        Minute = "0",
        Hour = "23",
        Day = "20",
        Month = "11",
        TimeZone = TimeZone.AMERICA_NEW_YORK
    }),
    Target = target,
    Description = "This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone"
});
```

Golang:

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

rateBasedSchedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Rate(awscdk.Duration_Minutes(jsii.Number(10))),
	Target: Target,
	Description: jsii.String("This is a test rate-based schedule"),
})

cronBasedSchedule := awscdk.NewSchedule(this, jsii.String("Schedule"), &ScheduleProps{
	Schedule: awscdk.ScheduleExpression_Cron(&CronOptionsWithTimezone{
		Minute: jsii.String("0"),
		Hour: jsii.String("23"),
		Day: jsii.String("20"),
		Month: jsii.String("11"),
		TimeZone: awscdk.TimeZone_AMERICA_NEW_YORK(),
	}),
	Target: Target,
	Description: jsii.String("This is a test cron-based schedule that will run at 11:00 PM, on day 20 of the month, only in November in New York timezone"),
})
```

## Properties

- `day`: string — The day of the month to run this rule at.

  **Default:** Every day of the month

- `hour`: string — The hour to run this rule at.

  **Default:** Every hour

- `minute`: string — The minute to run this rule at.

  **Default:** Every minute

- `month`: string — The month to run this rule at.

  **Default:** Every month

- `timeZone`: [TimeZone](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.TimeZone.html) = TimeZone.ETC_UTC — The timezone to run the schedule in.

- `weekDay`: string — The day of the week to run this rule at.

  **Default:** Any day of the week

- `year`: string — The year to run this rule at.

  **Default:** Every year
