This commit is contained in:
mathis committed 2026-09-24 16:29:30 +02:00
1 parent bc9c88a548
commit 2cb9ce64cb
32 files changed
+2233 -47

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
const q = "891811 de lundi";
const days = ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'];
const today = new Date();
let fallbackDate = null;
const foundDay = days.find(d => q.includes(d));
if (foundDay) {
const currentDay = today.getDay();
const targetDay = days.indexOf(foundDay);
let diff = targetDay - currentDay;
if (diff < 0) diff += 7; // next occurrence of that day
if (diff === 0 && q.includes('prochain')) diff += 7;
const targetDate = new Date(today);
targetDate.setDate(today.getDate() + diff);
fallbackDate = targetDate.toISOString().split('T')[0];
}
console.log(fallbackDate);