Time#

class wikibaseintegrator.datatypes.time.Time(time=None, before=0, after=0, precision=None, timezone=0, calendarmodel=None, wikibase_url=None, **kwargs)[source]#

Bases: BaseDataType

Implements the Wikibase data type with date and time values

Constructor, calls the superclass BaseDataType

Parameters:
  • time (str | None, default: None) – Explicit value for point in time, represented as a timestamp resembling ISO 8601. You can use the keyword ‘now’ to get the current UTC date.

  • prop_nr – The property number for this claim

  • before (int, default: 0) – explicit integer value for how many units after the given time it could be. The unit is given by the precision.

  • after (int, default: 0) – explicit integer value for how many units before the given time it could be. The unit is given by the precision.

  • precision (int | WikibaseTimePrecision | None, default: None) – Precision value for dates and time as specified in the Wikibase data model (https://www.wikidata.org/wiki/Special:ListDatatypes#time)

  • timezone (int, default: 0) – The timezone which applies to the date and time as specified in the Wikibase data model

  • calendarmodel (str | None, default: None) – The calendar model used for the date. URL to the Wikibase calendar model item or the QID.

static sparql_time(time, precision=None)[source]#

Return the timestamp in the form the Wikibase RDF export stores it: the month and the day are set to 01 when they are unknown (‘00’) or below the precision. ‘+1987-00-00T00:00:00Z’ and ‘+1987-05-17T00:00:00Z’ with a year precision both become ‘+1987-01-01T00:00:00Z’.

Parameters:
  • time (str) – A timestamp, as found in the JSON representation.

  • precision (int | None, default: None) – The precision of the timestamp.

Return type:

str

Returns:

The normalized timestamp.

from_sparql_value(sparql_value)[source]#

Parse data returned by a SPARQL endpoint and set the value to the object

Parameters:

sparql_value (dict) – A SPARQL value composed of type and value

Return type:

Self

Returns:

get_day()[source]#
Return type:

int

get_month()[source]#
Return type:

int

get_sparql_value(**kwargs)[source]#
Return type:

str

get_year()[source]#
Return type:

int

set_value(time=None, before=0, after=0, precision=None, timezone=0, calendarmodel=None, wikibase_url=None)[source]#
Return type:

None

DTYPE = 'time'#
PTYPE = 'http://wikiba.se/ontology#Time'#