iwf
    Preparing search index...

    Class TimeSnak

    Class for the TimeSnak.

    Most used property of this type is P1619 (date of official opening).

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    after: undefined | number
    before: undefined | number
    calendarmodel: undefined | CalendarModels
    datatype: string = 'time'
    hash: undefined | string
    precision: undefined | number
    property: `P${number}`
    snaktype: SnakType
    time: undefined | string
    timezone: undefined | number

    Accessors

    • get hasValue(): boolean

      Checks if the snak has a value.

      Returns boolean

      True if the snak has a value.

    • get internalID(): string

      Creates a unique ID for the Snak.

      Returns string

      The ID.

    Methods

    • This function checks if two snaks are equal.

      Parameters

      Returns boolean

      True if the snaks are equal.

      if (snak.equals(other)) {
      // do something
      }
    • Dates only, so add all of the date (year, month, day).

      Parameters

      • property: `P${number}`

        The property of the snak in 'P-form'.

      • year: number

        The year of the date.

      • month: number

        The month of the date (1-12), so just the normal months.

      • day: number

        The day of the date (1-31).

      • calendarModel: CalendarModels = 'http://www.wikidata.org/entity/Q1985727'

        The calendar model for the snak.

      Returns TimeSnak

      The TimeSnak.

      const snak = TimeSnak.fromDate('P1619', 2020, 1, 30, 'http://www.wikidata.org/entity/Q1985727');
      
    • Create a TimeSnak from a Date object.

      WARNING: JS Dates are horrible and you should not use them. Use a library like moment.js instead. When using it normally you should be fine, but anything before 1970 will be wrong. Also, timezones are not supported, so you need to use UTC which conflicts with Wikidata that assumes that all dates are in the local timezone.

      Parameters

      • property: `P${number}`

        The property of the snak in 'P-form'.

      • date: Date

        The Date object.

      • calendarModel: CalendarModels = 'http://www.wikidata.org/entity/Q1985727'

        The calendar model for the snak.

      Returns TimeSnak

      The TimeSnak.

      const snak = TimeSnak.fromDateObject('P1619', new Date(), 'http://www.wikidata.org/entity/Q1985727');