mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-19 00:31:06 +00:00
Squashed 'engine262/' content from commit ae71998
git-subtree-dir: engine262 git-subtree-split: ae71998cc5a8315700555135b1ac202a0d6d0b31
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import type { ISODateTimeRecord } from '../../intrinsics/Temporal/PlainDateTime.mts';
|
||||
import { SystemTimeZoneIdentifier } from './addition.mts';
|
||||
import { temporal_todo } from './not-implemented.mts';
|
||||
import {
|
||||
ObjectValue, GetGlobalObject, Value, type PlainCompletion, Q, ToTemporalTimeZoneIdentifier, GetISODateTimeFor,
|
||||
} from '#self';
|
||||
|
||||
/** https://tc39.es/proposal-temporal/#sec-hostsystemutcepochnanoseconds */
|
||||
export function HostSystemUTCEpochNanoseconds(_global: ObjectValue): number {
|
||||
temporal_todo();
|
||||
}
|
||||
|
||||
/** https://tc39.es/proposal-temporal/#sec-temporal-systemutcepochmilliseconds */
|
||||
export function SystemUTCEpochMilliseconds(): number {
|
||||
const global = GetGlobalObject();
|
||||
const nowNs = HostSystemUTCEpochNanoseconds(global);
|
||||
return Math.floor(nowNs / (10 ** 6));
|
||||
}
|
||||
|
||||
/** https://tc39.es/proposal-temporal/#sec-temporal-systemutcepochnanoseconds */
|
||||
export function SystemUTCEpochNanoseconds(): bigint {
|
||||
const global = GetGlobalObject();
|
||||
const nowNs = HostSystemUTCEpochNanoseconds(global);
|
||||
return BigInt(nowNs);
|
||||
}
|
||||
|
||||
/** https://tc39.es/proposal-temporal/#sec-temporal-systemdatetime */
|
||||
export function SystemDateTime(temporalTimeZoneLike: Value): PlainCompletion<ISODateTimeRecord> {
|
||||
let timeZone;
|
||||
if (temporalTimeZoneLike === Value.undefined) {
|
||||
timeZone = SystemTimeZoneIdentifier();
|
||||
} else {
|
||||
timeZone = Q(ToTemporalTimeZoneIdentifier(temporalTimeZoneLike));
|
||||
}
|
||||
const epochNs = SystemUTCEpochNanoseconds();
|
||||
return GetISODateTimeFor(timeZone, epochNs);
|
||||
}
|
||||
Reference in New Issue
Block a user