-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
console: update time formatting #29629
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,11 @@ require('../common'); | |
const { formatTime } = require('internal/console/constructor'); | ||
const assert = require('assert'); | ||
|
||
const test1 = formatTime(100); | ||
const test2 = formatTime(1500); | ||
const test3 = formatTime(60300); | ||
const test4 = formatTime(4000000); | ||
|
||
assert.strictEqual(test1, '100.000ms'); | ||
assert.strictEqual(test2, '1.500s'); | ||
assert.strictEqual(test3, '1.005min'); | ||
assert.strictEqual(test4, '1.111h'); | ||
assert.strictEqual(formatTime(100.0096), '100.01ms'); | ||
assert.strictEqual(formatTime(100.0115), '100.011ms'); | ||
assert.strictEqual(formatTime(1500.04), '1.500s'); | ||
assert.strictEqual(formatTime(1000.056), '1.000s'); | ||
assert.strictEqual(formatTime(60300.3), '1:00.300 (m:ss.mmm)'); | ||
assert.strictEqual(formatTime(4000457.4), '1:06:40.457 (h:mm:ss.mmm)'); | ||
assert.strictEqual(formatTime(3601310.4), '1:00:01.310 (h:mm:ss.mmm)'); | ||
assert.strictEqual(formatTime(3213601017.6), '892:40:01.018 (h:mm:ss.mmm)'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so we're outputting the literal string "hh:mm:as.mmm"? i think this format is standard enough that we don't have to do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess most people will know about it but I added it to leave no doubt. I would like to support people who are not yet that experienced as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep these consistent with the higher numbers, to be honest...
e.g.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seconds and milliseconds are the most common ones. People will rarely reach the higher values and it seems more straight forward to me to keep
s
andms
as common cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I understand the reasoning, I just disagree :) I'd rather opt for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to remove the
author ready
label out of caution while this gets sorted, but feel free to re-add it if that's overly-cautious of me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasnell is your comment blocking? I would rather close this PR than changing the common cases (even though I believe that this PR does improve the overall output).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking but I definitely don't consider the inconsistency to be ideal.