Skip to content

Commit

Permalink
v2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Nov 1, 2021
1 parent 89812d4 commit 6eb8e02
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion PSCalendar.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
RootModule = 'PSCalendar.psm1'

# Version number of this module.
ModuleVersion = '2.3.0'
ModuleVersion = '2.3.1'

# Supported PSEditions
CompatiblePSEditions = @("Desktop", "Core")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ For example, if you are running under the `en-AU` culture, you would need to use

I have tried to make this module culture-aware. Testing across cultures is not an easy process. If you encounter a problem and are not running PowerShell under the `EN-US` culture, run the calendar command you are trying to use with `-Verbose` and post the results in a new issue. Or if you have both Windows PowerShell and PowerShell 7 installed, try the same command in both versions.

Last Updated 2021-07-30 16:30:17Z
Last Updated2021-11-01 18:36:52Z
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log for PSCalendar

## v2.3.1

+ Fixed alignment problem when first day of a row is highlighted in `Get-NCalendar`. [Issue #25](https://github.com/jdhitsolutions/PSCalendar/issues/25).
+ Updated `Get-Calendar` to fix validation bug when the end date is less than the start date. [Issue #26](https://github.com/jdhitsolutions/PSCalendar/issues/26)

## v2.3.0

+ Added `Get-PNCalendar` and its alias `ncal`. [Issue #16](https://github.com/jdhitsolutions/PSCalendar/issues/16).
Expand Down
33 changes: 19 additions & 14 deletions functions/public.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Function Get-Calendar {
Param(
[Parameter(Position = 1, ParameterSetName = "month")]
[ValidateNotNullorEmpty()]
[ValidateScript( {
[ValidateScript({
$names = _getMonthsByCulture
if ($names -contains $_) {
$True
Expand All @@ -32,15 +32,6 @@ Function Get-Calendar {

[Parameter(Mandatory, HelpMessage = "Enter an ending date for the month like 3/1/2020 that is correct for your culture.", ParameterSetName = "span")]
[ValidateNotNullOrEmpty()]
[ValidateScript( {
if ($_ -ge $Start) {
$True
}
else {
Throw "The end date ($_) must be later than the start date ($start)"
$False
}
})]
[string]$End,

[Parameter(HelpMessage = "Specify a collection of dates to highlight in the calendar display.")]
Expand All @@ -64,6 +55,14 @@ Function Get-Calendar {
}
Process {
Write-Verbose "Using parameter set: $($pscmdlet.ParameterSetName)"

#validate $End Issue #26
if ($PSCmdlet.ParameterSetName -eq 'span') {
if ([datetime]$end -le [datetime]$Start) {
Write-Verbose "Validating End ($end) compared to Start ($Start)"
Throw "[Validation Error] The end date ($end) must be later than the start date ($start)"
}
}
Write-Verbose "Using culture: $($currculture.displayname) [$($currCulture.name)]"
Write-Verbose "Using PSBoundParameters:"
Write-Verbose ($PSBoundParameters | Out-String).trim()
Expand Down Expand Up @@ -624,7 +623,9 @@ Function Get-NCalendar {
$daylist.AddRange($daynames)
}

$daylist | ForEach-Object -Begin { $dayHash = [ordered]@{} } -Process {
$daylist | ForEach-Object -Begin {
$dayHash = [ordered]@{}
} -Process {
$dayHash.Add($_, @())
}

Expand All @@ -634,6 +635,7 @@ 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()
}
else {
$dom = $day.day
Expand All @@ -651,15 +653,18 @@ Function Get-NCalendar {
$str = $_.tostring()
if ($str -match [char]27) {
#add extra padding to account for ANSI escape sequence
$ansipad = 8
Write-Verbose "Adjusting for ANSI sequence"
$ansipad = $str.length - $daylength #8
Write-Verbose "Padding $ansipad"
$str = " $str"
}
else {
$ansipad = 0
}
$str.padleft(2)
$str.padleft(2+$ansipad)
}) -join " ").padleft($maxDayLength + 12 + $ansipad)
}
#Write-verbose "display length = $($out[0].length)"
Write-verbose "display length = $($out[0].length)"
#write-Verbose "head length = $($head.length)"
$pad = (($out[0].length - $head.length) / 2) + $head.length + 1
#Write-Verbose "padding $pad"
Expand Down

0 comments on commit 6eb8e02

Please sign in to comment.