-
-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
faker.date.future should include a min parameter #2397
Comments
Thank you for your feature proposal. We marked it as "waiting for user interest" for now to gather some feedback from our community:
We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements. We will start the implementation based on:
We do this because:
|
You should pass the |
What about passing a refDate 5 years in the future? |
What's the point of faker then? Faker actually do some math for the future method, like:
` const fromMs = toDate(from, this.faker.defaultRefDate).getTime();
|
The deterministic generation of data |
as referenced before on my edit, faker have some calculations. `const range = {
The min value is set as constant, in milliseconds. My suggestion is offer a optional parameter for this, if not present use the constant Add the min parameter only will not change the goal of faker, and it is not that a big deal either in my opinion |
@tecsobs Could you please describe/draft the API you would expect from/would like to have for the |
Logically if this was added there would need to be equivalent paramters for recent(), past() , soon(), and future() as they are symmetrical. |
The current date API is easy to get wrong. E.g. How about: type DateOffsetOptions = {
years?: number
months?: number
days?: number
weeks?: number
hours?: number
...
}
faker.date.after(options?: DateOffsetOptions): Date
faker.date.before(options?: DateOffsetOptions): Date |
@xpol How about a relativeBetween({ refDate?: Date, startOffset: { years?, months?, days?, hours?, minutes?, seconds?, millis? }, endOffset: {...}) where the offset values can be both positive or negative e.g. relativeBetween({startOffset: { days: 2 }, endOffset: { years: 1, days: -1}) // Returns a Date that is 2-364 days into the future
relativeBetween({startOffset: { days: -2 }, endOffset: { days: 2 }) // Returns a Date that is up to 2 days in the past or future (or maybe just |
Clear and concise description of the problem
Right now there is no way to fake a date that is at least 5 years in the future for example.
The param years works as a range between 1 and the value specified.
Suggested solution
Create a new min param, optional, that allow to create a new date in the future with at least "min" years
Alternative
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: