Merge pull request #87 from OpzekerIT/dev

first from yesterday
This commit is contained in:
Lanta 2023-11-06 16:26:37 +01:00 committed by GitHub
commit 951d3f9a06

View file

@ -46,7 +46,7 @@ function get-killstats {
} }
} }
# Get the latest file in the directory by last modification time
try { try {
$filesarray = @() $filesarray = @()
$files = Get-ChildItem -Path "$scriptroot/../data/archive/" -File -ErrorAction Stop $files = Get-ChildItem -Path "$scriptroot/../data/archive/" -File -ErrorAction Stop
@ -55,18 +55,15 @@ try {
$format = 'yyyy-MM-ddTHH-mm-ss\Z' $format = 'yyyy-MM-ddTHH-mm-ss\Z'
$culture = [Globalization.CultureInfo]::InvariantCulture $culture = [Globalization.CultureInfo]::InvariantCulture
$dateTime = [datetime]::ParseExact($dateinfile, $format, $culture) $dateTime = [datetime]::ParseExact($dateinfile, $format, $culture)
$filesarray += [PSCustomObject]@{name = $file.Name; date = $dateTime } $filesarray += [PSCustomObject]@{name = $file.Name; date = $dateTime }
} }
$latestFile = ($filesarray | where-object { ($_.date -gt (get-date).AddDays(-2)) -and ($_.date -lt (get-date).AddDays(-1))} | Sort-Object date)[0]
$latestFile = ($filesarray | where-object { ($_.date -gt (get-date).AddDays(-2)) -and ($_.date -lt (get-date).AddDays(-1))} | Sort-Object date)[-1]
$latestFile = Get-Item -Path "$scriptroot/../data/archive/$($latestFile.name)" $latestFile = Get-Item -Path "$scriptroot/../data/archive/$($latestFile.name)"
Write-Output "Found file $($latestFile.FullName)" Write-Output "Found file $($latestFile.FullName)"
} }
catch { catch {
$latestFile = @() $latestFile = @()
} }
# Display the result # Display the result