fix: Diese Woche startet am Montag statt rollierend -6 Tage
This commit is contained in:
@@ -70,7 +70,12 @@ function periodRange(id, custom) {
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
const pad = n => String(n).padStart(2,'0');
|
const pad = n => String(n).padStart(2,'0');
|
||||||
const iso = d => `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}`;
|
const iso = d => `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}`;
|
||||||
if (id==='week') { const d=new Date(now); d.setDate(d.getDate()-6); return { from:iso(d), to:iso(now) }; }
|
if (id==='week') {
|
||||||
|
const d = new Date(now);
|
||||||
|
const day = d.getDay() || 7; // 1=Mo … 7=So
|
||||||
|
d.setDate(d.getDate() - (day - 1)); // zurück auf Montag
|
||||||
|
return { from:iso(d), to:iso(now) };
|
||||||
|
}
|
||||||
if (id==='month') { const d=new Date(now.getFullYear(),now.getMonth(),1); return { from:iso(d), to:iso(now) }; }
|
if (id==='month') { const d=new Date(now.getFullYear(),now.getMonth(),1); return { from:iso(d), to:iso(now) }; }
|
||||||
if (id==='year') { return { from:`${now.getFullYear()}-01-01`, to:iso(now) }; }
|
if (id==='year') { return { from:`${now.getFullYear()}-01-01`, to:iso(now) }; }
|
||||||
if (id==='custom' && custom) {
|
if (id==='custom' && custom) {
|
||||||
|
|||||||
Reference in New Issue
Block a user