Search in sources :

Example 11 with XSDate

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate in project webtools.sourceediting by eclipse.

the class FnTimezoneFromDate method timezone_from_date.

/**
 * Timezone-from-Date operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:timezone-from-date operation.
 */
public static ResultSequence timezone_from_date(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return ResultBuffer.EMPTY;
    }
    XSDate dt = (XSDate) arg1.first();
    if (dt.timezoned()) {
        return dt.tz();
    }
    return ResultBuffer.EMPTY;
}
Also used : XSDate(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Collection(java.util.Collection)

Example 12 with XSDate

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate in project webtools.sourceediting by eclipse.

the class FnCurrentDate method current_date.

/**
 * Current-Date operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @param dc
 *            Result of dynamic context operation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:current-date operation.
 */
public static ResultSequence current_date(Collection args, DynamicContext dc) throws DynamicError {
    assert args.size() == 0;
    XSDayTimeDuration tz = new XSDayTimeDuration(dc.getTimezoneOffset());
    AnyType res = new XSDate(dc.getCurrentDateTime(), tz);
    return ResultSequenceFactory.create_new(res);
}
Also used : XSDate(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate) XSDayTimeDuration(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)

Example 13 with XSDate

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate in project webtools.sourceediting by eclipse.

the class FnDateTime method expected_args.

/**
 * Obtain a list of expected arguments.
 *
 * @return Result of operation.
 */
public static synchronized Collection expected_args() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        _expected_args.add(new SeqType(new XSDate(), SeqType.OCC_QMARK));
        _expected_args.add(new SeqType(new XSTime(), SeqType.OCC_QMARK));
    }
    return _expected_args;
}
Also used : XSDate(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate) SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList) XSTime(org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)

Example 14 with XSDate

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate in project webtools.sourceediting by eclipse.

the class FnAdjustDateToTimeZone method expectedArgs.

/**
 * Obtain a list of expected arguments.
 *
 * @return Result of operation.
 */
public static synchronized Collection expectedArgs() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        _expected_args.add(new SeqType(new XSDate(), SeqType.OCC_QMARK));
        _expected_args.add(new SeqType(new XSDayTimeDuration(), SeqType.OCC_QMARK));
    }
    return _expected_args;
}
Also used : XSDate(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate) SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList) XSDayTimeDuration(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration)

Example 15 with XSDate

use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate in project webtools.sourceediting by eclipse.

the class FnYearFromDate method year_from_date.

/**
 * Year-from-Date operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:year-from-date operation.
 */
public static ResultSequence year_from_date(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty()) {
        return ResultBuffer.EMPTY;
    }
    XSDate dt = (XSDate) arg1.first();
    int res = dt.year();
    return new XSInteger(BigInteger.valueOf(res));
}
Also used : XSDate(org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) XSInteger(org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger) Collection(java.util.Collection)

Aggregations

XSDate (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDate)13 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)6 SeqType (org.eclipse.wst.xml.xpath2.processor.internal.SeqType)6 Item (org.eclipse.wst.xml.xpath2.api.Item)5 Calendar (java.util.Calendar)4 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)4 GregorianCalendar (java.util.GregorianCalendar)3 XSDayTimeDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration)3 XSInteger (org.eclipse.wst.xml.xpath2.processor.internal.types.XSInteger)3 Iterator (java.util.Iterator)2 XSTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSTime)2 Duration (javax.xml.datatype.Duration)1 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)1 XSDateTime (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime)1 XSDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDuration)1