PSCalendar icon indicating copy to clipboard operation
PSCalendar copied to clipboard

Bug: Empty day trailing day with a different first weekday

Open scriptingstudio opened this issue 3 years ago • 4 comments

If the first weekday is Monday the Sunday of the next month will by empty.

February

image

Yellow square is the day of the next month. Why is it highlighted? It is a different month.

March

image

image

April

image

scriptingstudio avatar Mar 02 '22 11:03 scriptingstudio

I can duplicate this when setting the first day of the week to Monday.

image

This appears to be the case with any month where the first day is Monday.

jdhitsolutions avatar Mar 02 '22 14:03 jdhitsolutions

_getCalendar function: insert the snippet after line 82 and check it out

if ($fd) {
    $day0 += [datetime]$currentDay
}

scriptingstudio avatar Mar 03 '22 09:03 scriptingstudio

Also, small optimization for block of 118-148 lines

$underline = 4 #$abbreviated[0].Length + 1 (3 or 4)
$days = [System.Collections.Generic.List[string]]::new()
$addday = {
    $d = $abbreviated[$args[0]].padleft($underline, " ")
    if ($NoANSI) {
        $days.add($d)
    } else {
        $days.add(("{0}{1}{2}" -f $PScalendarConfiguration.DayofWeek, $d, "$esc[0m"))
    }
}
$n = if ($fd -eq 0) {0} else {1}
for ($n; $n -lt $abbreviated.count; $n++) {. $addday $n}
if ($fd) {. $addday 0}

$underline usage: line 176: $value = $d.tostring().padleft($underline, ' ') line 197: [int]$pad = (10*$underline - $plainhead.Length) / 2 + 1

scriptingstudio avatar Mar 03 '22 09:03 scriptingstudio

Thanks for the suggestions. Fixed the missing day problem. Working on other issues for the next release.

jdhitsolutions avatar Mar 03 '22 14:03 jdhitsolutions

Added in v2.9.0

jdhitsolutions avatar Dec 19 '22 15:12 jdhitsolutions