fixed a bug for when the next notification time is tomorrow
Security / security (push) Successful in 1m6s
Security / security (push) Successful in 1m6s
This commit is contained in:
@@ -105,17 +105,27 @@ while ($true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Finding next notification time..."
|
Write-Host "Finding next notification time..."
|
||||||
|
$nextNotificationTomorrow = $true
|
||||||
foreach($time in $notificationTimes)
|
foreach($time in $notificationTimes)
|
||||||
{
|
{
|
||||||
$now = Get-Date
|
$now = Get-Date
|
||||||
$diff = $now.Hour - $time
|
$diff = $now.Hour - $time
|
||||||
if ($diff -lt 0) # next notification time
|
if ($diff -lt 0) # next notification time
|
||||||
{
|
{
|
||||||
|
$nextNotificationTomorrow = $false
|
||||||
Write-Host "Next notification time is $time`:00"
|
Write-Host "Next notification time is $time`:00"
|
||||||
$sleepTime = ($diff * -1) * 60
|
$sleepTime = ($diff * -1) * 60 * 60 # hours * mins * seconds
|
||||||
Write-Host "Sleeping for $sleepTime seconds"
|
Write-Host "Sleeping for $sleepTime seconds"
|
||||||
Start-Sleep -Seconds $sleepTime
|
Start-Sleep -Seconds $sleepTime
|
||||||
continue # leave loop
|
continue # leave loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($nextNotificationTomorrow)
|
||||||
|
{
|
||||||
|
Write-Host "Next notification time is $time`:00"
|
||||||
|
$diff = 24 - $now.Hour + $notificationTimes[0]
|
||||||
|
$sleepTime = $diff * 60 * 60 # hours * mins * seconds
|
||||||
|
Write-Host "Sleeping for $sleepTime seconds"
|
||||||
|
Start-Sleep -Seconds $sleepTime
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user