calendar looping
This commit is contained in:
parent
49f584a8db
commit
720b61d802
51
lib/today.js
51
lib/today.js
@ -21,7 +21,7 @@ require('sugar-date');
|
||||
|
||||
var todayCache = {
|
||||
last: 0, data: {
|
||||
trains: {last: 0, data: []}, weather: {}, history: [], today: '', tv: {entries: []}, cal: {entries: []}, swedish: {}, fitbit:{}
|
||||
trains: {last: 0, data: []}, weather: {}, history: [], today: '', tv: {entries: []}, cal: {entries: []}, swedish: {}, fitbit: {}
|
||||
}, expire: ((60 * 1000) * 60)
|
||||
};
|
||||
var file = __dirname + '/' + 'newdata.json';
|
||||
@ -43,9 +43,9 @@ function saveToDB(data) {
|
||||
}
|
||||
|
||||
function nth(d) {
|
||||
// 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;
|
||||
// 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
|
||||
? 'th'
|
||||
: (n % 10 === 1
|
||||
@ -119,9 +119,9 @@ module.exports = {
|
||||
|
||||
todayCache.data.history = [];
|
||||
s = '<strong>' + d.format('{Weekday} {Month} {dd}, {yyyy}') + '</strong> - ';
|
||||
/*
|
||||
s = s + 'The ' + dayNumber() + nth(dayNumber) + ' day of ' + dateFormat(d,
|
||||
'yyyy') + ', and there are ' + DayDiff(d) + ' days left until the end of the year.';
|
||||
/*
|
||||
S = s + 'The ' + dayNumber() + nth(dayNumber) + ' day of ' + dateFormat(d,
|
||||
'yyyy') + ', and there are ' + DayDiff(d) + ' days left until the end of the year.';
|
||||
*/
|
||||
|
||||
s = s + 'The ' + daysSinceStart + nth(daysSinceStart) + ' day of ' + dateFormat(d,
|
||||
@ -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';
|
||||
@ -235,9 +260,9 @@ module.exports = {
|
||||
todayCache.data.fitbit = d;
|
||||
})
|
||||
.catch((e)=> {
|
||||
'use strict';
|
||||
console.error(e);
|
||||
});
|
||||
'use strict';
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
todayCache.date = breakDay();
|
||||
}
|
||||
@ -247,8 +272,8 @@ setTimeout(function() {
|
||||
module.exports.preLoadToday();
|
||||
}, 5000);
|
||||
setTimeout(function() {
|
||||
// mdMailer.sendEmailV1(todayCache, __dirname);
|
||||
// saveToDB(todayCache);
|
||||
// MdMailer.sendEmailV1(todayCache, __dirname);
|
||||
// saveToDB(todayCache);
|
||||
}, 45000);
|
||||
cron.schedule('45 6 * * *', function() {
|
||||
module.exports.preLoadToday();
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user