Skip to content
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

Leading zeros are stripped from Serial Monitor timestamps #580

Closed
per1234 opened this issue Oct 28, 2021 · 6 comments · Fixed by #1413
Closed

Leading zeros are stripped from Serial Monitor timestamps #580

per1234 opened this issue Oct 28, 2021 · 6 comments · Fixed by #1413
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Oct 28, 2021

Describe the problem

🐛 The timestamps produced by the Serial Monitor have a non-standard format resulting from stripping the leading zeros from the hours and minutes.

🐛 This is not even done consistently as the leading zeros are preserved for seconds.

To Reproduce

Steps to reproduce the behavior:

  1. Upload a sketch to an Arduino board that periodically prints to the serial port. For example:
    void setup() {
      Serial.begin(9600);
    }
    void loop() {
      Serial.println("hello");
      delay(1000);
    }
  2. Select Tools > Serial Monitor from the Arduino IDE menus.
  3. Click the 🕙 icon ("Toggle Timestamp") that is near the top right corner of the output panel
  4. Wait for a time that contains a second less than 10.
  5. Look at the Serial Monitor output pane.
    🙂 Note that the leading zero on the second component of the time has not been removed.
  6. Wait for a time that contains a minute less than 10.
  7. Look at the Serial Monitor output pane.
    🐛 Note that the leading zero on the minute component of the time has been removed.
  8. Wait for a time that contains an hour less than 10.
  9. Look at the Serial Monitor output pane.
    🐛 Note that the leading zero on the hour component of the time has been removed.
23:59:58.610 -> hello
23:59:59.609 -> hello
0:0:00.620 -> hello
0:0:01.618 -> hello
0:0:02.630 -> hello

Expected behavior

Serial Monitor timestamps to be formatted the same as they were in the classic Arduino IDE:
hh:mm:ss.sss

00:05:02.590 -> hello

Arduino IDE version

Original report

2.0.0-beta.12-nightly.20211028

Last verified with

2.0.0-rc9-snapshot-5087ff0

Operating system

Windows 10

Additional context

Originally reported at:

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: serial monitor Related to the Serial Monitor labels Oct 28, 2021
@mklemarczyk
Copy link

It is still exists in 2.0.0-rc4.

image

@ubidefeo
Copy link

@per1234
do we still have this issue?

@per1234
Copy link
Contributor Author

per1234 commented Jul 25, 2022

@ubidefeo yes:

Leading zeros are still stripped from hours:
image

Leading zeros are still stripped from minutes:

image

21:9:29.101 -> hello
21:9:30.088 -> hello
21:9:31.104 -> hello

@nmzaheer
Copy link
Contributor

nmzaheer commented Sep 8, 2022

I think the relevant code affecting this is given here

const timestamp =
(data.timestamp &&
`${dateFormat(data.lines[index].timestamp, 'H:M:ss.l')} -> `) ||
'';

Can I go ahead and submit a PR changing it to

  const timestamp =
    (data.timestamp &&
      `${dateFormat(data.lines[index].timestamp, 'HH:MM:ss.l')} -> `) ||
    '';

@per1234
Copy link
Contributor Author

per1234 commented Sep 8, 2022

Can I go ahead and submit a PR

Hi @nmzaheer. Please do. I'll be happy to review it.

@nmzaheer
Copy link
Contributor

nmzaheer commented Sep 8, 2022

@per1234 I've tested it on Ubuntu through WSL with my Uno board and it works.

@per1234 per1234 assigned per1234 and unassigned fstasi Sep 8, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants