76241f8778fab1927b8806d2df2c8cd95939a0f0
[dygraphs.git] / two_digit_years.js
1 /**
2 * @fileoverview Test to check that years < 100 get the correct ticks.
3 *
4 * @author gmadrid@gmail.com (George Madrid)
5 */
6
7 import Dygraph from '../../src/dygraph';
8 import {Granularity, getDateAxis} from '../../src/dygraph-tickers';
9 import * as utils from '../../src/dygraph-utils';
10 import DEFAULT_ATTRS from '../../src/dygraph-default-attrs';
11
12 describe("two-digit-years", function() {
13
14 it('testTwoDigitYears', function() {
15 // A date with a one digit year: '9 AD'.
16 var start = new Date(9, 2, 3);
17 // A date with a two digit year: '11 AD'.
18 var end = new Date(11, 3, 5);
19
20 // Javascript will automatically add 1900 to our years if they are < 100.
21 // Use setFullYear() to get the actual years we desire.
22 start.setFullYear(9);
23 end.setFullYear(11);
24
25 var ticks = getDateAxis(start, end, Granularity.QUARTERLY, function(x) {
26 return DEFAULT_ATTRS.axes['x'][x];
27 });
28
29 // This breaks in Firefox & Safari:
30 // assert.deepEqual([{"v":-61875345600000,"label":"Apr 9"},{"v":-61867483200000,"label":"Jul 9"},{"v":-61859534400000,"label":"Oct 9"},{"v":-61851582000000,"label":"Jan 10"},{"v":-61843809600000,"label":"Apr 10"},{"v":-61835947200000,"label":"Jul 10"},{"v":-61827998400000,"label":"Oct 10"},{"v":-61820046000000,"label":"Jan 11"},{"v":-61812273600000,"label":"Apr 11"}], ticks);
31 });
32
33 });