Skip to content

Commit be52281

Browse files
committed
remove time zone offset and use UTC getters
1 parent 6b68e34 commit be52281

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/plots/cartesian/align_period.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ module.exports = function alignPeriod(trace, ax, axLetter, vals) {
4444
// var isMiddle = 'middle' === alignment;
4545
var isEnd = 'end' === alignment;
4646

47-
var offset = (new Date()).getTimezoneOffset() * 60000;
4847
var period0 = trace[axLetter + 'period0'];
49-
var base = (dateTime2ms(period0, calendar) || 0) - offset;
48+
var base = dateTime2ms(period0, calendar) || 0;
5049

5150
var newVals = [];
5251
var len = vals.length;
@@ -55,9 +54,9 @@ module.exports = function alignPeriod(trace, ax, axLetter, vals) {
5554

5655
var dateStr = ms2DateTime(v, 0, calendar);
5756
var d = new Date(dateStr);
58-
var year = d.getFullYear();
59-
var month = d.getMonth();
60-
var day = d.getDate();
57+
var year = d.getUTCFullYear();
58+
var month = d.getUTCMonth();
59+
var day = d.getUTCDate();
6160

6261
var newD;
6362
var startTime;
@@ -73,8 +72,8 @@ module.exports = function alignPeriod(trace, ax, axLetter, vals) {
7372
var d1 = day + nDays;
7473
if(nDays || nMonths || nYears) {
7574
if(nDays) {
76-
startTime = (new Date(year, month, day)).getTime();
77-
var monthDays = new Date(y1, m1 + 1, 0).getDate();
75+
startTime = Date.UTC(year, month, day);
76+
var monthDays = new Date(y1, m1 + 1, 0).getUTCDate();
7877
if(d1 > monthDays) {
7978
d1 -= monthDays;
8079
m1 += 1;
@@ -83,13 +82,13 @@ module.exports = function alignPeriod(trace, ax, axLetter, vals) {
8382
y1 += 1;
8483
}
8584
}
86-
endTime = (new Date(y1, m1, d1)).getTime();
85+
endTime = Date.UTC(y1, m1, d1);
8786
} else if(nMonths) {
88-
startTime = (new Date(year, nYears ? month : roundMonth(month, nMonths))).getTime();
87+
startTime = Date.UTC(year, nYears ? month : roundMonth(month, nMonths));
8988
endTime = incrementMonth(startTime, mPeriod ? mPeriod : nMonths, calendar);
9089
} else {
91-
startTime = (new Date(year, 0)).getTime();
92-
endTime = (new Date(y1, 0)).getTime();
90+
startTime = Date.UTC(year, 0);
91+
endTime = Date.UTC(y1, 0);
9392
}
9493

9594
newD = new Date(

0 commit comments

Comments
 (0)