Skip to content

Commit

Permalink
v2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Nov 17, 2021
1 parent 5afe270 commit 5659577
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 38 deletions.
6 changes: 3 additions & 3 deletions PSCalendar.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


RootModule = 'PSCalendar.psm1'
ModuleVersion = '2.5.0'
ModuleVersion = '2.6.0'
CompatiblePSEditions = @("Desktop", "Core")
GUID = '222beda0-cdb5-464d-bf49-7ab701da86c9'
Author = 'Jeff Hicks'
Expand All @@ -20,11 +20,11 @@
FormatsToProcess = @('formats\pscalendarconfiguration.format.ps1xml')
FunctionsToExport = if ($PSEdition -eq 'Desktop') {
"Get-Calendar", "Show-Calendar", "Get-NCalendar", "Show-GuiCalendar", "Show-PSCalendarHelp",
"Get-PSCalendarConfiguration", "Set-PSCalendarConfiguration"
"Get-PSCalendarConfiguration", "Set-PSCalendarConfiguration","Get-MonthName"
}
else {
"Get-Calendar", "Show-Calendar", "Get-NCalendar", "Show-PSCalendarHelp",
"Get-PSCalendarConfiguration", "Set-PSCalendarConfiguration"
"Get-PSCalendarConfiguration", "Set-PSCalendarConfiguration","Get-MonthName"
}
VariablesToExport = @()
AliasesToExport = @('ncal', 'cal', 'gcal', 'scal')
Expand Down
Binary file modified PSCalendarManual.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log for PSCalendar

## v2.6.0

