mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-16 23:51:18 +02:00
Add check-midnight.ps1, check-noon.ps1, and check-tea-time.ps1
This commit is contained in:
29
Scripts/check-noon.ps1
Normal file
29
Scripts/check-noon.ps1
Normal file
@ -0,0 +1,29 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks the time until Noon
|
||||
.DESCRIPTION
|
||||
This script checks the time until Noon and replies by text-to-speech (TTS).
|
||||
.EXAMPLE
|
||||
PS> ./check-noon
|
||||
.NOTES
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
try {
|
||||
$Now = [DateTime]::Now
|
||||
$Noon = Get-Date -Hour 12 -Minute 0 -Second 0
|
||||
if ($Now -lt $Noon) {
|
||||
$Delta = $Noon - $Now
|
||||
$Reply = "Noon is in $($Delta.Hours) hours, $($Delta.Minutes) minutes."
|
||||
} else {
|
||||
$Delta = $Now - $Noon
|
||||
$Reply = "Noon was $($Delta.Hours) hours, $($Delta.Minutes) minutes ago."
|
||||
}
|
||||
& "$PSScriptRoot/give-reply.ps1" "$Reply"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
}
|
Reference in New Issue
Block a user