Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e6353bd

Browse filesBrowse files
joyeecheungBridgeAR
authored andcommitted
fs: document the Date conversion in Stats objects
Document why the dates are calculated with the timestamp in Numbers + 0.5. The comment was previously lost in a revert. Refs: ae6c704 PR-URL: #28224 Refs: ae6c704 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 365e062 commit e6353bd
Copy full SHA for e6353bd

File tree

Expand file treeCollapse file tree

1 file changed

+6
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/fs/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/utils.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ function nsFromTimeSpecBigInt(sec, nsec) {
287287
return sec * kNsPerSecBigInt + nsec;
288288
}
289289

290+
// The Date constructor performs Math.floor() to the timestamp.
291+
// https://www.ecma-international.org/ecma-262/#sec-timeclip
292+
// Since there may be a precision loss when the timestamp is
293+
// converted to a floating point number, we manually round
294+
// the timestamp here before passing it to Date().
295+
// Refs: https://github.com/nodejs/node/pull/12607
290296
function dateFromMs(ms) {
291297
return new Date(Number(ms) + 0.5);
292298
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.