User:Jc3s5h/Date from Wikidata test cases

Parser function edit

From Wikipedia:Wikidata#Parser function

The simplest is to use the #statements parser function. For example, to get Madonna's date of birth you need to know the property number of "date of birth" which is P569. (You can find this by clicking the property on Wikidata.)
  • Placing the code {{#statements:P569}} on the Madonna article will then return: "16 August 1958".

But this isn't the Madonna article, so that won't work here. So add the item number, which for Madonna is Q1744.

{{#statements:P569|from=Q1744}} results in "16 August 1958".

Try an edge case, death date of Emperor Ai of Han:

{{#statements:P570|from=Q7237}} results in "15 August 1 BCE".

Module Wikidata edit

Module:Wikidata can be invoked directly in wiki source code. Using it for the Emperor Ai of Hah case:

{{#invoke:Wikidata|getValueFromID|Q7237|P570|FETCH_WIKIDATA}}

gives

15 August 1 BCE

Trying to get more data about this date:

{{#invoke:Wikidata|getValueFromID|Q7237|P570|FETCH_WIKIDATA=ALL}}

gives


Module WikidataIB edit

Using Emperor Ai of Hah again as an example,

{{#invoke:WikidataIB |getValue |P570 |qid=Q7237 |fwd=ALL |osd=no}}

gives

15 August 1 BC  

Help from RexxS:

If you want to see how the data is actually stored on Wikidata:
table#1 {
    table#2 {
        ["id"] = "Q1817$FFB1F533-8501-4599-8FB3-E6256454B847",
        ["mainsnak"] = table#3 {
            ["datatype"] = "time",
            ["datavalue"] = table#4 {
                ["type"] = "time",
                ["value"] = table#5 {
                    ["after"] = 0,
                    ["before"] = 0,
                    ["calendarmodel"] = "http://www.wikidata.org/entity/Q1985786",
                    ["precision"] = 9,
                    ["time"] = "+0204-00-00T00:00:00Z",
                    ["timezone"] = 0,
                },
            },
            ["property"] = "P569",
            ["snaktype"] = "value",
        },
        ["qualifiers"] = table#6 {
            ["P1480"] = table#7 {
                table#8 {
                    ["datatype"] = "wikibase-item",
                    ["datavalue"] = table#9 {
                        ["type"] = "wikibase-entityid",
                        ["value"] = table#10 {
                            ["entity-type"] = "item",
                            ["id"] = "Q5727902",
                            ["numeric-id"] = 5727902,
                        },
                    },
                    ["hash"] = "cb40f2027a88b8d23735681aaccba1069a574f54",
                    ["property"] = "P1480",
                    ["snaktype"] = "value",
                },
            },
        },
        ["qualifiers-order"] = table#11 {
            "P1480",
        },
        ["rank"] = "normal",
        ["references"] = table#12 {
            table#13 {
                ["hash"] = "bbfc00cd1443559e385efbed4e9d5118cd6c7305",
                ["snaks"] = table#14 {
                    ["P1810"] = table#15 {
                        table#16 {
                            ["datatype"] = "string",
                            ["datavalue"] = table#17 {
                                ["type"] = "string",
                                ["value"] = "PHILIPPE L'ARABE MARCUS JULIUS PHILIPPUS",
                            },
                            ["property"] = "P1810",
                            ["snaktype"] = "value",
                        },
                    },
                    ["P248"] = table#18 {
                        table#19 {
                            ["datatype"] = "wikibase-item",
                            ["datavalue"] = table#20 {
                                ["type"] = "wikibase-entityid",
                                ["value"] = table#21 {
                                    ["entity-type"] = "item",
                                    ["id"] = "Q1340194",
                                    ["numeric-id"] = 1340194,
                                },
                            },
                            ["property"] = "P248",
                            ["snaktype"] = "value",
                        },
                    },
                    ["P3219"] = table#22 {
                        table#23 {
                            ["datatype"] = "external-id",
                            ["datavalue"] = table#24 {
                                ["type"] = "string",
                                ["value"] = "marcus-julius-philippus-philippe-l-arabe",
                            },
                            ["property"] = "P3219",
                            ["snaktype"] = "value",
                        },
                    },
                    ["P813"] = table#25 {
                        table#26 {
                            ["datatype"] = "time",
                            ["datavalue"] = table#27 {
                                ["type"] = "time",
                                ["value"] = table#28 {
                                    ["after"] = 0,
                                    ["before"] = 0,
                                    ["calendarmodel"] = "http://www.wikidata.org/entity/Q1985727",
                                    ["precision"] = 11,
                                    ["time"] = "+2017-10-09T00:00:00Z",
                                    ["timezone"] = 0,
                                },
                            },
                            ["property"] = "P813",
                            ["snaktype"] = "value",
                        },
                    },
                },
                ["snaks-order"] = table#29 {
                    "P248",
                    "P3219",
                    "P1810",
                    "P813",
                },
            },
        },
        ["type"] = "statement",
    },
}