Permalink
Browse files

Better Hours Scaling, allows scaling for half hour dates etc.

  • Loading branch information...
1 parent f76b94f commit 52e440ce7b512ff4e2a745a052ee4b0f209aca53 Benedikt Wolters committed Oct 1, 2012
Showing with 11 additions and 10 deletions.
  1. +11 −10 js/jquery.fn.gantt.js
View
@@ -363,9 +363,8 @@
switch (settings.scale) {
// hours /////////////////////////////////////////////////////////////////////////////////////////
case "hours":
-
- range = tools.parseTimeRange(element.dateStart, element.dateEnd, element.scaleStep);
-
+ var go = element.dateStart.getTime() - (element.dateStart.getTime() %3600000);
+ range = tools.parseTimeRange(go, element.dateEnd, element.scaleStep);
var year = range[0].getFullYear();
var month = range[0].getMonth();
var day = range[0];
@@ -953,17 +952,19 @@
switch (settings.scale) {
case "hours":
-
- var dFrom = tools.genId(tools.dateDeserialize(day.from).getTime(), element.scaleStep);
+ var Dfrom = tools.dateDeserialize(day.from);
+ var Dto = tools.dateDeserialize(day.to)
+ var dFrom = tools.genId(Dfrom.getTime(), element.scaleStep);
var from = $(element).find('#dh-' + dFrom);
-
- var dTo = tools.genId(tools.dateDeserialize(day.to).getTime(), element.scaleStep);
+
+ var dOffset = Math.floor((((Dfrom.getTime() - dFrom) / (3600* 1000)) ) * tools.getCellSize()); //Offset in Secs
+ var dTo = tools.genId(Dto.getTime(), element.scaleStep);
var to = $(element).find('#dh-' + dTo);
-
+
var cFrom = from.attr("offset");
var cTo = to.attr("offset");
- var dl = Math.floor((cTo - cFrom) / tools.getCellSize()) + 1;
-
+ var dl = (((Dto.getTime()-Dfrom.getTime()) / 3600000 ))
@ni-ka

ni-ka Oct 24, 2012

This does not work for zooming out (scaleStep is not considered). Also, I noticed a problem with events where summer saving time transition occurs (you loose or gain one hour on transition day, but the calendar days are all 24h). To fix both, I used:

var eventHours = (Dto.getTime() - Dfrom.getTime() + (Dfrom.getTimezoneOffset() - Dto.getTimezoneOffset())*60000) / 3600000;
var dl = eventHours / element.scaleStep;
+
_bar = core.createProgressBar(
dl,
day.customClass ? day.customClass : "",

1 comment on commit 52e440c

Anxiro commented on 52e440c Feb 26, 2013

Thank you for this commit. This also fixes some other issues.
Plus, I can confirm ni-ka's fix. I've added these to line 967-968.

Please sign in to comment.