query-bf6caa56bbe08240c4f75b2ee598eb89
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?date ?dateLabel ?monthNumber ?dayNumber WHERE {
# a date item is a “determinator for date of periodic occurrence” and part of a month
?date wdt:P31 wd:Q14795564;
wdt:P361 ?month.
# a month is a month of the Gregorian calendar and has a month number
?month wdt:P279 wd:Q18602249;
wdt:P2837 ?monthNumber.
# February 30 and “first saturday in March” …
FILTER(?date NOT IN (wd:Q37096, wd:Q21130129)).
# and here it gets ugly, it seems there’s no way to get the date’s day except from the label
?date rdfs:label ?dateLabel. FILTER(LANG(?dateLabel) = "en").
?month rdfs:label ?monthLabel. FILTER(LANG(?monthLabel) = "en").
FILTER(STRSTARTS(?dateLabel, CONCAT(?monthLabel, " "@en))). # sanity check
BIND(xsd:integer(SUBSTR(?dateLabel, STRLEN(?monthLabel)+1)) AS ?dayNumber).
}
ORDER BY ?monthNumber ?dayNumber
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?date"):::projected
v3("?dateLabel"):::projected
v7("?dayNumber"):::projected
v6("?month")
v4("?monthLabel")
v1("?monthNumber"):::projected
c9(["wd:Q18602249"]):::iri
c6(["wd:Q14795564"]):::iri
f0[["starts-with(?dateLabel,concat(?monthLabel,s ^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>'))"]]
f0 --> v3
f0 --> v4
f1[["?monthLabel = 'en'"]]
f1 --> v4
f2[["?dateLabel = 'en'"]]
f2 --> v3
f3[["?date != 'wd:Q37096'?date != 'wd:Q21130129'"]]
f3 --> v5
v5 --"wdt:P31"--> c6
v5 --"wdt:P361"--> v6
v6 --"wdt:P279"--> c9
v6 --"wdt:P2837"--> v1
v5 --"rdfs:label"--> v3
v6 --"rdfs:label"--> v4
bind4[/"http://www.w3.org/2001/XMLSchema#integer(substring(?dateLabel,string-length(?monthLabel) + '+1^^xsd:integer'))"/]
v3 --o bind4
v4 --o bind4
bind4 --as--o v7