jubilee/server/agenda.js
2018-03-13 13:46:26 +00:00

41 lines
765 B
JavaScript

const calHandler = require('./lib/calHandler');
const logger = require('log4js').getLogger('Agenda');
logger.level = 'debug';
function compare(a, b) {
if (a.ts < b.ts)
return -1;
if (a.ts > b.ts)
return 1;
return 0;
}
async function getTodaysAgenda() {
let three = [];
for (const item of calHandler.calendars)
await calHandler.getAdvancedCalV3(item)
.then((d) => {
three = three.concat(d.three);
})
.catch((e) => {
'use strict';
logger.error(e);
});
three = three.sort(compare);
return three;
}
async function doTodaysAgenda() {
return new Promise((resolve, reject) => {
const today = getTodaysAgenda();
return resolve(today);
});
}
module.exports = { doTodaysAgenda };