Add `Temporal` support to functions that accept `Date`
Clear and concise description of the problem
I'm testing out using Temporal instead of Date, and one of the pain points I found is vi.setSystemTime only accepting number | Date.
Suggested solution
Add Temporal as an option to functions that accept Date. The one I encountered was vi.setSystemTime
Alternative
As a workaround, you can convert a PlainDate[Time] to a ZonedDateTime or Instant and get the epoch time from that:
vi.setSystemTime(
Temporal.PlainDateTime.from("2022-02-02 12:00").toZonedDateTime("utc")
.epochMilliseconds,
)Additional context
Some Temporal support was added in #8007 but that could be achieved without having to use the Temporal global, which I think this feature would require.
For example, (I believe) to support PlainDate in vi.setSystemTime one would have to convert it to a ZonedDatetime to get .epochMilliseconds, which might require using Temporal.Now.timeZoneId() unless you would default to "UTC".
// or "UTC"?
plainDate.toZonedDateTime(Temporal.Now.timeZoneId()).epochMillisecondsTo support this one would probably have to use temporal-polyfill in some way until V8 implements Temporal (https://github.com/nodejs/node/issues/57127#issuecomment-2762978399, https://github.com/nodejs/node/pull/57128).
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Source: vitest-dev/vitest