From: János Rusiczki Date: Sat, 6 Mar 2021 20:19:02 +0000 (+0200) Subject: Better date / time formatting X-Git-Url: https://vault307.fbx.one/gitweb/RPI-PICO-I2C-LCD.git/commitdiff_plain/e2783229af9180c7ea31385b005773f35baf67c1?ds=sidebyside;hp=990c4d52c4fb2d312d425ba15c88012533034e1a Better date / time formatting Many thanks for putting together this library / short tutorial. It got me kickstarted with using a 20x4 LCD with my Pico. Here's some giving back, instead of writing: `2021/3/6 3:8:2` it will write `2021/03/06 03:08:02`. --- diff --git a/pico_i2c_lcd_test.py b/pico_i2c_lcd_test.py index 89e2d96..34fd9ff 100644 --- a/pico_i2c_lcd_test.py +++ b/pico_i2c_lcd_test.py @@ -21,9 +21,9 @@ def test_main(): while True: lcd.clear() time = utime.localtime() - lcd.putstr("{year}/{month}/{day} {HH}:{MM}:{SS}".format( - year=str(time[0]), month=str(time[1]), day=str(time[2]), - HH=str(time[3]), MM=str(time[4]), SS=str(time[5]))) + lcd.putstr("{year:>04d}/{month:>02d}/{day:>02d} {HH:>02d}:{MM:>02d}:{SS:>02d}".format( + year=time[0], month=time[1], day=time[2], + HH=time[3], MM=time[4], SS=time[5])) if count % 10 == 0: print("Turning cursor on") lcd.show_cursor()