Skip to content

Instantly share code, notes, and snippets.

@wildbillcat
Created January 30, 2019 21:59
Show Gist options
  • Save wildbillcat/60fc50b872be9e34c7d3aed54f4e3ec7 to your computer and use it in GitHub Desktop.
Save wildbillcat/60fc50b872be9e34c7d3aed54f4e3ec7 to your computer and use it in GitHub Desktop.
F# Test for Weekend
//Function
let DayOfWeekIs (days:DayOfWeek list) =
let today = DateTime.Now
List.exists (fun dow -> dow == today.DayOfWeek) days
//Function Use
DayOfWeekIs([DayOfWeek.Saturday; DayOfWeek.Sunday])
//Function (hours 0-23)
let TimeIsEqualOrAfterHour (hour:int) =
DateTime.Now.hour >= hour
//Function (hours 0-23)
let TimeIsBeforeHour (hour:int) =
DateTime.Now.hour < hour
//Function use before 3pm
TimeIsBeforeHour(14)
//Function use at or after 3pm
TimeIsEqualOrAfterHour(15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment