Skip to content
Snippets Groups Projects
Commit 8451d445 authored by Kasalehlia's avatar Kasalehlia
Browse files

fixed timezone issue on calendar

parent b0daf560
No related branches found
No related tags found
No related merge requests found
var httpreq = require('httpreq'); var httpreq = require('httpreq');
var ical = require('ical.js'); var ical = require('ical.js');
var Mustache = require('mustache'); var Mustache = require('mustache');
var time = require('time');
var URL = 'https://stratum0.org/kalender/termine.ics'; var URL = 'https://stratum0.org/kalender/termine.ics';
var TEMPLATE = ''; var TEMPLATE = '';
...@@ -9,6 +10,8 @@ require('fs').readFile('modules/calendar/template.mustache', 'utf-8', function ( ...@@ -9,6 +10,8 @@ require('fs').readFile('modules/calendar/template.mustache', 'utf-8', function (
}); });
var CALENDAR; var CALENDAR;
var TZOFFSET = new time.Date().getTimezoneOffset()*60;
function pad(n, width, z) { function pad(n, width, z) {
z = z || '0'; z = z || '0';
n = n + ''; n = n + '';
...@@ -42,7 +45,7 @@ function getData(count, cb) { ...@@ -42,7 +45,7 @@ function getData(count, cb) {
for (var i = 0; i < 100; i++) { for (var i = 0; i < 100; i++) {
var next = iter.next(); var next = iter.next();
if (next === undefined) {break;} if (next === undefined) {break;}
var start = next.toUnixTime(); var start = next.toUnixTime()+TZOFFSET;
events.push({ events.push({
title: p('summary'), title: p('summary'),
start: start, start: start,
...@@ -52,8 +55,8 @@ function getData(count, cb) { ...@@ -52,8 +55,8 @@ function getData(count, cb) {
} else { } else {
events.push({ events.push({
title: p('summary'), title: p('summary'),
start: p('dtstart').toUnixTime(), start: p('dtstart').toUnixTime()+TZOFFSET,
end: p('dtend').toUnixTime(), end: p('dtend').toUnixTime()+TZOFFSET,
}); });
} }
} }
...@@ -119,4 +122,3 @@ module.exports = function (io) { ...@@ -119,4 +122,3 @@ module.exports = function (io) {
}); });
setInterval(update, 600000); setInterval(update, 600000);
} }
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
"ms": "^0.7.1", "ms": "^0.7.1",
"mustache": "^2.2.0", "mustache": "^2.2.0",
"pixl-xml": "^1.0.4", "pixl-xml": "^1.0.4",
"socket.io": "^1.3.7" "socket.io": "^1.3.7",
"time": "^0.11.4"
}, },
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment