diff --git a/Start-DoneTickNotifier.ps1 b/Start-DoneTickNotifier.ps1 index 9571bb1..e5623d4 100644 --- a/Start-DoneTickNotifier.ps1 +++ b/Start-DoneTickNotifier.ps1 @@ -105,17 +105,27 @@ while ($true) { } Write-Host "Finding next notification time..." + $nextNotificationTomorrow = $true foreach($time in $notificationTimes) { $now = Get-Date $diff = $now.Hour - $time if ($diff -lt 0) # next notification time { + $nextNotificationTomorrow = $false 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" Start-Sleep -Seconds $sleepTime 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 + } } \ No newline at end of file