Skip to content

Date comparisons with Rego #21

Discussion options

You must be logged in to vote

Answer taken from slack

package play

time_window_min := time.parse_rfc3339_ns("2019-10-22T12:00:00Z")
time_window_max := time.parse_rfc3339_ns("2022-10-22T13:00:00Z")

default allow = false

allow {
    inside_valid_time_window
}

inside_valid_time_window {
    current_time := time.now_ns()
    time_window_min <= current_time
    time_window_max >= current_time
}

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@scottc-WellSky
Comment options

@scottc-WellSky
Comment options

@srenatus
Comment options

@scottc-WellSky
Comment options

@srenatus
Comment options

Answer selected by peteroneilljr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment