Browse Source

Fixes #2251: no axis after daylight saving (#2290)

codeClimate
Jos de Jong 7 years ago
committed by Alexander Wunschik
parent
commit
2f77d803ba
1 changed files with 15 additions and 5 deletions
  1. +15
    -5
      lib/timeline/TimeStep.js

+ 15
- 5
lib/timeline/TimeStep.js View File

@ -216,7 +216,17 @@ TimeStep.prototype.next = function() {
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'); break;
case 'hour':
this.current.add(this.moment.duration(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.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;
@ -228,10 +238,10 @@ TimeStep.prototype.next = function() {
if (this.step != 1) {
// round down to the correct major value
switch (this.scale) {
case 'millisecond': if(this.current.milliseconds() < this.step) this.current.milliseconds(0); break;
case 'second': if(this.current.seconds() < this.step) this.current.seconds(0); break;
case 'minute': if(this.current.minutes() < this.step) this.current.minutes(0); break;
case 'hour': if(this.current.hours() < this.step) this.current.hours(0); break;
case 'millisecond': if(this.current.milliseconds() > 0 && this.current.milliseconds() < this.step) this.current.milliseconds(0); break;
case 'second': if(this.current.seconds() > 0 && this.current.seconds() < this.step) this.current.seconds(0); break;
case 'minute': if(this.current.minutes() > 0 && this.current.minutes() < this.step) this.current.minutes(0); break;
case 'hour': if(this.current.hours() > 0 && this.current.hours() < this.step) this.current.hours(0); break;
case 'weekday': // intentional fall through
case 'day': if(this.current.date() < this.step+1) this.current.date(1); break;
case 'month': if(this.current.month() < this.step) this.current.month(0); break;

Loading…
Cancel
Save