Skip to content

Commit

Permalink
v1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Jan 30, 2020
1 parent e6c010a commit fac71bb
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 113 deletions.
4 changes: 2 additions & 2 deletions PSCalendar.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
RootModule = 'PSCalendar.psm1'

# Version number of this module.
ModuleVersion = '1.9.0'
ModuleVersion = '1.10.0'

# Supported PSEditions
CompatiblePSEditions = @("Desktop", "Core")
Expand All @@ -22,7 +22,7 @@
CompanyName = 'JDH Information Technology Solutions, Inc.'

# Copyright statement for this module
Copyright = '(c) 2018-19 JDH Information Technology Solutions, Inc. All rights reserved.'
Copyright = '(c) 2018-2020 JDH Information Technology Solutions, Inc. All rights reserved.'

# Description of the functionality provided by this module
Description = 'A PowerShell module to display a calendar in the console.'
Expand Down
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

[![PSGallery Version](https://img.shields.io/powershellgallery/v/PSCalendar.png?style=for-the-badge&logo=powershell&label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/PSCalendar/) [![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/PSCalendar.png?style=for-the-badge&label=Downloads)](https://www.powershellgallery.com/packages/PSCalendar/)

This module contains a few functions for displaying a calendar in the PowerShell console. The primary function is based on code originally published by Lee Holmes at [http://www.leeholmes.com/blog/2008/12/03/showing-calendars-in-your-oof-messages/](http://www.leeholmes.com/blog/2008/12/03/showing-calendars-in-your-oof-messages/)
.
This module contains a few functions for displaying a calendar in the PowerShell console. The primary function is based on code originally published by Lee Holmes at [http://www.leeholmes.com/blog/2008/12/03/showing-calendars-in-your-oof-messages/](http://www.leeholmes.com/blog/2008/12/03/showing-calendars-in-your-oof-messages/).

You can install this module from the PowerShell Gallery.

Expand Down Expand Up @@ -57,10 +56,43 @@ PS C:\> Show-GuiCalendar 12/2018 2/2019 -highlight 12/24/18,12/25/18,12/31/18,1/

The calendar form is transparent. But you should be able to click on it to drag it around your screen. You can also use the + and - keys to increase or decrease the calendar's opacity. Be aware that if you close the PowerShell session that launched the calendar, the calendar too will close.

This function requires the WPF-related assemblies. It should work in Windows PowerShell. For PowerShell Core and later it might or might not work depending on your platform. You will receive a warning if any incompatibility is detected.
This function requires the WPF-related assemblies. It should work in Windows PowerShell and PowerShell 7. You will receive a warning if any incompatibility is detected.

## A Console Calendar Prompt

One way you might want to use this is in your PowerShell console. You can use prompt function like this:

```powershell
Function prompt {
#define a buffercell fill
$fill = [system.management.automation.host.buffercell]::new(" ",$host.ui.RawUI.BackgroundColor,$host.ui.RawUI.BackgroundColor,"complete")
#define a rectangle with an upper left corner at 100,0
$r = [System.Management.Automation.Host.Rectangle]::new(100,0,$host.ui.rawui.windowsize.width,15)
#clear the area for the calendar display
$host.ui.rawui.SetBufferContents($r,$fill)
#show the calendar in the upper right corner of the console
Show-Calendar -Position ([system.management.automation.host.coordinates]::new($host.ui.RawUI.WindowSize.width - 42,0))
"PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
# .Link
# https://go.microsoft.com/fwlink/?LinkID=225750
# .ExternalHelp System.Management.Automation.dll-help.xml
}
```

Assuming the width of your console is at least 120, this code should work. Otherwise, you might need to tweak positioning. This should also work in Windows Terminal. If you add some highlighted dates using `$PSDefaultParameterValues`, then you'll have a calendar right in front of you.

![console calendar](assets/console-calendar.png)

## Potential Issues

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 command you are trying to use with -Verbose and post the results in a new issue.

last updated 2019-11-08 19:17:27Z UTC
last updated 2020-01-30 20:05:00Z UTC
Binary file added assets/console-calendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions calendar-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Function Show-Calendar {
if ($position) {
#save current cursor location
$here = $host.ui.RawUI.CursorPosition
# New-WPFMessageBox $here
[void]$PSBoundParameters.remove("Position")
}

Expand Down Expand Up @@ -317,7 +318,6 @@ Function Show-Calendar {
}
else {
Write-Host "$(($day).PadLeft($l," "))$spacer" -nonewline

}
}

Expand All @@ -334,7 +334,6 @@ Function Show-Calendar {

if ($Position) {
#set cursor position back
$here.y++
$host.ui.RawUI.CursorPosition = $here
}

Expand Down Expand Up @@ -373,7 +372,6 @@ Function Show-GuiCalendar {
[ValidateSet("Segoi UI", "QuickType", "Tahoma", "Lucida Console", "Century Gothic")]
[string]$Font = "Segoi UI",


[Parameter(HelpMessage = "Select a font style for your calendar." )]
[ValidateSet("Normal", "Italic", "Oblique")]
[string]$FontStyle = "Normal",
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log for PSCalendar

## v1.10.0

+ Fixed cursor positioning in `Show-Calendar`
+ Refreshed some of the help examples
+ Updated `README.md`

## v1.9.0

+ Modified manifest to export all public functions and aliases
Expand Down
104 changes: 51 additions & 53 deletions docs/Get-Calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,70 +36,68 @@ This command displays a visual representation of a calendar. It supports multipl
```powershell
PS C:\> Get-Calendar
September 2018
Sun Mon Tue Wed Thu Fri Sat
--- --- --- --- --- --- ---
26 27 28 29 30 31 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 1 2 3 4 5 6
January 2020
Sun Mon Tue Wed Thu Fri Sat
---- ---- ---- ---- ---- ---- ----
29 30 31 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 1
```

Show the current calendar and highlight today. The month name will be centered in your output.

### EXAMPLE 2

```powershell
PS C:\> Get-Calendar -start "3/1/2019" -end "5/1/2019"
March 2019
Sun Mon Tue Wed Thu Fri Sat
--- --- --- --- --- --- ---
24 25 26 27 28 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 1 2 3 4 5 6
April 2019
Sun Mon Tue Wed Thu Fri Sat
--- --- --- --- --- --- ---
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 1 2 3 4
May 2019
Sun Mon Tue Wed Thu Fri Sat
--- --- --- --- --- --- ---
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 1
```
PS C:\> Get-Calendar -start "3/1/2020" -end "5/1/2020"
March 2020
Sun Mon Tue Wed Thu Fri Sat
---- ---- ---- ---- ---- ---- ----
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 1 2 3 4
April 2020
Sun Mon Tue Wed Thu Fri Sat
---- ---- ---- ---- ---- ---- ----
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* 1 2
May 2020
Sun Mon Tue Wed Thu Fri Sat
---- ---- ---- ---- ---- ---- ----
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 1 2 3 4 5 6```
### EXAMPLE 3
```powershell
PS C:\> Get-Calendar -Start 12/1/2018 -end 12/1/2018 -HighlightDate 12/25/2018
December 2018
Sun Mon Tue Wed Thu Fri Sat
--- --- --- --- --- --- ---
25 26 27 28 29 30 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 1 2 3 4 5
PS C:\> Get-Calendar December -HighlightDate 12/4/2020,12/25/2020,12/24/2020,12/31/2020
December 2020
Sun Mon Tue Wed Thu Fri Sat
---- ---- ---- ---- ---- ---- ----
29 30 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* 1 2
```

Display a month and highlight a specific date.
Expand Down
4 changes: 2 additions & 2 deletions docs/Show-Calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ Display a colorized version of the current month. The current day will also be c
### EXAMPLE 2

```powershell
PS C:\> Show-Calendar -Month February -Year 2019 -HighlightDate 2/22/19 -HighlightColor red
PS C:\> Show-Calendar -Month February -Year 2020 -HighlightDate 2/22/20 -HighlightColor red
```

Display February 2019 and highlight the 22nd in red.
Display February 2020 and highlight the 22nd in red.

### Example 3

Expand Down
2 changes: 1 addition & 1 deletion docs/Show-GuiCalendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Display the current month as a graphical calendar.
### Example 2

```powershell
PS C:\> Show-GuiCalendar -start 12/2018 -end 2/2019 -highlight 12/24/18,12/25/18,12/31/18,1/1/19,2/14/19 -font 'Century Gothic' -FontStyle italic
PS C:\> Show-GuiCalendar -start 12/2019 -end 2/2020 -highlight 12/24/19,12/25/19,12/31/19,1/1/20,2/14/20 -font 'Century Gothic' -FontStyle italic
```

Display 3 months with selected dates highlighted and style the calendar to font settings.
Expand Down
Loading

0 comments on commit fac71bb

Please sign in to comment.