From 7b233b027fcfcbe723b7150e664088c422f8eff9 Mon Sep 17 00:00:00 2001 From: elpatron Date: Tue, 22 Jul 2025 17:06:57 +0200 Subject: [PATCH] Local changes --- .gitignore | 4 ++- app.py | 23 ++++++++++++++-- requirements.txt | 3 +- templates/index.html | 65 ++++++++++++++++++++++++++++++++------------ 4 files changed, 74 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index a8021d3..5779aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,6 @@ htmlcov/ .pytest_cache/ # Betriebssystem -*.swp \ No newline at end of file +*.swp + +idea.txt diff --git a/app.py b/app.py index 49298fe..f1469a7 100644 --- a/app.py +++ b/app.py @@ -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) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 9ec642b..f21b489 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Flask==3.0.3 -numpy==1.26.4 \ No newline at end of file +numpy==1.26.4 +python-dateutil==2.9.0.post0 \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 8529d9b..37dc117 100644 --- a/templates/index.html +++ b/templates/index.html @@ -149,6 +149,22 @@ .accordion-content.active { display: block; } + .header-tage { background: #2563eb; } + .header-tage.active, .header-tage:hover { background: #1e40af; } + .header-werktage { background: #059669; } + .header-werktage.active, .header-werktage:hover { background: #047857; } + .header-wochentag { background: #f59e42; color: #fff; } + .header-wochentag.active, .header-wochentag:hover { background: #d97706; } + .header-plusminus-tage { background: #a21caf; } + .header-plusminus-tage.active, .header-plusminus-tage:hover { background: #701a75; } + .header-plusminus-werktage { background: #0ea5e9; } + .header-plusminus-werktage.active, .header-plusminus-werktage:hover { background: #0369a1; } + .header-plusminus-wochenmonate { background: #f43f5e; } + .header-plusminus-wochenmonate.active, .header-plusminus-wochenmonate:hover { background: #be123c; } + .header-kw { background: #facc15; color: #1e293b; } + .header-kw.active, .header-kw:hover { background: #ca8a04; } + .header-kw-datum { background: #38bdf8; } + .header-kw-datum.active, .header-kw-datum:hover { background: #0ea5e9; } @media (max-width: 600px) { .container { margin: 1em; @@ -173,16 +189,16 @@ }); } document.addEventListener('DOMContentLoaded', function() { - openAccordion({{ active_idx|default(0) }}); + openAccordion(parseInt("{{ active_idx|default(0) }}")); });
-

Datumsberechnungen

+

Elpatrons Datumsrechner

-
-
-
-
-
-
- + + + + + + + + + +
- {% if kw_berechnen is not none %} -
Kalenderwoche: {{ kw_berechnen }}
+ {% if wochen_monate is not none %} +
Ergebnis: {{ wochen_monate }}
{% endif %}
-
+ \ No newline at end of file