calendar looping
This commit is contained in:
parent
49f584a8db
commit
720b61d802
41
lib/today.js
41
lib/today.js
@ -21,7 +21,7 @@ require('sugar-date');
|
|||||||
|
|
||||||
var todayCache = {
|
var todayCache = {
|
||||||
last: 0, data: {
|
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)
|
}, expire: ((60 * 1000) * 60)
|
||||||
};
|
};
|
||||||
var file = __dirname + '/' + 'newdata.json';
|
var file = __dirname + '/' + 'newdata.json';
|
||||||
@ -43,9 +43,9 @@ function saveToDB(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nth(d) {
|
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';}
|
// 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;
|
var n = d;
|
||||||
return Math.floor(n / 10) === 1
|
return Math.floor(n / 10) === 1
|
||||||
? 'th'
|
? 'th'
|
||||||
: (n % 10 === 1
|
: (n % 10 === 1
|
||||||
@ -119,8 +119,8 @@ module.exports = {
|
|||||||
|
|
||||||
todayCache.data.history = [];
|
todayCache.data.history = [];
|
||||||
s = '<strong>' + d.format('{Weekday} {Month} {dd}, {yyyy}') + '</strong> - ';
|
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.';
|
'yyyy') + ', and there are ' + DayDiff(d) + ' days left until the end of the year.';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -189,7 +189,21 @@ module.exports = {
|
|||||||
'use strict';
|
'use strict';
|
||||||
logger.error(e);
|
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')
|
'https://calendar.google.com/calendar/ical/martind2000%40gmail.com/private-40cfebc9f7dcfa7fde6b9bf2f0092c93/basic.ics')
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -219,6 +233,17 @@ module.exports = {
|
|||||||
'use strict';
|
'use strict';
|
||||||
logger.error(e);
|
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()
|
swedishWord.getSwedishWord()
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -247,7 +272,7 @@ setTimeout(function() {
|
|||||||
module.exports.preLoadToday();
|
module.exports.preLoadToday();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// mdMailer.sendEmailV1(todayCache, __dirname);
|
// MdMailer.sendEmailV1(todayCache, __dirname);
|
||||||
// saveToDB(todayCache);
|
// saveToDB(todayCache);
|
||||||
}, 45000);
|
}, 45000);
|
||||||
cron.schedule('45 6 * * *', function() {
|
cron.schedule('45 6 * * *', function() {
|
||||||
|
@ -113,6 +113,11 @@ function processICAL(ical) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
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: [],
|
jsonBlock: [],
|
||||||
getTodaysSimple: function() {
|
getTodaysSimple: function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
Loading…
Reference in New Issue
Block a user