Github user afs commented on a diff in the pull request:
https://github.com/apache/jena/pull/148#discussion_r66244682
--- Diff:
jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java ---
@@ -1554,4 +1551,55 @@ private static Duration
valueCanonicalDuration(NodeValue nv) {
// dur = ...
return dur ;
}
+
+ public static NodeValue adjustDatetimeToTimezone(NodeValue
nv1,NodeValue nv2){
+ if(nv1 == null)
+ return null;
+
+ if(!nv1.isDateTime() && !nv1.isDate() && !nv1.isTime()){
+ throw new ExprEvalException("Not a valid date, datetime or
time:"+nv1);
+ }
+
+ XMLGregorianCalendar calValue = nv1.getDateTime();
+ Boolean hasTz = calValue.getTimezone() !=
DatatypeConstants.FIELD_UNDEFINED;
+ int inputOffset = 0;
+ if(hasTz){
+ inputOffset = calValue.getTimezone();
+ }
+
+ int tzOffset = TimeZone.getDefault().getRawOffset() / (1000*60);
+ if(nv2 != null){
+ if(!nv2.isDuration()) {
+ String nv2StrValue = nv2.getString();
+ if(nv2StrValue.equals("")){
+
calValue.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
+ if(nv1.isDateTime())
+ return NodeValue.makeDateTime(calValue);
+ else if(nv1.isTime())
+ return
NodeValue.makeNode(calValue.toXMLFormat(),XSDDatatype.XSDtime);
+ else
+ return NodeValue.makeDate(calValue);
+ }
+ throw new ExprEvalException("Not a valid duration:" + nv2);
+ }
+ Duration tzDuration = nv2.getDuration();
--- End diff --
```} else {
tzOffset = TimeZone.getDefault().getOffset(new
Date().getTime())/(1000*60) ;
}
```
so `new Date` is only called if needed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---