DailyHoursStrategy

@Serializable
@SerialName(value = "dailyHours")
data class DailyHoursStrategy(val startHour: Int, val endHour: Int, val timezone: TimeZone = TimeZone.UTC, clock: Clock = Clock.System) : FlippingStrategy(source)

A strategy that enables a feature only during specific hours of the day.

The feature is enabled when the current hour (in the specified timezone) is within the range [startHour, endHour) (start inclusive, end exclusive).

This strategy is useful for:

  • Business hours availability (e.g., 9 AM to 5 PM)

  • Off-peak processing windows

  • Time-restricted features

See also

for day-of-week based enabling

for absolute time range enabling

Throws

if startHour is not in 0..23, endHour is not in 1..24, or endHour is not greater than startHour.

Constructors

Link copied to clipboard
constructor(startHour: Int, endHour: Int, timezone: TimeZone = TimeZone.UTC, clock: Clock = Clock.System)

Properties

Link copied to clipboard

The hour when the feature becomes disabled (1-24, inclusive).

Link copied to clipboard

The hour when the feature becomes enabled (0-23, inclusive).

Link copied to clipboard
val timezone: TimeZone

The timezone used to determine the current hour. Defaults to TimeZone.UTC.

Functions

Link copied to clipboard

Combines this strategy with other using logical AND.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open suspend override fun evaluate(featureId: String, store: FeatureStore?, context: FlippingExecutionContext): Boolean

Evaluates whether the feature should be enabled based on the execution context.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Negates this strategy.

Link copied to clipboard

Combines this strategy with other using logical OR.