Skip to content

Commit

Permalink
Address Get-Date Culture issue (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee authored Sep 14, 2022
1 parent c7dae64 commit 7ec9dbc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion public/Get-KbUpdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,18 @@ function Get-KbUpdate {


if ($lastmodified) {
$lastmod = Get-Date $lastmodified -Format "yyyy-MM-dd"
$lastmodified = $lastmodified.Replace(" ", "").Replace(".","/")
if ("$(Get-Culture)" -ne "en-US") {
try {
$datetime = [DateTime]::ParseExact("$lastmodified 12:00:00 AM", "M/d/yyyy h:mm:ss tt",[System.Globalization.DateTimeFormatInfo]::InvariantInfo, "None")
$lastmod = Get-Date $datetime -Format "yyyy-MM-dd"
} catch {
$lastmod = $null
}
} else {
$lastmod = Get-Date $lastmodified -Format "yyyy-MM-dd"
}

} else {
$lastmod = $null
}
Expand Down

0 comments on commit 7ec9dbc

Please sign in to comment.