8000 Dates: Accept ISO-8601 format, and use UTC milliseconds as the backend by alexcjohnson · Pull Request #1194 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Dates: Accept ISO-8601 format, and use UTC milliseconds as the backend #1194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 25, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix range selectors for UTC, and tests to run in arbitrary timezone
  • Loading branch information
alexcjohnson committed Nov 19, 2016
commit 02e98a9380d32a00836f0d749a1f9cf14815f48f
6 changes: 3 additions & 3 deletions src/components/rangeselector/get_update_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function getXRange(axisLayout, buttonLayout) {

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

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

range0 = Lib.ms2DateTime(+d3.time[step].ceil(base2));
range0 = Lib.ms2DateTime(+d3.time[step].utc.ceil(base2));
break;
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var datesModule = require('./dates');
lib.dateTime2ms = datesModule.dateTime2ms;
lib.isDateTime = datesModule.isDateTime;
lib.ms2DateTime = datesModule.ms2DateTime;
lib.ms2DateTimeLocal = datesModule.ms2DateTimeLocal;
lib.cleanDate = datesModule.cleanDate;
lib.isJSDate = datesModule.isJSDate;
lib.MIN_MS = datesModule.MIN_MS;
Expand Down
5 changes: 4 additions & 1 deletion test/jasmine/tests/annotations_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ describe('Test annotations', function() {
axref: 'x',
ayref: 'y',
x: '2008-07-01',
ax: Dates.dateTime2ms('2004-07-01'),
// note this is not portable: this generates ms in the local
// timezone, so will work correctly where it was created but
// not if the milliseconds number is moved to another TZ
ax: +(new Date(2004, 6, 1)),
y: 0,
ay: 50
}]
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ describe('Test axes', function() {

it('should handle tick0 and dtick for date axes', function() {
var someMs = 123456789,
someMsDate = Lib.ms2DateTime(someMs),
someMsDate = Lib.ms2DateTimeLocal(someMs),
oneDay = 24 * 3600 * 1000,
axIn = {tick0: someMs, dtick: String(3 * oneDay)},
axOut = {};
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/shapes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ describe('Test shapes', function() {
title: 'linked to date and category axes',
xaxis: {
type: 'date',
range: ['2000-01-01', (new Date(2000, 1, 2)).getTime()]
range: ['2000-01-01', '2000-02-02']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

},
yaxis: { type: 'category', range: ['a', 'b'] }
}
Expand Down
0