8000 Localize auto-formatted x-axis date ticks by TomDemulierChevret · Pull Request #2261 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Localize auto-formatted x-axis date ticks #2261

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

Prev Previous commit
Next Next commit
Fix lib_date_test (missing extraFormats parameter passed to formatDate)
  • Loading branch information
TomDemulierChevret committed Jan 22, 2018
commit d79d00a1aa2931c99ad506931fab51a6b5012f00
27 changes: 19 additions & 8 deletions test/jasmine/tests/lib_date_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,12 @@ describe('dates', function() {
describe('formatDate', function() {
function assertFormatRounds(ms, calendar, results) {
['y', 'm', 'd', 'M', 'S', 1, 2, 3, 4].forEach(function(tr, i) {
expect(Lib.formatDate(ms, '', tr, utcFormat, calendar))
expect(Lib.formatDate(ms, '', tr, utcFormat, calendar, {
year: '%Y',
month: '%b %Y',
dayMonth: '%b %-d',
dayMonthYear: '%b %-d, %Y'
}))
.toBe(results[i], calendar);
});
}
Expand Down Expand Up @@ -598,17 +603,23 @@ describe('dates', function() {
});

it('should remove extra fractional second zeros', function() {
expect(Lib.formatDate(0.1, '', 4, utcFormat)).toBe('00:00:00.0001\nJan 1, 1970');
expect(Lib.formatDate(0.1, '', 3, utcFormat)).toBe('00:00:00\nJan 1, 1970');
expect(Lib.formatDate(0.1, '', 0, utcFormat)).toBe('00:00:00\nJan 1, 1970');
expect(Lib.formatDate(0.1, '', 'S', utcFormat)).toBe('00:00:00\nJan 1, 1970');
expect(Lib.formatDate(0.1, '', 3, utcFormat, 'coptic'))
var extraFormat = {
year: '%Y',
month: '%b %Y',
dayMonth: '%b %-d',
dayMonthYear: '%b %-d, %Y'
};
expect(Lib.formatDate(0.1, '', 4, utcFormat, null, extraFormat)).toBe('00:00:00.0001\nJan 1, 1970');
expect(Lib.formatDate(0.1, '', 3, utcFormat, null, extraFormat)).toBe('00:00:00\nJan 1, 1970');
expect(Lib.formatDate(0.1, '', 0, utcFormat, null, extraFormat)).toBe('00:00:00\nJan 1, 1970');
expect(Lib.formatDate(0.1, '', 'S', utcFormat, null, extraFormat)).toBe('00:00:00\nJan 1, 1970');
expect(Lib.formatDate(0.1, '', 3, utcFormat, 'coptic', extraFormat))
.toBe('00:00:00\nKoi 23, 1686');

// because the decimal point is explicitly part of the format
// string here, we can't remove it OR the very first zero after it.
expect(Lib.formatDate(0.1, '%S.%f', null, utcFormat)).toBe('00.0001');
expect(Lib.formatDate(0.1, '%S.%3f', null, utcFormat)).toBe('00.0');
expect(Lib.formatDate(0.1, '%S.%f', null, utcFormat, null, extraFormat)).toBe('00.0001');
expect(Lib.formatDate(0.1, '%S.%3f', null, utcFormat, null, extraFormat)).toBe('00.0');
});

});
Expand Down
0