Skip to content

Added zero-padding to timestamp output #40095

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

Merged
merged 4 commits into from
Sep 12, 2020
Merged

Conversation

rhillefeld
Copy link
Contributor

Fixes #31272
Fixed the output of nowString() to properly zero-pad individual timestamp components (hours, minutes, seconds, milliseconds). This affects the log output of tsserver.

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Aug 17, 2020
@sandersn
Copy link
Member

sandersn commented Sep 4, 2020

The code looks fine to me, but @sheetalkamat @amcasey or @uniqueiniquity will know what the ramifications of changing the format are.

Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the concept, but please extract a function. Consider mimicking/unifying with padLeft.

…gs other than a single space as padding.

Used this new functionality to zero-pad the timestamp created by nowString().
@ghost
Copy link

ghost commented Sep 11, 2020

CLA assistant check
All CLA requirements met.

@rhillefeld
Copy link
Contributor Author

Thank you for your feedback. I didn't realize those functions existed already and I'm a fan of unifying similar capabilities where it makes sense. With this update, we can pad using any string, similar to padStart() and padEnd() in JS.

Even though the original bug didn't need it, I also updated padRight() for consistency. Most of the code is obviously the same as padLeft() but I thought refactoring out just those few lines in common was overkill for this case.

I'd like to test this further but wanted your feedback on this change before I spend too much time doing that...

@rhillefeld rhillefeld requested a review from amcasey September 11, 2020 19:47
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! One more suggestion, but looks good.

…ted padRight() to mirror padLeft() but without the option to use zeros since that would be an unlikely use case.
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for the changes.

@amcasey
Copy link
Member

amcasey commented Sep 12, 2020

@rhillefeld Happy to merge if you're done.

@rhillefeld
Copy link
Contributor Author

@amcasey yes, that should do it. Thanks!

@amcasey amcasey merged commit 46506b5 into microsoft:master Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

tsserver log timestamps are not properly zero-padded
5 participants