boo1ean/casual

Feature request: Date in range

Opened this issue · 4 comments

I would like to be able to generate a casual.unix_time that is between a certain range of dates.

Many thanks for a great module.

Does anyone have a workaround solution for this?

Not sure why I didn't think of this before, but just had a look at the source code, and it just uses casual.integer:

return this.integer(0, 1462369607);

so you can use that with your desired range

I see, thanks for finding that! I was actually referring to casual.date but I see that just calls moment so I can call it directly. Still would be nice to have a convenience method for readability.

Are there any updates?
I need to generate random dates at a given range.

A very common use case would be to generate random createdAt and endedAt dates which adhere to the following condition: createdAt < endedAt.

It would be nice to have an API for date generator with custom range since I believe this is a very common use case.