From ee32d8600bae029252e8e8d3daa6162243025a3e Mon Sep 17 00:00:00 2001 From: kotlanj Date: Mon, 27 Oct 2025 12:08:25 +0100 Subject: [PATCH] holiday check --- shifts.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shifts.ps1 b/shifts.ps1 index 84c5e39..157f7b2 100644 --- a/shifts.ps1 +++ b/shifts.ps1 @@ -153,6 +153,10 @@ $response = Invoke-RestMethod $authUri -Method 'POST' -Body $body $token = $response.access_token +$headers_holiday = @{} + +$headers_holiday.Add("Accept", "application/json") + Import-Module Microsoft.Graph.Teams Connect-MgGraph -AccessToken $($token | ConvertTo-SecureString -AsPlainText -Force) >> $null @@ -225,6 +229,14 @@ try { continue } + # ---| HOLIDAY CHECK |--- + $holiday_response = (Invoke-WebRequest -Uri "https://svatky.steelants.cz/api/$($dayDate.ToString('yyyy-MM-dd'))" -Method GET -Headers $headers_holiday) | ConvertFrom-Json + + if($holiday_response.isPublicHoliday) { + Write-Debug("{0} {1}: skipping holiday" -f $dayDate, $dayDate.DayOfWeek) + continue + } + # ---| NEW DAY INIT |--- $ds_shift_inplace = $false $ho_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ho'