Created
September 12, 2014 23:30
-
-
Save agrafix/2b48ec069693e3ab851e to your computer and use it in GitHub Desktop.
Haskell UTCTime Arbitrary instance
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 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yoink!