]> vault307.fbx.one Git - RPI-PICO-I2C-LCD.git/commitdiff
Merge pull request #4 from janosrusiczki/patch-1
authorTyler Peppy <61562476+T-622@users.noreply.github.com>
Sat, 6 Mar 2021 20:31:30 +0000 (15:31 -0500)
committerGitHub <noreply@github.com>
Sat, 6 Mar 2021 20:31:30 +0000 (15:31 -0500)
Better date / time formatting

pico_i2c_lcd_test.py

index 89e2d96cad40d835d51e9064fdbed99f53d0b5cf..34fd9ffd82e708518206ffe96a7df81f78250709 100644 (file)
@@ -21,9 +21,9 @@ def test_main():
     while True:\r
         lcd.clear()\r
         time = utime.localtime()\r
-        lcd.putstr("{year}/{month}/{day} {HH}:{MM}:{SS}".format(\r
-            year=str(time[0]), month=str(time[1]), day=str(time[2]),\r
-            HH=str(time[3]), MM=str(time[4]), SS=str(time[5])))\r
+        lcd.putstr("{year:>04d}/{month:>02d}/{day:>02d} {HH:>02d}:{MM:>02d}:{SS:>02d}".format(\r
+            year=time[0], month=time[1], day=time[2],\r
+            HH=time[3], MM=time[4], SS=time[5]))\r
         if count % 10 == 0:\r
             print("Turning cursor on")\r
             lcd.show_cursor()\r