Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@agrafix
Created September 12, 2014 23:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agrafix/2b48ec069693e3ab851e to your computer and use it in GitHub Desktop.
Save agrafix/2b48ec069693e3ab851e to your computer and use it in GitHub Desktop.
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

Yoink!

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