elm-test icon indicating copy to clipboard operation
elm-test copied to clipboard

Fuzzer.date

Open joshhornby opened this issue 8 years ago • 1 comments

After looking through the docs I was surprised to not find a fuzzer for dates.

After asking on Slack @zwilias said:

You could potentially do something like fuzzing a float in a certain range and doing map Date.fromTime on that you'd have to figure out what sort of granularity and range you want, though

I think it would be nice to have a date fuzzer in this package, so opening an issue for further discussions

joshhornby avatar Nov 17 '17 11:11 joshhornby

Here are some possible implementations (untested):

import Fuzz exposing (..)
import Date exposing (Date)
import Time exposing (Time)


time : Fuzzer Time
time =
    map ((*) Time.second) <| Fuzz.floatRange 0 2524608000


date : Fuzzer Date
date =
    map Date.fromTime time

liamcurry avatar Dec 06 '17 16:12 liamcurry