Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 16 additions & 36 deletions lib/timeline/TimeStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,46 +193,26 @@ TimeStep.prototype.next = function() {

// Two cases, needed to prevent issues with switching daylight savings
// (end of March and end of October)
if (this.current.month() < 6) {
switch (this.scale) {
case 'millisecond': this.current.add(this.step, 'millisecond'); break;
case 'second': this.current.add(this.step, 'second'); break;
case 'minute': this.current.add(this.step, 'minute'); break;
case 'hour':
this.current.add(this.step, 'hour');
// in case of skipping an hour for daylight savings, adjust the hour again (else you get: 0h 5h 9h ... instead of 0h 4h 8h ...)
// TODO: is this still needed now we use the function of moment.js?
this.current.subtract(this.current.hours() % this.step, 'hour');
break;
case 'weekday': // intentional fall through
case 'day': this.current.add(this.step, 'day'); break;
case 'month': this.current.add(this.step, 'month'); break;
case 'year': this.current.add(this.step, 'year'); break;
default: break;
}
}
else {
switch (this.scale) {
case 'millisecond': this.current.add(this.step, 'millisecond'); break;
case 'second': this.current.add(this.step, 'second'); break;
case 'minute': this.current.add(this.step, 'minute'); break;
case 'hour':
this.current.add(this.moment.duration(this.step, 'hour'));
switch (this.scale) {
case 'millisecond': this.current.add(this.step, 'millisecond'); break;
case 'second': this.current.add(this.step, 'second'); break;
case 'minute': this.current.add(this.step, 'minute'); break;
case 'hour':
this.current.add(this.step, 'hour');

// correct for daylight saving
// FIXME: use this.current.add(moment.duration(this.step, 'hour'))
// see http://momentjs.com/docs/#special-considerations-for-months-and-years
if (this.current.month() < 6) {
this.current.subtract(this.current.hours() % this.step, 'hour');
} else {
if (this.current.hours() % this.step !== 0) {
this.current.add(this.step - this.current.hours() % this.step, 'hour');
}

break;
case 'weekday': // intentional fall through
case 'day': this.current.add(this.step, 'day'); break;
case 'month': this.current.add(this.step, 'month'); break;
case 'year': this.current.add(this.step, 'year'); break;
default: break;
}
}
break;
case 'weekday': // intentional fall through
case 'day': this.current.add(this.step, 'day'); break;
case 'month': this.current.add(this.step, 'month'); break;
case 'year': this.current.add(this.step, 'year'); break;
default: break;
}

if (this.step != 1) {
Expand Down