public static NodeValue _makeNodeValue(Calendar o) { return NodeValue.makeDate(o); }
nodeValue = NodeValue.makeDate(tmp);
@Test public void testCompare17() { // One in a timezone, one not. Within +/- 14 hours. Can't compare. NodeValue nv1 = NodeValue.makeDate("2007-08-31") ; NodeValue nv2 = NodeValue.makeDate("2007-08-31Z") ; try { NodeValue.compare(nv1, nv2) ; assertFalse("Compared the uncomparable: "+nv1+" & "+nv2, true) ; } catch (ExprNotComparableException ex) {} }
NodeValue r = NodeValue.makeDate(result) ; return r ;
@Test public void testDate1() { Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // Clear/ set all fields (milliseconds included). cal.setTimeInMillis(0); // NB Months from 0, not 1 // For a date, must be time = 00:00:00 cal.set(2005, 01, 18, 0, 0, 0); NodeValue v = NodeValue.makeDate(cal); assertTrue("Not a date: " + v, v.isDate()); assertFalse("A dateTime: " + v, v.isDateTime()); // DateTimes always have nodes because we used that to parse the thing. }
NodeValue r = NodeValue.makeDate(result) ; return r ;
@Test(expected=ExprEvalTypeException.class) public void cast_gregorian_32() { testDateTimeCast(nv_gy, XSDDatatype.XSDdate, NodeValue.makeDate("2010-01-01")) ; }
@Test public void exprAdjustDateToTz_03() { test("fn:adjust-date-to-timezone('2002-03-07'^^xsd:date,'-PT10H'^^xsd:dayTimeDuration)",NodeValue.makeDate("2002-03-07-10:00"));}
@Test public void exprAdjustDateToTz_04() { test("fn:adjust-date-to-timezone('2002-03-07-07:00'^^xsd:date,'-PT10H'^^xsd:dayTimeDuration)",NodeValue.makeDate("2002-03-06-10:00"));}
@Test public void exprAdjustDateToTz_05() { test("fn:adjust-date-to-timezone('2002-03-07'^^xsd:date,'')",NodeValue.makeDate("2002-03-07"));}
@Test public void exprAdjustDateToTz_06() { test("fn:adjust-date-to-timezone('2002-03-07-07:00'^^xsd:date,'')",NodeValue.makeDate("2002-03-07"));}
private static NodeValue fixupDate(NodeValue nv) { DateTimeStruct dts = DateTimeStruct.parseDate(nv.asNode().getLiteralLexicalForm()) ; if ( dts.timezone != null ) return null ; dts.timezone = defaultTimezone ; nv = NodeValue.makeDate(dts.toString()) ; if ( !nv.isDate() ) throw new ARQInternalErrorException("Failed to reform an xsd:date") ; return nv ; }
@Test public void testSameDate_3() { NodeValue nv1 = NodeValue.makeDate("2007-09-04Z") ; NodeValue nv2 = NodeValue.makeDate("2007-09-04") ; // No timezone try { NodeValue.sameAs(nv1, nv2) ; fail("Should not sameValueAs (but did) "+nv1+" & "+nv2) ; } catch (ExprEvalException ex) {} try { NodeValue.notSameAs(nv1, nv2) ; fail("Should not notSameValueAs (but did) "+nv1+" & "+nv2) ; } catch (ExprEvalException ex) {} }
@Test public void testCompare15() { NodeValue nv1 = NodeValue.makeDate("2005-10-14Z") ; NodeValue nv2 = NodeValue.makeNodeDateTime("2005-10-14T14:09:43Z") ; try { NodeValue.compare(nv1, nv2) ; assertFalse("Compared the uncomparable: "+nv1+" & "+nv2, true) ; } catch (ExprNotComparableException ex) {} }
@Test public void testCompare12() { if ( ! ARQ.isTrue(ARQ.strictSPARQL) ) { NodeValue nv1 = NodeValue.makeDate("2006-07-21-08:00") ; // Different timezones NodeValue nv2 = NodeValue.makeNodeDate("2006-07-21+01:00") ; assertEquals("Does not compare "+nv1+" & "+nv2, NodeValue.CMP_GREATER, NodeValue.compare(nv1, nv2) ) ; } }
@Test public void testDate3() { NodeValue v1 = NodeValue.makeDate("2005-02-18+01:00"); NodeValue v2 = NodeValue.makeNodeDate("2005-02-18+01:00"); assertEquals("Not Calendar.equals: ", v1.getDateTime(), v2.getDateTime()); }