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', '')
|
||||
|
||||
|
||||
content += `\n* [${event.title}](${eventUrl})` ;
|
||||
// content += `\n* [${event.title}](${eventUrl})` ;
|
||||
content += `\n* [${event.city} - ${event.title}](${eventUrl})` ;
|
||||
content += `\n* ${tags}` ;
|
||||
content += `\n* ${event.city} - ${event.title}` ;
|
||||
|
||||
let start = moment(new Date(event.start_time)).format(event_date_format)
|
||||
let end = moment(new Date(event.end_time)).format(event_date_format)
|
||||
content += `\n ${start} -- ${end}` ;
|
||||
})
|
||||
content += `\n`;
|
||||
|
||||
})
|
||||
return content;
|
||||
@ -73,7 +74,4 @@ async function postLink() {
|
||||
sendPostMastodon(configPost)
|
||||
}
|
||||
|
||||
// postLink();
|
||||
|
||||
let difftest = diffDaysBetweenTwoDates(new Date("2023-03-04T14:30:00.000Z") ,new Date())
|
||||
console.log('new Date("2023-03-04") ', difftest )
|
||||
postLink();
|
||||
|
@ -63,8 +63,8 @@ export default function sendPostMastodon(config) {
|
||||
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('configPost.folder_image', config.folder_image)
|
||||
console.log('config', config)
|
||||
// console.log('configPost.folder_image', config.folder_image)
|
||||
console.log('config', config.message)
|
||||
} else {
|
||||
|
||||
console.log(" ")
|
||||
@ -420,17 +420,18 @@ export function getArticlesFromDaysInJson(json_content,nbOfDays){
|
||||
let selectedEvents = [];
|
||||
|
||||
console.log('getArticlesFromDaysInJson: filtre nbOfDays', nbOfDays)
|
||||
console.log('events ', json_content.length)
|
||||
json_content.forEach((item) => {
|
||||
|
||||
let differenceDays = diffDaysBetweenTwoDates(new Date(item.start_time) ,today);
|
||||
|
||||
console.log('differenceDays', differenceDays)
|
||||
if( differenceDays <= nbOfDays || differenceDays == 0 || differenceDays == 1){
|
||||
console.log('on garde', item.title)
|
||||
if( differenceDays < nbOfDays){
|
||||
console.log('on garde', differenceDays,item.city, item.title)
|
||||
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
|
||||
@ -438,9 +439,9 @@ export function getArticlesFromDaysInJson(json_content,nbOfDays){
|
||||
|
||||
export function diffDaysBetweenTwoDates(date1,date2) {
|
||||
|
||||
const diffTime = Math.abs(date2 - date1);
|
||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||
return diffDays;
|
||||
const a = moment(date1);
|
||||
const b = moment(date2);
|
||||
return a.diff(b, 'days');
|
||||
|
||||
}
|
||||
|
||||
@ -455,6 +456,7 @@ export function filterRegionAgendaDuLibreEvents(events_list, filter_critera) {
|
||||
})
|
||||
return selection;
|
||||
}
|
||||
|
||||
moment.locale('fr');
|
||||
|
||||
export function groupEventsByDay(events_list){
|
||||
@ -465,9 +467,8 @@ export function groupEventsByDay(events_list){
|
||||
|
||||
if( ! selection[formattedDay]){
|
||||
selection[formattedDay] = []
|
||||
selection[formattedDay].push(item)
|
||||
}
|
||||
selection[formattedDay].push(item)
|
||||
})
|
||||
console.log('selection', selection)
|
||||
return selection;
|
||||
}
|
Loading…
Reference in New Issue
Block a user