From 016c35a53c65f6e057ec3bef76aa711b263e4cea Mon Sep 17 00:00:00 2001 From: George Madrid Date: Mon, 10 Feb 2014 10:33:41 -0500 Subject: [PATCH] Responding to Dan's feedback. --- auto_tests/tests/TwoDigitYears.js | 22 ---------------------- auto_tests/tests/two_digit_years.js | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 22 deletions(-) delete mode 100644 auto_tests/tests/TwoDigitYears.js create mode 100644 auto_tests/tests/two_digit_years.js diff --git a/auto_tests/tests/TwoDigitYears.js b/auto_tests/tests/TwoDigitYears.js deleted file mode 100644 index aeb030e..0000000 --- a/auto_tests/tests/TwoDigitYears.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @fileoverview Test to check that years < 100 get the correct ticks. - * - * @author gmadrid@gmail.com (George Madrid) - */ -var TwoDigitYearsTestCase = TestCase("TwoDigitYears"); - -TwoDigitYearsTestCase.prototype.testTwoDigitYears = function() { - var start = new Date(9, 2, 3); - var end = new Date(11, 3, 5); - - // Javascript will automatically add 1900 to our years if they are < 100. - // Use setFullYear() to get the actual years we desire. - start.setFullYear(9); - end.setFullYear(11); - - var ticks = Dygraph.getDateAxis(start, end, Dygraph.QUARTERLY, function(x) { - return Dygraph.DEFAULT_ATTRS.axes['x'][x]; - }); - - 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); -}; diff --git a/auto_tests/tests/two_digit_years.js b/auto_tests/tests/two_digit_years.js new file mode 100644 index 0000000..e6e13be --- /dev/null +++ b/auto_tests/tests/two_digit_years.js @@ -0,0 +1,24 @@ +/** + * @fileoverview Test to check that years < 100 get the correct ticks. + * + * @author gmadrid@gmail.com (George Madrid) + */ +var TwoDigitYearsTestCase = TestCase("TwoDigitYears"); + +TwoDigitYearsTestCase.prototype.testTwoDigitYears = function() { + // A date with a one digit year: '9 AD'. + var start = new Date(9, 2, 3); + // A date with a two digit year: '11 AD'. + var end = new Date(11, 3, 5); + + // Javascript will automatically add 1900 to our years if they are < 100. + // Use setFullYear() to get the actual years we desire. + start.setFullYear(9); + end.setFullYear(11); + + var ticks = Dygraph.getDateAxis(start, end, Dygraph.QUARTERLY, function(x) { + return Dygraph.DEFAULT_ATTRS.axes['x'][x]; + }); + + 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); +}; -- 2.7.4