use of org.apache.jena.sparql.util.DateTimeStruct in project jena by apache.
the class XSDFuncOp method tzStrFromNV.
/** Get the timezone in XSD tiezone format (e.g. "Z" or "+01:00").
* Assumes the NodeValue is of suitable datatype.
*/
private static String tzStrFromNV(NodeValue nv) {
DateTimeStruct dts = parseAnyDT(nv);
if (dts == null)
return "";
String tzStr = dts.timezone;
if (tzStr == null)
tzStr = "";
return tzStr;
}
use of org.apache.jena.sparql.util.DateTimeStruct in project jena by apache.
the class XSDFuncOp method fixupDateTime.
private static NodeValue fixupDateTime(NodeValue nv) {
DateTimeStruct dts = DateTimeStruct.parseDateTime(nv.asNode().getLiteralLexicalForm());
if (dts.timezone != null)
return null;
dts.timezone = defaultTimezone;
nv = NodeValue.makeDateTime(dts.toString());
if (!nv.isDateTime())
throw new ARQInternalErrorException("Failed to reform an xsd:dateTime");
return nv;
}
use of org.apache.jena.sparql.util.DateTimeStruct in project jena by apache.
the class XSDFuncOp method dtGetTimezone.
public static NodeValue dtGetTimezone(NodeValue nv) {
DateTimeStruct dts = parseAnyDT(nv);
if (dts == null || dts.timezone == null)
throw new ExprEvalException("Not a datatype with a timezone: " + nv);
if ("".equals(dts.timezone))
return null;
if ("Z".equals(dts.timezone)) {
Node n = NodeFactory.createLiteral("PT0S", NodeFactory.getType(XSDDatatype.XSD + "#dayTimeDuration"));
return NodeValue.makeNode(n);
}
if ("+00:00".equals(dts.timezone)) {
Node n = NodeFactory.createLiteral("PT0S", NodeFactory.getType(XSDDatatype.XSD + "#dayTimeDuration"));
return NodeValue.makeNode(n);
}
if ("-00:00".equals(dts.timezone)) {
Node n = NodeFactory.createLiteral("-PT0S", NodeFactory.getType(XSDDatatype.XSD + "#dayTimeDuration"));
return NodeValue.makeNode(n);
}
String s = dts.timezone;
int idx = 0;
StringBuilder sb = new StringBuilder();
if (s.charAt(0) == '-')
sb.append('-');
// Skip '-' or '+'
idx++;
sb.append("PT");
digitsTwo(s, idx, sb, 'H');
idx += 2;
// The ":"
idx++;
digitsTwo(s, idx, sb, 'M');
idx += 2;
return NodeValue.makeNode(sb.toString(), null, XSDDatatype.XSD + "#dayTimeDuration");
}
Aggregations