Merge pull request #636 from Jopyth/fix_calendar

Fix Calendar Issues
This commit is contained in:
Michael Teeuw 2017-01-22 16:10:31 +01:00 committed by GitHub
commit 1f7863057f
3 changed files with 20 additions and 5 deletions

View File

@ -8,7 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed ### Changed
- Installer: Use init config.js from config.js.sample. - Installer: Use init config.js from config.js.sample.
- Switched out `rrule` package for `rrule-alt` in order to improve calendar issues. (Experimental: [#565](https://github.com/MichMich/MagicMirror/issues/565)) - Switched out `rrule` package for `rrule-alt` and fixes in `ical.js` in order to fix calendar issues. ([#565](https://github.com/MichMich/MagicMirror/issues/565))
- Make mouse events pass through the region fullscreen_above to modules below. - Make mouse events pass through the region fullscreen_above to modules below.
- Scaled the splash screen down to make it a bit more subtle. - Scaled the splash screen down to make it a bit more subtle.
- Replace HTML tables with markdown tables in README files. - Replace HTML tables with markdown tables in README files.

View File

@ -90,7 +90,6 @@
return dt return dt
} }
var dateParam = function(name){ var dateParam = function(name){
return function(val, params, curr){ return function(val, params, curr){
@ -143,6 +142,16 @@
} }
} }
var exdateParam = function(name){
return function(val, params, curr){
var date = dateParam(name)(val, params, curr);
if (date.exdates === undefined) {
date.exdates = [];
}
date.exdates.push(date.exdate);
return date;
}
}
var geoParam = function(name){ var geoParam = function(name){
return function(val, params, curr){ return function(val, params, curr){
@ -240,6 +249,7 @@
, 'LOCATION' : storeParam('location') , 'LOCATION' : storeParam('location')
, 'DTSTART' : dateParam('start') , 'DTSTART' : dateParam('start')
, 'DTEND' : dateParam('end') , 'DTEND' : dateParam('end')
, 'EXDATE' : exdateParam('exdate')
,' CLASS' : storeParam('class') ,' CLASS' : storeParam('class')
, 'TRANSP' : storeParam('transparency') , 'TRANSP' : storeParam('transparency')
, 'GEO' : geoParam('geo') , 'GEO' : geoParam('geo')

View File

@ -18,6 +18,7 @@ exports.parseFile = function(filename){
var rrule = require('rrule-alt').RRule var rrule = require('rrule-alt').RRule
var rrulestr = rrule.rrulestr
ical.objectHandlers['RRULE'] = function(val, params, curr, stack, line){ ical.objectHandlers['RRULE'] = function(val, params, curr, stack, line){
curr.rrule = line; curr.rrule = line;
@ -26,7 +27,7 @@ ical.objectHandlers['RRULE'] = function(val, params, curr, stack, line){
var originalEnd = ical.objectHandlers['END']; var originalEnd = ical.objectHandlers['END'];
ical.objectHandlers['END'] = function(val, params, curr, stack){ ical.objectHandlers['END'] = function(val, params, curr, stack){
if (curr.rrule) { if (curr.rrule) {
var rule = curr.rrule.replace('RRULE:', ''); var rule = curr.rrule;
if (rule.indexOf('DTSTART') === -1) { if (rule.indexOf('DTSTART') === -1) {
if (curr.start.length === 8) { if (curr.start.length === 8) {
@ -36,10 +37,14 @@ ical.objectHandlers['END'] = function(val, params, curr, stack){
} }
} }
rule += ';DTSTART=' + curr.start.toISOString().replace(/[-:]/g, ''); rule += ' DTSTART:' + curr.start.toISOString().replace(/[-:]/g, '');
rule = rule.replace(/\.[0-9]{3}/, ''); rule = rule.replace(/\.[0-9]{3}/, '');
} }
curr.rrule = rrule.fromString(rule); for (var i in curr.exdates) {
rule += ' EXDATE:' + curr.exdates[i].toISOString().replace(/[-:]/g, '');
rule = rule.replace(/\.[0-9]{3}/, '');
}
curr.rrule = rrulestr(rule);
} }
return originalEnd.call(this, val, params, curr, stack); return originalEnd.call(this, val, params, curr, stack);
} }