Search in sources :

Example 1 with WikibaseDate

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;
}
Also used : WikibaseDate(org.wikidata.query.rdf.common.WikibaseDate) XSDNumericIV(com.bigdata.rdf.internal.impl.literal.XSDNumericIV) LiteralExtensionIV(com.bigdata.rdf.internal.impl.literal.LiteralExtensionIV)

Example 2 with WikibaseDate

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);
}
Also used : WikibaseDate(org.wikidata.query.rdf.common.WikibaseDate) Calendar(java.util.Calendar)

Aggregations

WikibaseDate (org.wikidata.query.rdf.common.WikibaseDate)2 LiteralExtensionIV (com.bigdata.rdf.internal.impl.literal.LiteralExtensionIV)1 XSDNumericIV (com.bigdata.rdf.internal.impl.literal.XSDNumericIV)1 Calendar (java.util.Calendar)1