PowerShell/Scripts/check-new-year.ps1

28 lines
708 B
PowerShell
Raw Normal View History

<#
.SYNOPSIS
Checks the time until New Year
.DESCRIPTION
2022-01-29 12:47:46 +01:00
This PowerShell script checks the time until New Year and replies by text-to-speech (TTS).
.EXAMPLE
PS> ./check-new-year
.LINK
https://github.com/fleschutz/PowerShell
2022-01-29 12:47:46 +01:00
.NOTES
Author: Markus Fleschutz / License: CC0
#>
try {
$Now = [DateTime]::Now
2021-12-08 12:50:10 +01:00
$NewYear = [Datetime]("12/31/" + $Now.Year)
2021-12-13 10:52:50 +01:00
$Days = ($NewYear $Now).Days + 1
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
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}