@js-temporal/polyfill
Version:
Polyfill for Tc39 Stage 3 proposal Temporal (https://github.com/tc39/proposal-temporal)
12 lines (9 loc) • 385 B
text/typescript
import { Instant } from './instant';
import JSBI from 'jsbi';
import * as ES from './ecmascript';
import { MILLION } from './ecmascript';
export function toTemporalInstant(this: Date) {
// Observable access to valueOf is not correct here, but unavoidable
const epochNanoseconds = JSBI.multiply(JSBI.BigInt(+this), MILLION);
return new Instant(ES.ToBigInt(epochNanoseconds));
}