Last active
September 1, 2022 00:37
-
-
Save carljavier/4685fa530092805a039d002e2c697d34 to your computer and use it in GitHub Desktop.
Time Validate Sentinel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "time" | |
# Load Time | |
currentTime = time.now | |
# Validate time is between 10 AM and 6 PM AEST | |
valid_time = rule { (currentTime.hour >= 0 and currentTime.hour < 8)} | |
# Validate time is between 7am AM and 10 AM AEST | |
valid_time2 = rule { (currentTime.hour >= 21 and currentTime.hour <= 23)} | |
# Validate day is M - Th | |
valid_day = rule { | |
currentTime.weekday_name in ["Monday", "Tuesday", "Wednesday", "Thursday"] | |
} | |
main = rule { (valid_time or valid_time2) and valid_day } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "time" | |
# Load Time | |
currentTime = time.now | |
# Validate day is Monday - Friday | |
is_weekday = rule { | |
currentTime.weekday_name not in ["Saturday", "Sunday"] | |
} | |
# Validate time is between 10 AM and 6 PM AEST | |
is_open_hours_aest1 = rule { | |
(currentTime.hour >= 0 and time.now.hour <= 8) | |
} | |
# Validate time is between 7am AM and 10 AM AEST | |
is_open_hours_aest2 = rule { | |
(currentTime.hour >= 21 and time.now.hour <= 23) | |
} | |
main = rule { | |
(is_open_hours_aest1 or is_open_hours_aest2) and is_weekday | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment