From e2783229af9180c7ea31385b005773f35baf67c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1nos=20Rusiczki?= Date: Sat, 6 Mar 2021 22:19:02 +0200 Subject: [PATCH] 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`. --- pico_i2c_lcd_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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() -- 2.47.3