Hans_Henrik Skrevet 7. juli 2021 Del Skrevet 7. juli 2021 trenger en liste over røde dager i Norge i 2021 i et format som kan leses programmatisk (eg JSON/XML/sql), noen som vet hvor jeg kan finne en sånn liste? Lenke til kommentar
Hans_Henrik Skrevet 7. juli 2021 Forfatter Del Skrevet 7. juli 2021 (endret) ... laget en parser for copy-pasting av lista her https://www.timeanddate.com/calendar/?country=18 $days_raw = <<<'DAYS_RAW' copy-paste the list from https://www.timeanddate.com/calendar/?country=18 here DAYS_RAW; $days=[]; foreach(explode("\n",trim($days_raw)) as $line){ $line=trim($line); if(!preg_match("/(?<day_of_month>\d+)\s+(?<month_name>\S+)\s+(?<day_name>\S+)\s+(?<red_day_name>[\s\S]*?)\s*\t\s*(?<type_of_red_day>[\s\S]*)/",$line,$matches)){ throw new \RuntimeException("regex failed on: {$line}"); } $date=$matches["day_of_month"]." ".$matches["month_name"]." ".date("Y"); $date=(new DateTime($date, timezone_open("Europe/Oslo")))->format(DateTime::RFC3339); $days[$date]=["type"=>$matches["type_of_red_day"],"name"=>$matches["red_day_name"]]; } echo json_encode($days,JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); gir { "2021-01-01T00:00:00+01:00": { "type": "National holiday", "name": "New Year's Day" }, "2021-01-21T00:00:00+01:00": { "type": "Flag day", "name": "Princess Ingrid Alexandra's day" }, "2021-02-06T00:00:00+01:00": { "type": "Flag day", "name": "The Saami people's day" }, "2021-02-14T00:00:00+01:00": { "type": "Observance", "name": "Valentine's Day" }, "2021-02-21T00:00:00+01:00": { "type": "Flag day", "name": "King Harald V's day" }, "2021-03-20T00:00:00+01:00": { "type": "Season", "name": "March Equinox" }, "2021-03-28T00:00:00+01:00": { "type": "Clock change/Daylight Saving Time", "name": "Daylight Saving Time starts" }, "2021-04-01T00:00:00+02:00": { "type": "National holiday", "name": "Maundy Thursday" }, "2021-04-02T00:00:00+02:00": { "type": "National holiday", "name": "Good Friday" }, "2021-04-03T00:00:00+02:00": { "type": "Observance", "name": "Holy Saturday" }, "2021-04-04T00:00:00+02:00": { "type": "National holiday", "name": "Easter Sunday" }, "2021-04-05T00:00:00+02:00": { "type": "National holiday", "name": "Easter Monday" }, "2021-05-01T00:00:00+02:00": { "type": "National holiday, Flag day", "name": "Labor day" }, "2021-05-08T00:00:00+02:00": { "type": "Observance, Flag day", "name": "Day of liberation" }, "2021-05-13T00:00:00+02:00": { "type": "National holiday", "name": "Ascension Day" }, "2021-05-17T00:00:00+02:00": { "type": "National holiday, Flag day", "name": "17 May Constitution Day (1814)" }, "2021-05-22T00:00:00+02:00": { "type": "Observance", "name": "Whit Saturday" }, "2021-05-23T00:00:00+02:00": { "type": "National holiday", "name": "Whit Sunday" }, "2021-05-24T00:00:00+02:00": { "type": "National holiday", "name": "Whit Monday" }, "2021-06-07T00:00:00+02:00": { "type": "Flag day", "name": "Dissolution of union with Sweden (1905)" }, "2021-06-21T00:00:00+02:00": { "type": "Season", "name": "June Solstice" }, "2021-06-23T00:00:00+02:00": { "type": "Observance", "name": "Midsummer Eve" }, "2021-06-24T00:00:00+02:00": { "type": "Observance", "name": "St. John's day" }, "2021-07-04T00:00:00+02:00": { "type": "Flag day", "name": "Queen Sonja's day" }, "2021-07-20T00:00:00+02:00": { "type": "Flag day", "name": "Crown Prince Haakon's day" }, "2021-07-29T00:00:00+02:00": { "type": "Flag day", "name": "St. Olaf's day" }, "2021-08-19T00:00:00+02:00": { "type": "Flag day", "name": "Crown Princess Mette-Marit's day" }, "2021-09-13T00:00:00+02:00": { "type": "Flag day", "name": "Election day" }, "2021-09-22T00:00:00+02:00": { "type": "Season", "name": "September Equinox" }, "2021-10-24T00:00:00+02:00": { "type": "Observance", "name": "United Nations Day" }, "2021-10-31T00:00:00+02:00": { "type": "Clock change/Daylight Saving Time", "name": "Daylight Saving Time ends" }, "2021-11-07T00:00:00+01:00": { "type": "Observance", "name": "All Saints' Day" }, "2021-11-14T00:00:00+01:00": { "type": "Observance", "name": "Father's Day" }, "2021-11-28T00:00:00+01:00": { "type": "Observance", "name": "First Advent Sunday" }, "2021-12-05T00:00:00+01:00": { "type": "Observance", "name": "Second Advent Sunday" }, "2021-12-12T00:00:00+01:00": { "type": "Observance", "name": "Third Advent Sunday" }, "2021-12-19T00:00:00+01:00": { "type": "Observance", "name": "Fourth Advent Sunday" }, "2021-12-21T00:00:00+01:00": { "type": "Season", "name": "December Solstice" }, "2021-12-24T00:00:00+01:00": { "type": "Bank Holiday / Observance", "name": "Christmas Eve" }, "2021-12-25T00:00:00+01:00": { "type": "National holiday", "name": "Christmas Day" }, "2021-12-26T00:00:00+01:00": { "type": "National holiday", "name": "Boxing Day" }, "2021-12-31T00:00:00+01:00": { "type": "Observance", "name": "New Year's Eve" } } men.. jeg tviler på at de egentlig ønsker at folk skal parse websiden dems på den måten =/ hvis noen har noen bedre forslag, im all ears. Endret 7. juli 2021 av Hans_Henrik code blocks Lenke til kommentar
NULL Skrevet 8. juli 2021 Del Skrevet 8. juli 2021 https://webapi.no/api/v1/holidays/2021 1 Lenke til kommentar
Hans_Henrik Skrevet 8. juli 2021 Forfatter Del Skrevet 8. juli 2021 3 hours ago, NULL said: https://webapi.no/api/v1/holidays/2021 perfekt! takker, er det din api? Lenke til kommentar
NULL Skrevet 8. juli 2021 Del Skrevet 8. juli 2021 13 minutes ago, Hans_Henrik said: perfekt! takker, er det din api? Nope, ikke noe jeg har noen tilknytting til. Men ligger litt forskjellige API-er på https://webapi.no/ som kan være nyttige, uten at jeg nødvendigvis vet om det er noe som er lurt å bruke i et kritisk prodmiljø med tanke på oppetid osv😉 Lenke til kommentar
quantum Skrevet 10. november 2021 Del Skrevet 10. november 2021 Jollyday (github) Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå