You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Require `from` and `to` in `faker.date.between()` and `betweens()`
2
+
3
+
Previously, in `faker.date.between()` and `faker.date.betweens()` if the `from` or `to` parameter was omitted (in Javascript) or an invalid date (in Javascript or Typescript), they would default to the current date or reference date. Now, both boundaries must now be given explictly. If you still need the old behavior, you can pass `Date.now()` or the reference date for `from` or `to`.
'Must pass an options object with `from` and `to` values.'
258
+
);
259
+
}
239
260
261
+
const{ from, to, count =3}=options;
240
262
returnthis.faker.helpers
241
263
.multiple(()=>this.between({ from, to }),{ count })
242
264
.sort((a,b)=>a.getTime()-b.getTime());
@@ -433,6 +455,12 @@ export class SimpleDateModule extends SimpleModuleBase {
433
455
*
434
456
* For more control, any of these methods can be customized with further options, or use [`between()`](https://fakerjs.dev/api/date.html#between) to generate a single date between two dates, or [`betweens()`](https://fakerjs.dev/api/date.html#betweens) for multiple dates.
435
457
*
458
+
* Dates can be specified as Javascript Date objects, strings or UNIX timestamps.
459
+
* For example to generate a date between 1st January 2000 and now, use:
460
+
* ```ts
461
+
* faker.date.between({ from: '2000-01-01', to: Date.now() });
462
+
* ```
463
+
*
436
464
* You can generate random localized month and weekday names using [`month()`](https://fakerjs.dev/api/date.html#month) and [`weekday()`](https://fakerjs.dev/api/date.html#weekday).
437
465
*
438
466
* These methods have additional concerns about reproducibility, see [Reproducible Results](https://fakerjs.dev/guide/usage.html#reproducible-results).
0 commit comments