Set "this" to the Dygraph object in all callbacks
[dygraphs.git] / auto_tests / tests / 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 var TwoDigitYearsTestCase = TestCase("two-digit-years");
7
8 TwoDigitYearsTestCase.prototype.testTwoDigitYears = function() {
9 // A date with a one digit year: '9 AD'.
10 var start = new Date(9, 2, 3);
11 // A date with a two digit year: '11 AD'.
12 var end = new Date(11, 3, 5);
13
14 // Javascript will automatically add 1900 to our years if they are < 100.
15 // Use setFullYear() to get the actual years we desire.
16 start.setFullYear(9);
17 end.setFullYear(11);
18
19 var ticks = Dygraph.getDateAxis(start, end, Dygraph.QUARTERLY, function(x) {
20 return Dygraph.DEFAULT_ATTRS.axes['x'][x];
21 });
22
23 // This breaks in Firefox & Safari:
24 // assertEquals([{"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);
25 };