V0.5.0.1
This commit is contained in:
1 parent
bc9c88a548
commit
2cb9ce64cb
32 files changed
+2233
-47
No files matched your search
@@ -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);
|
||||
Reference in new issue
Block a user