calendar looping

This commit is contained in:
martind2000 2016-05-02 23:30:55 +01:00
parent 49f584a8db
commit 720b61d802
2 changed files with 43 additions and 13 deletions

View File

@ -43,7 +43,7 @@ function saveToDB(data) {
}
function nth(d) {
// if (d > 3 && d < 21) {return 'th';} // Thanks kennebec
// If (d > 3 && d < 21) {return 'th';} // Thanks kennebec
// if (d % 10 === 1) {return 'st';} else if (d % 10 === 2) {return 'nd';} else if (d % 10 === 3) {return 'rd';} else {return 'th';}
var n = d;
return Math.floor(n / 10) === 1
@ -120,7 +120,7 @@ module.exports = {
todayCache.data.history = [];
s = '<strong>' + d.format('{Weekday} {Month} {dd}, {yyyy}') + '</strong> - ';
/*
s = s + 'The ' + dayNumber() + nth(dayNumber) + ' day of ' + dateFormat(d,
S = s + 'The ' + dayNumber() + nth(dayNumber) + ' day of ' + dateFormat(d,
'yyyy') + ', and there are ' + DayDiff(d) + ' days left until the end of the year.';
*/
@ -189,7 +189,21 @@ module.exports = {
'use strict';
logger.error(e);
});
calHandler.getSimpleCalV3(
for (var t = 0; t < calHandler.calendars.length;t++) {
calHandler.getSimpleCalV3(calHandler.calendars[t])
.then((d) => {
'use strict';
todayCache.data.cal.entries = todayCache.data.cal.entries.concat(d.entries);
})
.catch((e) => {
'use strict';
logger.error(e);
});
}
/*calHandler.getSimpleCalV3(
'https://calendar.google.com/calendar/ical/martind2000%40gmail.com/private-40cfebc9f7dcfa7fde6b9bf2f0092c93/basic.ics')
.then((d) => {
'use strict';
@ -219,6 +233,17 @@ module.exports = {
'use strict';
logger.error(e);
});
calHandler.getSimpleCalV3(
'https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics')
.then((d) => {
'use strict';
todayCache.data.cal.entries = todayCache.data.cal.entries.concat(d.entries);
})
.catch((e) => {
'use strict';
logger.error(e);
});
*/
swedishWord.getSwedishWord()
.then((d) => {
'use strict';
@ -247,7 +272,7 @@ setTimeout(function() {
module.exports.preLoadToday();
}, 5000);
setTimeout(function() {
// mdMailer.sendEmailV1(todayCache, __dirname);
// MdMailer.sendEmailV1(todayCache, __dirname);
// saveToDB(todayCache);
}, 45000);
cron.schedule('45 6 * * *', function() {

View File

@ -113,6 +113,11 @@ function processICAL(ical) {
}
module.exports = {
calendars: ['https://calendar.google.com/calendar/ical/martind2000%40gmail.com/private-40cfebc9f7dcfa7fde6b9bf2f0092c93/basic.ics',
'https://calendar.google.com/calendar/ical/mt5pgdhknvgoc8usfnrso9vkv0%40group.calendar.google.com/private-58876002af9f302a593acfa6fa792dcf/basic.ics',
'https://www.tripit.com/feed/ical/private/DB96E4BB-94A9BD8F9CC1CF51C6CC0D920840F4F5/tripit.ics',
'https://calendar.google.com/calendar/ical/en.uk%23holiday%40group.v.calendar.google.com/public/basic.ics',
'https://calendar.google.com/calendar/ical/i8dglj12p5nuv20sbjmun5s588%40group.calendar.google.com/private-c8adccb41e56d6a2f285078aaed313f5/basic.ics'],
jsonBlock: [],
getTodaysSimple: function() {
'use strict';