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):