Skip to content

Commit 02e98a9

Browse files
committed
fix range selectors for UTC, and tests to run in arbitrary timezone
1 parent 6d83c7b commit 02e98a9

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

src/components/rangeselector/get_update_object.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ function getXRange(axisLayout, buttonLayout) {
4242

4343
switch(buttonLayout.stepmode) {
4444
case 'backward':
45-
range0 = Lib.ms2DateTime(+d3.time[step].offset(base, -count));
45+
range0 = Lib.ms2DateTime(+d3.time[step].utc.offset(base, -count));
4646
break;
4747

4848
case 'todate':
49-
var base2 = d3.time[step].offset(base, -count);
49+
var base2 = d3.time[step].utc.offset(base, -count);
5050

51-
range0 = Lib.ms2DateTime(+d3.time[step].ceil(base2));
51+
range0 = Lib.ms2DateTime(+d3.time[step].utc.ceil(base2));
5252
break;
5353
}
5454

src/lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var datesModule = require('./dates');
2828
lib.dateTime2ms = datesModule.dateTime2ms;
2929
lib.isDateTime = datesModule.isDateTime;
3030
lib.ms2DateTime = datesModule.ms2DateTime;
31+
lib.ms2DateTimeLocal = datesModule.ms2DateTimeLocal;
3132
lib.cleanDate = datesModule.cleanDate;
3233
lib.isJSDate = datesModule.isJSDate;
3334
lib.MIN_MS = datesModule.MIN_MS;

test/jasmine/tests/annotations_test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ describe('Test annotations', function() {
7171
axref: 'x',
7272
ayref: 'y',
7373
x: '2008-07-01',
74-
ax: Dates.dateTime2ms('2004-07-01'),
74+
// note this is not portable: this generates ms in the local
75+
// timezone, so will work correctly where it was created but
76+
// not if the milliseconds number is moved to another TZ
77+
ax: +(new Date(2004, 6, 1)),
7578
y: 0,
7679
ay: 50
7780
}]

test/jasmine/tests/axes_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ describe('Test axes', function() {
678678

679679
it('should handle tick0 and dtick for date axes', function() {
680680
var someMs = 123456789,
681-
someMsDate = Lib.ms2DateTime(someMs),
681+
someMsDate = Lib.ms2DateTimeLocal(someMs),
682682
oneDay = 24 * 3600 * 1000,
683683
axIn = {tick0: someMs, dtick: String(3 * oneDay)},
684684
axOut = {};

test/jasmine/tests/shapes_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ describe('Test shapes', function() {
489489
title: 'linked to date and category axes',
490490
xaxis: {
491491
type: 'date',
492-
range: ['2000-01-01', (new Date(2000, 1, 2)).getTime()]
492+
range: ['2000-01-01', '2000-02-02']
493493
},
494494
yaxis: { type: 'category', range: ['a', 'b'] }
495495
}

0 commit comments

Comments
 (0)