query-066db862e93e9b8b946c559072e458d7

rq turtle/ttl

using https://cs.wikipedia.org/wiki/Algoritmus_pro_v%C3%BDpo%C4%8Det_dne_v_t%C3%BDdnu#Zeller%C5%AFv_algoritmus SELECT ?disaster ?disasterLabel ?start_time WHERE { ?disaster wdt:P31/wdt:P279* wd:Q3839081 ; wdt:P580 ?start_time . BIND( DAY( ?start_time ) AS ?q ) . FILTER( ?q = 13 ) . BIND( MONTH( ?start_time ) + IF( MONTH( ?start_time ) < 3, 12, 0 ) AS ?m ) . BIND( YEAR( ?start_time ) - IF( MONTH( ?start_time ) < 3, 1, 0 ) AS ?_year ) . BIND( ?_year - FLOOR( ?_year / 100 ) * 100 AS ?K ) . # modulo BIND( FLOOR( YEAR( ?start_time ) / 100 ) AS ?J ) . BIND( ?q + FLOOR( 13 * ( ?m + 1 ) / 5 ) + ?K + FLOOR( ?K / 4 ) + FLOOR( ?J / 4 ) - 2 * ?J AS ?_h ) . FILTER( ?_h - FLOOR( ?_h / 7 ) * 7 = 6 ) . # modulo, 0 is Saturday SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# using https://cs.wikipedia.org/wiki/Algoritmus_pro_v%C3%BDpo%C4%8Det_dne_v_t%C3%BDdnu#Zeller%C5%AFv_algoritmus
SELECT ?disaster ?disasterLabel ?start_time WHERE {
  ?disaster wdt:P31/wdt:P279* wd:Q3839081 ;
            wdt:P580 ?start_time .
  BIND( DAY( ?start_time ) AS ?q ) .
  FILTER( ?q = 13 ) .
  BIND( MONTH( ?start_time ) + IF( MONTH( ?start_time ) < 3, 12, 0 ) AS ?m ) .
  BIND( YEAR( ?start_time ) - IF( MONTH( ?start_time ) < 3, 1, 0 ) AS ?_year ) .
  BIND( ?_year - FLOOR( ?_year / 100 ) * 100 AS ?K ) . # modulo
  BIND( FLOOR( YEAR( ?start_time ) / 100 ) AS ?J ) .
  BIND( ?q + FLOOR( 13 * ( ?m + 1 ) / 5 ) + ?K + FLOOR( ?K / 4 ) + FLOOR( ?J / 4 ) - 2 * ?J AS ?_h ) .
  FILTER( ?_h - FLOOR( ?_h / 7 ) * 7 = 6 ) . # modulo, 0 is Saturday
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } .
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?J") v7("?K") v9("?_h") v6("?_year") v3("?disaster"):::projected v5("?m") v5("?q") v4("?start_time"):::projected a1((" ")) c9(["bd:serviceParam"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal c6(["wd:Q3839081"]):::iri f0[["?_h - numeric-floor(?_h / '7^^xsd:integer') * '7^^xsd:integer' = '6^^xsd:integer'"]] f0 --> v9 f1[["?q = '13^^xsd:integer'"]] f1 --> v5 v3 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c6 v3 --"wdt:P580"--> v4 bind2[/"day-from-dateTime(?start_time)"/] v4 --o bind2 bind2 --as--o v5 bind3[/"month-from-dateTime(?start_time) + if(month-from-dateTime(?start_time) < '3^^xsd:integer','12^^xsd:integer','0^^xsd:integer')"/] v4 --o bind3 bind3 --as--o v5 bind4[/"year-from-dateTime(?start_time) - if(month-from-dateTime(?start_time) < '3^^xsd:integer','1^^xsd:integer','0^^xsd:integer')"/] v4 --o bind4 bind4 --as--o v6 bind5[/"?_year - numeric-floor(?_year / '100^^xsd:integer') * '100^^xsd:integer'"/] v6 --o bind5 bind5 --as--o v7 bind6[/"numeric-floor(year-from-dateTime(?start_time) / '100^^xsd:integer')"/] v4 --o bind6 bind6 --as--o v8 bind7[/"?q + numeric-floor('13^^xsd:integer' * ?m + '1^^xsd:integer' / '5^^xsd:integer') + ?K + numeric-floor(?K / '4^^xsd:integer') + numeric-floor(?J / '4^^xsd:integer') - '2^^xsd:integer' * ?J"/] v5 --o bind7 v5 --o bind7 v7 --o bind7 v8 --o bind7 bind7 --as--o v9 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end