Update the scripts

This commit is contained in:
Markus Fleschutz 2021-12-13 10:52:50 +01:00
parent 50ea7be8f1
commit 7b5165e34d
2 changed files with 19 additions and 7 deletions

View File

@ -14,12 +14,20 @@
try { try {
$Now = [DateTime]::Now $Now = [DateTime]::Now
$Christmas = [Datetime]("12/25/" + $Now.Year) $Christmas = [Datetime]("12/25/" + $Now.Year)
if ($Now -lt $Christmas) { $Days = ($Christmas - $Now).Days
$Diff = $Christmas $Now if ($Days -gt 1) {
& "$PSScriptRoot/give-reply.ps1" "Christmas on December 25 is in $($Diff.Days) days." & "$PSScriptRoot/give-reply.ps1" "Christmas is in $Days days."
} elseif ($Days -eq 1) {
& "$PSScriptRoot/give-reply.ps1" "Christmas is tomorrow."
} elseif ($Days -eq 0) {
& "$PSScriptRoot/give-reply.ps1" "Christmas is today."
} elseif ($Days -eq 1) {
& "$PSScriptRoot/give-reply.ps1" "Christmas is tomorrow."
} elseif ($Days -eq -1) {
& "$PSScriptRoot/give-reply.ps1" "Christmas was yesterday."
} else { } else {
$Diff = $Now - $Christmas $Days = -$Days
& "$PSScriptRoot/give-reply.ps1" "Christmas on December 25 was $($Diff.Days) days ago." & "$PSScriptRoot/give-reply.ps1" "Christmas was $Days days ago."
} }
exit 0 # success exit 0 # success
} catch { } catch {

View File

@ -14,8 +14,12 @@
try { try {
$Now = [DateTime]::Now $Now = [DateTime]::Now
$NewYear = [Datetime]("12/31/" + $Now.Year) $NewYear = [Datetime]("12/31/" + $Now.Year)
$Diff = $NewYear $Now $Days = ($NewYear $Now).Days + 1
& "$PSScriptRoot/give-reply.ps1" "New Year is in $($Diff.Days) days." if ($Days -gt 1) {
& "$PSScriptRoot/give-reply.ps1" "New Year is in $Days days."
} elseif ($Days -eq 1) {
& "$PSScriptRoot/give-reply.ps1" "New Year is tomorrow."
}
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"