|
@ -193,46 +193,26 @@ TimeStep.prototype.next = function() { |
|
|
|
|
|
|
|
|
// Two cases, needed to prevent issues with switching daylight savings
|
|
|
// Two cases, needed to prevent issues with switching daylight savings
|
|
|
// (end of March and end of October)
|
|
|
// (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) { |
|
|
if (this.current.hours() % this.step !== 0) { |
|
|
this.current.add(this.step - this.current.hours() % this.step, 'hour'); |
|
|
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) { |
|
|
if (this.step != 1) { |
|
|