-
Notifications
You must be signed in to change notification settings - Fork 29
/
Show-Time.ps1
48 lines (41 loc) · 1.68 KB
/
Show-Time.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<#
.SYNOPSIS
Displays a formatted date using powerline font characters.
.LINK
Get-Unicode.ps1
.LINK
Format-Date.ps1
.LINK
Get-Date
.FUNCTIONALITY
Date and time
.EXAMPLE
Show-Time.ps1 Iso8601Z Iso8601WeekDate Iso8601OrdinalDate -Separator ' * '
( 2020-12-08T03:59:39Z * 2020-W50-1 * 2020-342 )
(but using powerline graphics)
#>
#Requires -Version 3
[CmdletBinding()][OutputType([void])] Param(
# The format to serialize the date as.
[Parameter(Position=0,Mandatory=$true,ValueFromRemainingArguments=$true)]
[ValidateSet('FrenchRepublicanDateTime','Iso8601','Iso8601Date','Iso8601OrdinalDate',
'Iso8601Week','Iso8601WeekDate','Iso8601Z','LocalLongDate','LocalLongDateTime','Rfc1123','Rfc1123Gmt')]
[string[]] $Format,
# The date/time value to format.
[Parameter(ValueFromPipeline=$true)][datetime] $Date = (Get-Date),
# The separator to use between formatted dates.
[string] $Separator = " $(Get-Unicode.ps1 0x2022) ",
# The foreground console color to use.
[consolecolor] $ForegroundColor = $host.UI.RawUI.BackgroundColor,
# The background console color to use.
[consolecolor] $BackgroundColor = $host.UI.RawUI.ForegroundColor
)
Process
{
Write-Info.ps1 (Get-Unicode.ps1 0xE0B6) -ForegroundColor $BackgroundColor -NoNewline
Write-Info.ps1 ' ' -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline
Write-Info.ps1 (($Format |ForEach-Object {Format-Date.ps1 $_ -Date $Date}) -join $Separator) `
-ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline
Write-Info.ps1 ' ' -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline
Write-Info.ps1 (Get-Unicode.ps1 0xE0B4) -fore $BackgroundColor
}