Local changes

This commit is contained in:
2025-07-22 17:06:57 +02:00
parent 30ca90fd69
commit 7b233b027f
4 changed files with 74 additions and 21 deletions

23
app.py
View File

@@ -1,6 +1,7 @@
from flask import Flask, render_template, request
from datetime import datetime, timedelta
import numpy as np
from dateutil.relativedelta import relativedelta
app = Flask(__name__)
@@ -10,7 +11,7 @@ WOCHENTAGE = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samsta
@app.route('/', methods=['GET', 'POST'])
def index():
tage = werktage = wochentag = datumsrechnung = werktagsrechnung = kw_berechnen = kw_datum = None
tage = werktage = wochentag = datumsrechnung = werktagsrechnung = kw_berechnen = kw_datum = wochen_monate = None
active_idx = 0
if request.method == 'POST':
action = request.form.get('action')
@@ -99,7 +100,25 @@ def index():
kw_datum = f"{start.strftime('%d.%m.%Y')} bis {end.strftime('%d.%m.%Y')}"
except Exception:
kw_datum = 'Ungültige Eingabe'
return render_template('index.html', tage=tage, werktage=werktage, wochentag=wochentag, datumsrechnung=datumsrechnung, werktagsrechnung=werktagsrechnung, kw_berechnen=kw_berechnen, kw_datum=kw_datum, active_idx=active_idx)
elif action == 'wochen_monate':
datum = request.form.get('datum8')
anzahl = request.form.get('anzahl8')
einheit = request.form.get('einheit8')
richtung = request.form.get('richtung8')
try:
d = datetime.strptime(datum, '%Y-%m-%d')
anzahl_int = int(anzahl)
if richtung == 'sub':
anzahl_int = -anzahl_int
if einheit == 'wochen':
result = d + timedelta(weeks=anzahl_int)
else:
result = d + relativedelta(months=anzahl_int)
wochen_monate = result.strftime('%d.%m.%Y')
except Exception:
wochen_monate = 'Ungültige Eingabe'
return render_template('index.html', tage=tage, werktage=werktage, wochentag=wochentag, datumsrechnung=datumsrechnung, werktagsrechnung=werktagsrechnung, kw_berechnen=kw_berechnen, kw_datum=kw_datum, active_idx=active_idx, wochen_monate=wochen_monate)
if __name__ == '__main__':
app.run(debug=True)