Skip to content

Commit 2a22bc3

Browse files
committed
Ensure SystemUTCEpochNanoseconds never throws
Times outside of a range of about half a million years cannot be represented by Temporal.Instant. Clamp the system time to that range so that the operation is guaranteed not to throw, which is editorially the cleanest solution. If your clock is 300,000 years off then Temporal is not the biggest problem you will have, so this is not expected to come up in practice. See: #1424
1 parent 8b61c1b commit 2a22bc3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/ecmascript.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4352,7 +4352,7 @@ export const ES = ObjectAssign({}, ES2020, {
43524352
const ms = Date.now();
43534353
const result = bigInt(ms).multiply(1e6).plus(ns);
43544354
ns = ms % 1e6;
4355-
return result;
4355+
return bigInt.min(NS_MAX, bigInt.max(NS_MIN, result));
43564356
};
43574357
})(),
43584358
SystemTimeZone: () => {

0 commit comments

Comments
 (0)