+ Updates to `Get-NCalendar` [Issue #25](https://github.com/jdhitsolutions/PSCalendar/issues/25).
+ Exported `Get-MonthName` in the module manifest.
+ Added missing online help links.
+ Help updates.

## v2.5.0

+ Updated commands to work in PowerShell 7.2. [Issue #28](https://github.com/jdhitsolutions/PSCalendar/issues/28).
Expand Down
2 changes: 1 addition & 1 deletion docs/Get-MonthName.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
external help file: PSCalendar-help.xml
Module Name: PSCalendar
online version:
online version: https://bit.ly/3qPYLaH
schema: 2.0.0
---

Expand Down
4 changes: 2 additions & 2 deletions docs/Get-NCalendar.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
external help file: PSCalendar-help.xml
Module Name: PSCalendar
online version:
online version: https://bit.ly/2YWjIFn
schema: 2.0.0
---

# Get-NCalendar

## SYNOPSIS

Display a Linux-style ncal calendar
Display a Linux-style ncal calendar.

## SYNTAX

Expand Down
2 changes: 1 addition & 1 deletion docs/Show-GuiCalendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ schema: 2.0.0

## SYNOPSIS

Display a WPF-based calendar
Display a WPF-based calendar.

## SYNTAX

Expand Down
12 changes: 10 additions & 2 deletions en-us/PSCalendar-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ Dec</dev:code>
</command:example>
</command:examples>
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online Version:</maml:linkText>
<maml:uri>https://bit.ly/3qPYLaH</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Culture</maml:linkText>
<maml:uri></maml:uri>
Expand All @@ -463,7 +467,7 @@ Dec</dev:code>
<command:verb>Get</command:verb>
<command:noun>NCalendar</command:noun>
<maml:description>
<maml:para>Display a Linux-style ncal calendar</maml:para>
<maml:para>Display a Linux-style ncal calendar.</maml:para>
</maml:description>
</command:details>
<maml:description>
Expand Down Expand Up @@ -655,6 +659,10 @@ Sat 6 13 20 27
</command:example>
</command:examples>
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online Version:</maml:linkText>
<maml:uri>https://bit.ly/2YWjIFn</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Calendar</maml:linkText>
<maml:uri></maml:uri>
Expand Down Expand Up @@ -1156,7 +1164,7 @@ Highlight : `e[92m</dev:code>
<command:verb>Show</command:verb>
<command:noun>GuiCalendar</command:noun>
<maml:description>
<maml:para>Display a WPF-based calendar</maml:para>
<maml:para>Display a WPF-based calendar.</maml:para>
</maml:description>
</command:details>
<maml:description>
Expand Down
90 changes: 61 additions & 29 deletions functions/public.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -574,23 +574,30 @@ Function Get-NCalendar {
[Outputtype("String")]

Param(
[Parameter(Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName,
HelpMessage = "Enter the full month name. The default is the current month.")]
[Parameter(
Position = 0,
ValueFromPipeline,
ValueFromPipelineByPropertyName,
HelpMessage = "Enter the full month name. The default is the current month."
)]
[ValidateNotNullOrEmpty()]
[ValidateScript( {
#sometimes this returns an extra and blank entry
$m = [system.globalization.cultureinfo]::CurrentCulture.DateTimeFormat.MonthNames | Where-Object { $_ }
if ( $m -contains $_) {
$True
}
Else {
Throw "You must enter one of these values: $($m -join ',')"
$False
}
})]
#sometimes this returns an extra and blank entry
$m = [system.globalization.cultureinfo]::CurrentCulture.DateTimeFormat.MonthNames | Where-Object { $_ }
if ( $m -contains $_) {
$True
}
Else {
Throw "You must enter one of these values: $($m -join ',')"
$False
}
})]
[string]$Month = (Get-Date -Format MMMM),
[Parameter(Position = 1, ValueFromPipelineByPropertyName,
HelpMessage = "Enter the 4 digit year. The default is the current year.")]
[Parameter(
Position = 1,
ValueFromPipelineByPropertyName,
HelpMessage = "Enter the 4 digit year. The default is the current year."
)]
[ValidatePattern("\d{4}")]
[ValidateRange(1000, 9999)]
[int]$Year = (Get-Date).Year,
Expand Down Expand Up @@ -644,34 +651,58 @@ Function Get-NCalendar {
$dayname = "{0:ddd}" -f $day
if ((-NOT $HideHighlight) -AND ($day -eq $today)) {
$dom = "$([char]27)[7m$($day.day)$([char]27)[0m"
$dayLength = $day.day.ToString()
$dayLength = $day.day.ToString().length
}
else {
$dom = $day.day
}
$dayhash[$dayname] += $dom
}

$dayhash | Out-String | Write-Verbose
#make sure month is in title case
$head = "$($currculture.TextInfo.toTitleCase($Month)) $Year"
$maxDayLength = $dayhash.keys.length | Sort-Object | Select-Object -Last 1
Write-Verbose "Building day hashtable"
$out = $dayhash.GetEnumerator() |
ForEach-Object {
"{0}{1}" -f $_.name.Padright(4), ($_.value.foreach( {
$str = $_.tostring()
if ($str -match [char]27) {
#add extra padding to account for ANSI escape sequence
Write-Verbose "Adjusting for ANSI sequence"
$ansipad = $str.length - $daylength #8
Write-Verbose "Padding $ansipad"
$str = " $str"
}
else {
$ansipad = 0
}
$str.padleft(2 + $ansipad)
}) -join " ").padleft($maxDayLength + 12 + $ansipad)
Write-Verbose $_.name
#build a value string
$vstring = $_.value.foreach( {
$str = $_.tostring()
Write-Verbose "Day: $str"
if ($str -match [char]27) {
#add extra padding to account for ANSI escape sequence
Write-Verbose "Adjusting for ANSI sequence"
Write-Verbose "String length = $($str.length)"
Write-Verbose "Saved length $ANSILength"
Write-Verbose "Day length = $daylength"
if ($daylength -le $str.length) {
$ansipad = $str.length - $daylength #8
#save ANSI length
$ANSILength = $str.length - $daylength
}
else {
$ansipad = 0
}
Write-Verbose "Padding $ansipad"
}
else {
$ansipad = 0

}
$str.padleft(1 + $ansipad)
})
Write-Verbose "Does day string contain ANSI?"
Write-Verbose (($vstring -join ' ') -match [char]27)
if ((($vstring -join ' ') -match [char]27)) {
Write-Verbose "Adding $ANSILength to AnsiPad value"
$ansipad+= $ANSILength
}
Write-Verbose "Using days $($vstring -join ' ')"
# Write-Verbose "Padding left $MaxDayLength + 12 + $ANSIPad"
"{0}{1}" -f $_.name.Padright(4), $($vstring -join " ").padleft($maxDayLength + 12 + $ansipad)
$ANSILength=0
}
Write-Verbose "display length = $($out[0].length)"
#write-Verbose "head length = $($head.length)"
Expand All @@ -689,6 +720,7 @@ Function Get-NCalendar {

Function Get-MonthName {
[cmdletbinding()]
[outputtype("string")]
Param(
[Parameter(HelpMessage = "Get short month names")]
[switch]$Short
Expand Down

0 comments on commit 5659577

Please sign in to comment.