From f41ea74380f351de1df4ec24c7622b4d506a6059 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 7 Feb 2025 15:43:55 +0100 Subject: [PATCH] Update rest responses to have UTC sortable dates --- src/functions/public/API/Invoke-GitHubAPI.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index c06dfe242..797463741 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -237,6 +237,21 @@ filter Invoke-GitHubAPI { $headers[$item.Key] = ($item.Value).Trim() -join ', ' } $headers = [pscustomobject]$headers + if ($headers.'x-ratelimit-reset') { + $headers.'x-ratelimit-reset' = [DateTime]::UnixEpoch.AddSeconds( + $headers.'x-ratelimit-reset' + ).ToString('s') + } + if ($headers.'Date') { + $headers.'Date' = [DateTime]::Parse( + ($headers.'Date').Replace('UTC', '').Trim() + ).ToString('s') + } + if ($headers.'github-authentication-token-expiration') { + $headers.'github-authentication-token-expiration' = [DateTime]::Parse( + ($headers.'github-authentication-token-expiration').Replace('UTC', '').Trim() + ).ToString('s') + } $sortedProperties = $headers.PSObject.Properties.Name | Sort-Object $headers = $headers | Select-Object $sortedProperties Write-Debug 'Response headers:'