修正时间显示(+0前缀)

This commit is contained in:
Easy 2022-04-07 23:41:53 +08:00
parent 4fbf408eae
commit 0808c2257c
2 changed files with 6 additions and 2 deletions

View File

@ -140,7 +140,9 @@ void loop() {
void show_time(bool force)
{
timeClient.update();
newTime = String(timeClient.getHours()) + ':' + String(timeClient.getMinutes()) ;
String hourStr = timeClient.getHours() < 10 ? "0" + String(timeClient.getHours()) : String(timeClient.getHours());
String minStr = timeClient.getMinutes() < 10 ? "0" + String(timeClient.getMinutes()) : String(timeClient.getMinutes());
newTime = hourStr + ":" + minStr ;
if( lastTime != newTime )
{
echo_time( newTime );

View File

@ -324,7 +324,9 @@ void clear_config()
void show_time(bool force)
{
timeClient.update();
newTime = String(timeClient.getHours()) + ':' + String(timeClient.getMinutes()) ;
String hourStr = timeClient.getHours() < 10 ? "0" + String(timeClient.getHours()) : String(timeClient.getHours());
String minStr = timeClient.getMinutes() < 10 ? "0" + String(timeClient.getMinutes()) : String(timeClient.getMinutes());
newTime = hourStr + ":" + minStr ;
if( lastTime != newTime )
{
echo_time( newTime );