Skip to content

Instantly share code, notes, and snippets.

@remisarrailh
Created June 3, 2019 09:53
Show Gist options
  • Save remisarrailh/e55a021828f9a0f2b015ac7f7d571bb4 to your computer and use it in GitHub Desktop.
Save remisarrailh/e55a021828f9a0f2b015ac7f7d571bb4 to your computer and use it in GitHub Desktop.
// Récupération de la description
description_raw = msg.payload.split("SUMMARY:");
var description = [];
description_raw.forEach(function (item, index) {
if(index !== 0){
description.push(item.split("\n")[0].trim());
}
});
// Récupération de la date
date_raw = msg.payload.split("DTSTART;");
var message_complet = "Voici la liste des initiations et ateliers:\n------------------------\n";
date_raw.forEach(function (item, index) {
if(index !== 0){
icalStr = item.split("\n")[0].trim();
icalStr = item.split(":")[1].trim();
//Conversion du temps
var strAnnee = icalStr.substr(0,4);
var strMois = icalStr.substr(4,2);
var strJour = icalStr.substr(6,2);
//Transformation date en jour
strDate = strMois + "/" + strJour + "/" + strAnnee;
var days = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
strJourEntier = days[new Date(strDate).getDay()];
//Transformation date en mois
var month = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'];
strMoisEntier = month[new Date(strDate).getMonth()];
message_complet += description[index-1] + " --> " + strJourEntier + " " + strJour + " " + strMoisEntier + "\n";
}
});
//Fin du message
message_complet += "\n Plus d'informations sur https://labsud.org/agenda/";
//Copie du message dans la variable new_calendrier
flow.set("new_calendrier", message_complet);
return msg;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment