From c0e8970c6612aad893b6697d5b119ef691b92326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20L=C3=B3pez=20P=C3=A9rez?= Date: Mon, 24 Oct 2011 14:23:31 +0200 Subject: [PATCH] Add startParamUTC and endParamUTC options --- src/EventManager.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/EventManager.js b/src/EventManager.js index 4d159ab..bae09d5 100644 --- a/src/EventManager.js +++ b/src/EventManager.js @@ -36,6 +36,7 @@ function EventManager(options, _sources) { var stickySource = { events: [] }; var sources = [ stickySource ]; var rangeStart, rangeEnd; + var offsetStart, offsetEnd; var currentFetchID = 0; var pendingSourceCnt = 0; var loadingLevel = 0; @@ -60,6 +61,8 @@ function EventManager(options, _sources) { function fetchEvents(start, end) { rangeStart = start; rangeEnd = end; + offsetStart = start.getTimezoneOffset()*60*1000; + offsetEnd = end.getTimezoneOffset()*60*1000; cache = []; var fetchID = ++currentFetchID; var len = sources.length; @@ -130,10 +133,18 @@ function EventManager(options, _sources) { var startParam = firstDefined(source.startParam, options.startParam); var endParam = firstDefined(source.endParam, options.endParam); if (startParam) { - data[startParam] = Math.round(+rangeStart / 1000); + var tmpstart = rangeStart; + if (source.startParamUTC) { + tmpstart -= offsetStart; + } + data[startParam] = Math.round(+tmpstart / 1000); } if (endParam) { - data[endParam] = Math.round(+rangeEnd / 1000); + var tmpend = rangeEnd; + if (source.endParamUTC) { + tmpend -= offsetEnd; + } + data[endParam] = Math.round(+tmpend / 1000); } pushLoading(); $.ajax($.extend({}, ajaxDefaults, source, {