Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Haskell UTCTime Arbitrary instance
import Data.Time
instance Arbitrary UTCTime where
arbitrary =
do randomDay <- choose (1, 29) :: Gen Int
randomMonth <- choose (1, 12) :: Gen Int
randomYear <- choose (2001, 2002) :: Gen Integer
randomTime <- choose (0, 86401) :: Gen Int
return $ UTCTime (fromGregorian randomYear randomMonth randomDay) (fromIntegral randomTime)
@runeksvendsen
Copy link

runeksvendsen commented Nov 25, 2016

Yoink!

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