PaulStoffregen / Time

Time library for Arduino
http://playground.arduino.cc/code/time
1.24k stars 664 forks source link

Suggestion: prepend single digit output with 0 #150

Closed leonbrag closed 4 years ago

leonbrag commented 4 years ago

Description

No problem, excellent library, thank you for sharing it. This is a suggestion.

If month, day, minute or second is a single digit please prepend with 0.

Steps To Reproduce Problem

Please give detailed instructions needed for anyone to attempt to reproduce the problem.

Run samples, code with the slight modification:

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(hour());
  Serial.print(":");
  Serial.print(minute());
  Serial.print(":");
  Serial.print(second());
  Serial.print(" ");
  Serial.print(day());
  Serial.print(" ");
  Serial.print(month());
  Serial.print(" ");
  Serial.print(year()); 
  Serial.println(); 
}

Observe output similar to this in the serial window:

22:32:05.663 -> 21:32:4 29 5 2020

Desired outcome:

21:32:04 29 05 2020

While this can be easily worked around in the code, it would be nice for library to have ability to produce such output.

Hardware & Software

n/a

Arduino Sketch

n/a - samples that comes with the library

Errors or Incorrect Output

n/a

leonbrag commented 4 years ago

My mistake. All values are returned as uint8_t.