dateRangeStrategy

fun FeatureBuilder.dateRangeStrategy(startDate: Instant, endDate: Instant)(source)

Configures a DateRangeStrategy for this feature using Instant values.

The feature will be enabled only when the current time is within the specified range: [startDate, endDate) (start inclusive, end exclusive).

Example

feature("holiday-sale") {
dateRangeStrategy(
startDate = Instant.parse("2025-12-20T00:00:00Z"),
endDate = Instant.parse("2025-12-26T00:00:00Z")
)
}

Author

Yonatan Karp-Rudin

Parameters

startDate

The instant from which the feature becomes enabled (inclusive).

endDate

The instant at which the feature becomes disabled (exclusive).

See also

for enabling a feature after a single date


Configures a DateRangeStrategy for this feature using ISO-8601 date strings.

The feature will be enabled only when the current time is within the specified range: [startDate, endDate) (start inclusive, end exclusive).

Example

feature("holiday-sale") {
dateRangeStrategy(
startDate = "2025-12-20T00:00:00Z",
endDate = "2025-12-26T00:00:00Z"
)
}

Author

Yonatan Karp-Rudin

Parameters

startDate

The start date in ISO-8601 format (e.g., "2025-01-01T00:00:00Z").

endDate

The end date in ISO-8601 format (e.g., "2025-01-31T23:59:59Z").

See also

for enabling a feature after a single date

Throws

if either date string is not valid ISO-8601 format.


fun FeatureBuilder.dateRangeStrategy(startDate: LocalDateTime, endDate: LocalDateTime, timezone: TimeZone = TimeZone.UTC)(source)

Configures a DateRangeStrategy for this feature using LocalDateTime values and timezone.

The feature will be enabled only when the current time is within the specified range: [startDate, endDate) (start inclusive, end exclusive).

Example

feature("holiday-sale") {
dateRangeStrategy(
startDate = LocalDateTime(2025, 12, 20, 0, 0),
endDate = LocalDateTime(2025, 12, 26, 0, 0),
timezone = TimeZone.of("America/New_York")
)
}

Author

Yonatan Karp-Rudin

Parameters

startDate

The local date and time when the feature becomes enabled.

endDate

The local date and time when the feature becomes disabled.

timezone

The timezone to interpret the local date times. Defaults to UTC.

See also

for enabling a feature after a single date