-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
wontfixThis will not be worked onThis will not be worked on
Description
Pre-Checks
- Follow our Code of Conduct.
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Faker issue and not related to a combination with another package.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
- I am willing to provide a PR.
Describe the bug
When creating a random date without a refDate and with a seed, the time of the date still changes randomly.
Minimal reproduction code
import { base, de, en, Faker } from "@faker-js/faker";
const faker1 = new Faker({ locale: [de, en, base], seed: 1 });
const faker2 = new Faker({ locale: [de, en, base], seed: 1 });
console.log(faker1.date.past());
setTimeout(() => console.log(faker2.date.past()), 1_000);
// Times of dates will be different by roughly one second
Additional Context
This is I think because past just gets the time from refDate which is set to now by default:
Line 35 in 549d71c
| get defaultRefDate(): () => Date { |
Environment Info
System:
OS: macOS 15.4.1
CPU: (10) arm64 Apple M1 Max
Memory: 10.81 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.15.0 - ~/.nvm/versions/node/v22.15.0/bin/node
npm: 10.9.2 - ~/.nvm/versions/node/v22.15.0/bin/npm
pnpm: 10.8.1 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 136.0.7103.114Which module system do you use?
- CJS
- ESM
Used Package Manager
pnpm
Metadata
Metadata
Assignees
Labels
wontfixThis will not be worked onThis will not be worked on