Skip to content

Instantly share code, notes, and snippets.

@LeifW
Created January 26, 2015 23:05
Show Gist options
  • Select an option

  • Save LeifW/035caa291c5b5bc1ccc4 to your computer and use it in GitHub Desktop.

Select an option

Save LeifW/035caa291c5b5bc1ccc4 to your computer and use it in GitHub Desktop.
val dateGen: Gen[DateTime] = for {
year <- Gen.choose(2014, 2015)
month <- Gen.choose(1, 12)
day <- Gen.choose(1, month match {
case 2 => 28
case 4 | 6 | 9 | 11 => 30
case _ => 31
})
hour <- Gen.choose(0, 23)
minute <- Gen.choose(0, 59)
second <- Gen.choose(0, 59)
} yield DateTime(year, month, day, hour, minute, second)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment