@Test public void testDateScaleHoursOrLess() { Field a; double[] pad = {0, 0}; a = Data.toDate(Data.makeColumnField("a", "label", new Object[] {"09:45:22", "09:45:24"})); Assert.assertEquals( "date : 09:45:22 09:45:24 : |09:45:22|09:45:23|09:45:24", asString(NumericScale.makeDateScale(a, false, pad, 5), a)); a = Data.toDate(Data.makeColumnField("a", "label", new Object[] {"09:45:22", "09:45:54"})); assertEquals(0.40650462963, a.min(), 1e-9); assertEquals(0.406875, a.max(), 1e-9); Assert.assertEquals( "date : 09:45:22 09:45:54 : |09:45:30|09:45:40|09:45:50", asString(NumericScale.makeDateScale(a, false, pad, 5), a)); a = Data.toDate(Data.makeColumnField("a", "label", new Object[] {"09:45:22", "09:45:54"})); Assert.assertEquals( "date : 09:45:20 09:46:00 : |09:45:20|09:45:30|09:45:40|09:45:50|09:46:00", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate(Data.makeColumnField("a", "label", new Object[] {"09:45:22", "10:01:54"})); Assert.assertEquals( "date : 09:45 10:05 : |09:45|09:50|09:55|10:00|10:05", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate(Data.makeColumnField("a", "label", new Object[] {"09:45:22", "12:01:54"})); Assert.assertEquals( "date : 09:30 12:30 : |09:30|10:00|10:30|11:00|11:30|12:00|12:30", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate(Data.makeColumnField("a", "label", new Object[] {"09:45:22", "23:01:54"})); Assert.assertEquals( "date : 09:00 00:00 : |09:00|12:00|15:00|18:00|21:00|00:00", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); }
@Test public void testDateScaleDaysPlusRange() { double[] pad = {0, 0}; Field a = Data.toDate( Data.makeColumnField( "a", "label", new Object[] {"January 9, 2010", "January 9, 2010"})); Assert.assertEquals( "date : 2000 2020 : |2005|2010|2015|2020", asString(NumericScale.makeDateScale(a, false, pad, 5), a)); a = Data.toDate( Data.makeColumnField( "a", "label", new Object[] {"January 9, 2010", "January 10, 2010"})); Assert.assertEquals( "date : 00:00 00:00 : |00:00|06:00|12:00|18:00|00:00", asString(NumericScale.makeDateScale(a, false, pad, 5), a)); a = Data.toDate( Data.makeColumnField( "a", "label", new Object[] {"January 9, 2010", "January 14, 2010"})); Assert.assertEquals( "date : Jan 9, 2010 Jan 14, 2010 : |Jan 9, 2010|Jan 10, 2010|Jan 11, 2010|Jan 12, 2010|Jan 13, 2010|Jan 14, 2010", asString(NumericScale.makeDateScale(a, false, pad, 5), a)); a = Data.toDate( Data.makeColumnField( "a", "label", new Object[] {"January 9, 2010", "January 14, 2010"})); Assert.assertEquals( "date : Jan 9, 2010 Jan 14, 2010 : |Jan 9, 2010|Jan 10, 2010|Jan 11, 2010|Jan 12, 2010|Jan 13, 2010|Jan 14, 2010", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate( Data.makeColumnField("a", "label", new Object[] {"January 9, 2010", "August 9, 2010"})); Assert.assertEquals( "date : Jan 2010 Aug 2010 : |Mar 2010|May 2010|Jul 2010", asString(NumericScale.makeDateScale(a, false, pad, 5), a)); a = Data.toDate( Data.makeColumnField("a", "label", new Object[] {"January 9, 2010", "August 9, 2010"})); Assert.assertEquals( "date : Jan 2010 Sep 2010 : |Jan 2010|Mar 2010|May 2010|Jul 2010|Sep 2010", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate( Data.makeColumnField("a", "label", new Object[] {"January 9, 2010", "August 9, 2011"})); Assert.assertEquals( "date : Jan 2010 Jan 2012 : |Jan 2010|Jul 2010|Jan 2011|Jul 2011|Jan 2012", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate( Data.makeColumnField("a", "label", new Object[] {"January 9, 2010", "August 9, 2014"})); Assert.assertEquals( "date : Jan 2010 Jan 2015 : |Jan 2010|Jan 2011|Jan 2012|Jan 2013|Jan 2014|Jan 2015", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate( Data.makeColumnField("a", "label", new Object[] {"January 9, 2010", "August 9, 2024"})); Assert.assertEquals( "date : 2010 2025 : |2010|2015|2020|2025", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate( Data.makeColumnField("a", "label", new Object[] {"January 9, 2010", "August 9, 2124"})); Assert.assertEquals( "date : 2000 2140 : |2000|2020|2040|2060|2080|2100|2120|2140", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); a = Data.toDate( Data.makeColumnField("a", "label", new Object[] {"January 9, 2010", "August 9, 6124"})); Assert.assertEquals( "date : 2000 6500 : |2000|2500|3000|3500|4000|4500|5000|5500|6000|6500", asString(NumericScale.makeDateScale(a, true, pad, 5), a)); }