add agenda du libre IDF events
This commit is contained in:
parent
dec093393b
commit
ae33a57bf4
@ -34,14 +34,15 @@ function makeTitleContentFromAgendaDulibre(articles) {
|
|||||||
let eventUrl = event.url.replace('.json', '')
|
let eventUrl = event.url.replace('.json', '')
|
||||||
|
|
||||||
|
|
||||||
content += `\n* [${event.title}](${eventUrl})` ;
|
// content += `\n* [${event.title}](${eventUrl})` ;
|
||||||
|
content += `\n* [${event.city} - ${event.title}](${eventUrl})` ;
|
||||||
content += `\n* ${tags}` ;
|
content += `\n* ${tags}` ;
|
||||||
content += `\n* ${event.city} - ${event.title}` ;
|
|
||||||
|
|
||||||
let start = moment(new Date(event.start_time)).format(event_date_format)
|
let start = moment(new Date(event.start_time)).format(event_date_format)
|
||||||
let end = moment(new Date(event.end_time)).format(event_date_format)
|
let end = moment(new Date(event.end_time)).format(event_date_format)
|
||||||
content += `\n ${start} -- ${end}` ;
|
content += `\n ${start} -- ${end}` ;
|
||||||
})
|
})
|
||||||
|
content += `\n`;
|
||||||
|
|
||||||
})
|
})
|
||||||
return content;
|
return content;
|
||||||
@ -73,7 +74,4 @@ async function postLink() {
|
|||||||
sendPostMastodon(configPost)
|
sendPostMastodon(configPost)
|
||||||
}
|
}
|
||||||
|
|
||||||
// postLink();
|
postLink();
|
||||||
|
|
||||||
let difftest = diffDaysBetweenTwoDates(new Date("2023-03-04T14:30:00.000Z") ,new Date())
|
|
||||||
console.log('new Date("2023-03-04") ', difftest )
|
|
||||||
|
@ -63,8 +63,8 @@ export default function sendPostMastodon(config) {
|
|||||||
if (!config.reallySendPost) {
|
if (!config.reallySendPost) {
|
||||||
|
|
||||||
console.log("\n\n =========== le message ne sera PAS réellement posté sur le compte @" + config.author + "@" + process.env.INSTANCE_MASTODON + " =========== \n")
|
console.log("\n\n =========== le message ne sera PAS réellement posté sur le compte @" + config.author + "@" + process.env.INSTANCE_MASTODON + " =========== \n")
|
||||||
console.log('configPost.folder_image', config.folder_image)
|
// console.log('configPost.folder_image', config.folder_image)
|
||||||
console.log('config', config)
|
console.log('config', config.message)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
console.log(" ")
|
console.log(" ")
|
||||||
@ -420,17 +420,18 @@ export function getArticlesFromDaysInJson(json_content,nbOfDays){
|
|||||||
let selectedEvents = [];
|
let selectedEvents = [];
|
||||||
|
|
||||||
console.log('getArticlesFromDaysInJson: filtre nbOfDays', nbOfDays)
|
console.log('getArticlesFromDaysInJson: filtre nbOfDays', nbOfDays)
|
||||||
|
console.log('events ', json_content.length)
|
||||||
json_content.forEach((item) => {
|
json_content.forEach((item) => {
|
||||||
|
|
||||||
let differenceDays = diffDaysBetweenTwoDates(new Date(item.start_time) ,today);
|
let differenceDays = diffDaysBetweenTwoDates(new Date(item.start_time) ,today);
|
||||||
|
|
||||||
console.log('differenceDays', differenceDays)
|
if( differenceDays < nbOfDays){
|
||||||
if( differenceDays <= nbOfDays || differenceDays == 0 || differenceDays == 1){
|
console.log('on garde', differenceDays,item.city, item.title)
|
||||||
console.log('on garde', item.title)
|
|
||||||
selectedEvents.push(item)
|
selectedEvents.push(item)
|
||||||
}else{
|
|
||||||
console.log('on ne garde pas', differenceDays)
|
|
||||||
}
|
}
|
||||||
|
// else{
|
||||||
|
// console.log('on ne garde pas', differenceDays,item.city, item.title)
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
|
|
||||||
return selectedEvents
|
return selectedEvents
|
||||||
@ -438,9 +439,9 @@ export function getArticlesFromDaysInJson(json_content,nbOfDays){
|
|||||||
|
|
||||||
export function diffDaysBetweenTwoDates(date1,date2) {
|
export function diffDaysBetweenTwoDates(date1,date2) {
|
||||||
|
|
||||||
const diffTime = Math.abs(date2 - date1);
|
const a = moment(date1);
|
||||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
const b = moment(date2);
|
||||||
return diffDays;
|
return a.diff(b, 'days');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,6 +456,7 @@ export function filterRegionAgendaDuLibreEvents(events_list, filter_critera) {
|
|||||||
})
|
})
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
moment.locale('fr');
|
moment.locale('fr');
|
||||||
|
|
||||||
export function groupEventsByDay(events_list){
|
export function groupEventsByDay(events_list){
|
||||||
@ -465,9 +467,8 @@ export function groupEventsByDay(events_list){
|
|||||||
|
|
||||||
if( ! selection[formattedDay]){
|
if( ! selection[formattedDay]){
|
||||||
selection[formattedDay] = []
|
selection[formattedDay] = []
|
||||||
selection[formattedDay].push(item)
|
|
||||||
}
|
}
|
||||||
|
selection[formattedDay].push(item)
|
||||||
})
|
})
|
||||||
console.log('selection', selection)
|
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user