From 348d6dd2f3a966ccd23c39319ea416c550f3abd7 Mon Sep 17 00:00:00 2001 From: Borzutzki Robert Date: Mon, 25 Nov 2024 22:24:39 +0100 Subject: [PATCH] change file name --- examples/solar-monitoring.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/solar-monitoring.py b/examples/solar-monitoring.py index 4cc754e..69e2e6f 100644 --- a/examples/solar-monitoring.py +++ b/examples/solar-monitoring.py @@ -44,15 +44,13 @@ import locale loc = locale.getlocale() print (loc) -datum = input('Datum: ') -td = datetime.timedelta(int(input('Abstand: '))) -datum1 = time.strptime(datum, '%Y-%m-%d') -datum2 = (datetime.datetime.fromtimestamp(time.mktime(datum1)) - td) -print(datum2.strftime('%Y-%m-%d')) - -print(datum2.strftime('Der Wochentag ist %A')) -locale.setlocale(locale.LC_ALL, ('de_DE', 'UTF-8')) -print(datum2.strftime('Der Wochentag ist %A')) +from datetime import datetime, timedelta +# Zwei datetime-Objekte erstellen +start_time = datetime(2024, 6, 1, 0, 0, 0) +end_time = datetime(2024, 6, 10, 0, 0, 0) +# Zeitdelta berechnen +duration = end_time - start_time +print(duration) # Ausgabe: 9 Tage, 2:30:00 def init_monitor(topics):