Skip to content

Instantly share code, notes, and snippets.

@boblemarin
Created November 14, 2021 10:21
Show Gist options
  • Save boblemarin/d5ce420355940bdaa73de2c40caae853 to your computer and use it in GitHub Desktop.
Save boblemarin/d5ce420355940bdaa73de2c40caae853 to your computer and use it in GitHub Desktop.
/* Get CSV-formatted event list from https://www.journee-mondiale.com/les-journees-mondiales.htm */
let months = ['janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre'];
let out = 'Start date, Subject\n';
let curm = (new Date()).getMonth()+1;
let cury = (new Date()).getFullYear();
function dd(n) { return n<10?"0"+n:n; }
document.querySelectorAll(".content li").forEach(function(el) {
let parts = el.innerText.split(' ');
let day = parts[0]=='1er' ? '1' : parts[0];
let month = months.indexOf(parts[1]) + 1;
let desc = el.innerText.split(' : ')[1];
let year = (month<curm) ? (cury+1) : cury;
out +=dd(month)+"/"+dd(day)+"/"+year+",\""+desc+"\"\n";
});
console.log(out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment