diff --git a/examples/date-diff.py b/examples/date-diff.py index 470e002..950503a 100644 --- a/examples/date-diff.py +++ b/examples/date-diff.py @@ -13,7 +13,6 @@ import time from PIL import Image,ImageDraw,ImageFont import traceback - logging.basicConfig(level=logging.DEBUG) #Define Display @@ -63,12 +62,12 @@ def init_monitor(): # Drawing on the Horizontal image logging.info("1.Drawing on the Horizontal image...") - drawblack.text((4, 0), 'Noch: ' + str(duration.days), font = font16, fill = 0) - drawblack.text((4, 16), 'Oder: ' + str(duration.seconds), font = font16, fill = 0) - drawblack.text((4, 32), ' ', font = font16, fill = 0) - drawblack.text((4, 48), ' ', font = font16, fill = 0) - drawblack.text((4, 64), ' ', font = font16, fill = 0) - drawblack.text((4, 80), str(ruhestand.strftime("%A %B %d.%m.%Y")), font = font16, fill = 0) + drawblack.text((4, 0), 'Lieber Reinhold, auf dich warten noch: ' + str(duration.days) + " Tage", font = font16, fill = 0) + drawblack.text((4, 16), 'Oder ' + str(round(duration.days / 7,3)) + " Wochen", font = font16, fill = 0) + drawblack.text((4, 32), 'Oder ', + str(round(duration.days / 30,3)) + " Monate", font = font16, fill = 0) + drawblack.text((4, 48), 'Oder ', + str(duration.days * 24) + " Stunden", font = font16, fill = 0) + drawblack.text((4, 64), 'Oder ', + str(duration.days / 365) + " Jahre", font = font16, fill = 0) + drawblack.text((4, 80), "Bis du am " + str(ruhestand.strftime("%A %B %d.%m.%Y")), font = font16, fill = 0) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) diff --git a/examples/time-diff.py b/examples/time-diff.py index e69de29..6443915 100644 --- a/examples/time-diff.py +++ b/examples/time-diff.py @@ -0,0 +1,21 @@ +import time +import datetime +import locale + +loc = locale.getlocale() +print (loc) + +from datetime import datetime, timedelta, date +# Zwei datetime-Objekte erstellen +# from datetime import date + +start_time = date.today() +print(start_time.strftime("%d.%m.%Y")) +ruhestand = date(2025, 6, 10) +# Zeitdelta berechnen +duration = ruhestand - start_time +print("Tage: " + str(duration.days)) +print("Wochen: " + str(round(duration.days / 7,3))) +print("Monate: " + str(round(duration.days / 30,3))) +print("Jahre: " + str(round(duration.days / 365,3))) +print("Stunden: " + str(duration.days *24)) \ No newline at end of file