diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 6cd6f7aceb2848..24d946edf7288a 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -286,6 +286,12 @@ function nsFromTimeSpecBigInt(sec, nsec) { return sec * kNsPerSecBigInt + nsec; } +// The Date constructor performs Math.floor() to the timestamp. +// https://www.ecma-international.org/ecma-262/#sec-timeclip +// Since there may be a precision loss when the timestamp is +// converted to a floating point number, we manually round +// the timestamp here before passing it to Date(). +// Refs: https://github.com/nodejs/node/pull/12607 function dateFromMs(ms) { return new Date(Number(ms) + 0.5); }