Skip to content

Commit ebf84ca

Browse files
committed
Woah, hours are finally working again!
1 parent e0909c0 commit ebf84ca

File tree

4 files changed

+39
-30
lines changed

4 files changed

+39
-30
lines changed

css/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
float: left;
4747
height: 24px;
4848
line-height: 24px;
49-
margin-left: -24px;
49+
margin-left: -1px;
5050
}
5151

5252
.fn-gantt .leftPanel .fn-label {

js/jquery.fn.gantt.js

100644100755
Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@
506506
+ day_class
507507
+ '" id="dh-'
508508
+ rday.getTime()
509-
+ '" offset="' + i * tools.getCellSize() + '" repdate="' + rday.genRepDate() + '"> '
509+
+ '" offset="' + i * tools.getCellSize() + '" repdate="' + rday.genRepDate() + '"><div class="fn-label">'
510510
+ rday.getHours()
511-
+ '</div>');
511+
+ '</div></div>');
512512
}
513513

514514

@@ -679,7 +679,7 @@
679679

680680
for (var i = 0; i < range.length; i++) {
681681
var rday = range[i];
682-
682+
683683
// Fill years
684684
if (rday.getFullYear() !== year) {
685685
yearArr.push(
@@ -713,7 +713,7 @@
713713
}
714714

715715
dayArr.push('<div class="row date ' + day_class + '" '
716-
+ ' id="dh-' + tools.genId(rday.getTime()) + '" offset="' + i * tools.getCellSize() + '" repdate="' + rday.genRepDate() + '> '
716+
+ ' id="dh-' + tools.genId(rday.getTime()) + '" offset="' + i * tools.getCellSize() + '" repdate="' + rday.genRepDate() + '"> '
717717
+ ' <div class="fn-label">' + rday.getDate() + '</div></div>');
718718
dowArr.push('<div class="row day ' + day_class + '" '
719719
+ ' id="dw-' + tools.genId(rday.getTime()) + '" repdate="' + rday.genRepDate() + '"> '
@@ -733,7 +733,7 @@
733733
+ tools.getCellSize() * daysInMonth + 'px"><div class="fn-label">'
734734
+ settings.months[month]
735735
+ '</div></div>');
736-
736+
737737
var dataPanel = core.dataPanel(element, range.length * tools.getCellSize());
738738

739739

@@ -1522,12 +1522,28 @@
15221522
parseTimeRange: function (from, to, scaleStep) {
15231523
var current = new Date(from);
15241524
var end = new Date(to);
1525+
1526+
// GR: Fix begin
1527+
current.setMilliseconds(0);
1528+
current.setSeconds(0);
1529+
current.setMinutes(0);
1530+
current.setHours(0);
1531+
1532+
end.setMilliseconds(0);
1533+
end.setSeconds(0);
1534+
if (end.getMinutes() > 0 || end.getHours() > 0) {
1535+
end.setMinutes(0);
1536+
end.setHours(0);
1537+
end.setTime(end.getTime() + (86400000)); // Add day
1538+
}
1539+
// GR: Fix end
1540+
15251541
var ret = [];
15261542
var i = 0;
15271543
for(;;) {
15281544
var dayStartTime = new Date(current);
15291545
dayStartTime.setHours(Math.floor((current.getHours()) / scaleStep) * scaleStep);
1530-
1546+
15311547
if (ret[i] && dayStartTime.getDay() !== ret[i].getDay()) {
15321548
// If mark-cursor jumped to next day, make sure it starts at 0 hours
15331549
dayStartTime.setHours(0);
@@ -1544,11 +1560,13 @@
15441560
}
15451561
*/
15461562

1547-
current = ktkGetNextDate(current, scaleStep);
1563+
// GR Fix Begin
1564+
current = ktkGetNextDate(dayStartTime, scaleStep);
1565+
// GR Fix End
15481566

15491567
i++;
1550-
};
1551-
1568+
}
1569+
15521570
return ret;
15531571
},
15541572

@@ -1591,9 +1609,9 @@
15911609

15921610
// Deserialize a date from a string
15931611
dateDeserialize: function (dateStr) {
1594-
//return eval("new" + dateStr.replace(/\//g, " "));
1595-
var date = eval("new" + dateStr.replace(/\//g, " "));
1596-
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes());
1612+
var newDate = new Date();
1613+
newDate.setTime(dateStr.replace(/[^0-9]/g, ""));
1614+
return newDate;
15971615
},
15981616

15991617
// Generate an id for a date
@@ -1734,5 +1752,5 @@ function ktkGetNextDate(currentDate, scaleStep) {
17341752

17351753
// If code reaches here, it's because current didn't really increment (invalid local time) because of daylight-saving adjustments
17361754
// => retry adding 2, 3, 4 hours, and so on (until nextDate > current)
1737-
}
1755+
}
17381756
}

tests/moment.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test01.html

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ <h1>
4242
</h1>
4343

4444
<p>
45-
<strong>Expected behaviour:</strong> Gantt bar should run from "now" until 2 hours from now.
45+
<strong>Expected behaviour:</strong> Gantt bar should run from "now" until 2 hours from now. It fails when all the bars are docked left at the hour view.
4646
</p>
4747

4848
<p>
49-
<strong>Errors:</strong>
49+
<strong>Manual validation:</strong>
50+
<ul>
51+
<li>Passing</li>
52+
</ul>
5053
</p>
51-
<ul>
52-
<li>Hour views (1/3/6/9 hours) are all docked left</li>
53-
</ul>
5454

5555
<div class="gantt"></div>
5656

@@ -67,17 +67,12 @@ <h1>
6767

6868
"use strict";
6969

70-
7170
var today = moment();
7271
var andTwoHours = moment().add("hours",2);
7372

7473
var today_friendly = "/Date(" + today.valueOf() + ")/";
7574
var next_friendly = "/Date(" + andTwoHours.valueOf() + ")/";
7675

77-
//var today_friendly = today.toDate();
78-
//var next_friendly = andTwoHours.toDate();
79-
var maxDate = moment().add("days",10).toDate();
80-
8176
$(".gantt").gantt({
8277
source: [{
8378
name: "Testing",
@@ -101,10 +96,6 @@ <h1>
10196
trigger: "hover"
10297
});
10398

104-
console.log(today.format("HH"));
105-
106-
prettyPrint();
107-
10899
});
109100

110101
</script>

0 commit comments

Comments
 (0)