use of org.wikidata.query.rdf.common.WikibaseDate in project wikidata-query-rdf by wikimedia.
the class WikibaseDateExtension method datePlusDuration.
/**
* Add Duration to date.
* @param iv
* @param d
* @param vf
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private IV datePlusDuration(LiteralExtensionIV iv, Duration d, BigdataValueFactory vf) {
long ts = iv.getDelegate().longValue();
WikibaseDate newdate = WikibaseDate.fromSecondsSinceEpoch(ts).addDuration(d);
LiteralExtensionIV result = new LiteralExtensionIV(new XSDNumericIV(newdate.secondsSinceEpoch()), iv.getExtensionIV());
result.setValue(safeAsValue(result, vf, getDataType(iv)));
return result;
}
use of org.wikidata.query.rdf.common.WikibaseDate in project wikidata-query-rdf by wikimedia.
the class WikibaseNowBOp method get.
/**
* Get expression value.
*/
public IV get(final IBindingSet bs) {
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT);
WikibaseDate wd = WikibaseDate.fromSecondsSinceEpoch(cal.getTimeInMillis() / 1000);
return super.asIV(getValueFactory().createLiteral(wd.toString(ToStringFormat.DATE_TIME), XMLSchema.DATETIME), bs);
}
Aggregations