Class TimeSnak

class for the TimeSnak

most used property of this type P1619 (date of official opening)

Hierarchy (view full)

Constructors

Properties

after: undefined | number
before: undefined | number
calendarmodel: undefined | "http://www.wikidata.org/entity/Q1985727" | "http://www.wikidata.org/entity/Q1985786"
datatype: string = 'time'
hash: undefined | string
precision: undefined | number
property: `P${number}`
snaktype: SnakType
time: undefined | string
timezone: undefined | number

Accessors

  • get hasValue(): boolean
  • Returns boolean

    true if the snak has a value

  • get internalID(): string
  • create 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

    Example

    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 calendarModel for the snak

    Returns TimeSnak

    the timeSnak

    Example

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

    WARNING: JS Date 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 is 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 calendarModel for the snak

    Returns TimeSnak

    the timeSnak

    Example

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

Generated using TypeDoc