From bc775f67d392d202c7c0bea08227fdbbb582c923 Mon Sep 17 00:00:00 2001 From: Dicken Date: Mon, 1 Jun 2026 09:55:31 +0200 Subject: [PATCH] DevTools Datetime: Felder-leeren statt Jetzt-verwenden, Wochentag beim Geburtstag, Dezimalstellen, Datum ohne Uhrzeit --- frontend/src/tools/devtools.jsx | 71 +++++++++++++++++---------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/frontend/src/tools/devtools.jsx b/frontend/src/tools/devtools.jsx index 11b2ed6..0880653 100644 --- a/frontend/src/tools/devtools.jsx +++ b/frontend/src/tools/devtools.jsx @@ -600,13 +600,15 @@ function DatetimeRechner({ mobile }) { const nextBday = new Date(today.getFullYear(), birth.getMonth(), birth.getDate()); if (nextBday <= today) nextBday.setFullYear(today.getFullYear()+1); - const diffMs = nextBday - today; - const diffD = Math.ceil(diffMs / 86400000); - const totalD = Math.floor((today - birth) / 86400000); + const diffMs = nextBday - today; + const diffD = (diffMs / 86400000).toFixed(1); + const totalD = Math.floor((today - birth) / 86400000); + const nextWday = WEEKDAYS[nextBday.getDay()]; - setBdayResult({ age, diffD, totalD, wday: WEEKDAYS[birth.getDay()], + setBdayResult({ age, diffD, totalD, + wday: WEEKDAYS[birth.getDay()], geburtstag: `${pad2(birth.getDate())}.${pad2(birth.getMonth()+1)}.${birth.getFullYear()}`, - nextDate: `${pad2(nextBday.getDate())}.${pad2(nextBday.getMonth()+1)}.${nextBday.getFullYear()}`, + nextDate: `${pad2(nextBday.getDate())}.${pad2(nextBday.getMonth()+1)}.${nextBday.getFullYear()} (${nextWday})`, }); } @@ -620,12 +622,13 @@ function DatetimeRechner({ mobile }) { const dA = new Date(a), dB = new Date(b); if (isNaN(dA)||isNaN(dB)) { setDiffResult(null); return; } const ms = Math.abs(dB - dA); - const s = Math.floor(ms/1000); - const m = Math.floor(s/60); - const h = Math.floor(m/60); - const d = Math.floor(h/24); - const weeks = Math.floor(d/7); - const months = Math.abs(dB.getMonth()-dA.getMonth() + (dB.getFullYear()-dA.getFullYear())*12); + const s = (ms / 1000).toFixed(1); + const m = (ms / 60000).toFixed(1); + const h = (ms / 3600000).toFixed(2); + const d = (ms / 86400000).toFixed(2); + const weeks = (ms / (86400000*7)).toFixed(2); + const dA2 = new Date(Math.min(dA,dB)), dB2 = new Date(Math.max(dA,dB)); + const months = Math.abs(dB2.getMonth()-dA2.getMonth() + (dB2.getFullYear()-dA2.getFullYear())*12); setDiffResult({ ms, s, m, h, d, weeks, months }); } @@ -667,15 +670,9 @@ function DatetimeRechner({ mobile }) { value={conv.local||''} onChange={e=>{ setConv(p=>({...p,local:e.target.value})); convFromLocal(e.target.value); }}/> - {convResult && (
@@ -704,10 +701,14 @@ function DatetimeRechner({ mobile }) { {tab==='bday' && (
-
-
Geburtsdatum
- calcBday(e.target.value)}/> +
+
+
Geburtsdatum
+ calcBday(e.target.value)}/> +
+ {!!bday && }
{bdayResult && (
@@ -731,29 +732,31 @@ function DatetimeRechner({ mobile }) {
Von
- { setDtA(e.target.value); calcDiff(e.target.value, dtB); }}/>
Bis
- { setDtB(e.target.value); calcDiff(dtA, e.target.value); }}/>
+ {!!(dtA||dtB) && } {diffResult && (
- - - - - - - + + + + + + +
)} {!diffResult && (
- Zwei Zeitpunkte eingeben + Zwei Datumswerte eingeben
)}