This is a PowerShell implementation of the cal command found in Unix/Linux. Its task is quite simply to output a calendar view of the choosen month(s).
I have made an update to the function. It now supports right-aligning the days in the output. In fact, Right alignment are now the default value. (Thanks Kirk!). I have also added support for using abbreviated names for days.
The biggest change however are the fact that the function is now culture-aware, and the default culture is the current culture. It supports specifying a specific culture, or you can use the Invariant Culture.
I have also decided to do something I thought I’d never do, I have used Format-Table for the output. This makes using Kirks FormatPx module even more desirable, as this is now the only way to get a proper PowerShell object out of this function.
The reason I made this change was that without FormatPx, the default output (list view) was not well suited for a calendar, and having to use Format-Table after the command each time, made it cumbersome to use.
A small note regarding the culture awareness: Since the days and the months are read from a CultureInfo object, they will display in the language of that culture. Since I use Week, Month and Year also as property names, and since these will still be visible in English, I have added a translation hash table to the script. I have added translations for a handful of different languages already, but if yours is missing, and you would like it added, please let me know, and I’ll add it to the code!
Original post text
You can choose the starting month and year, and how many months to show, as well as parameters to mark day(s) as well as a specific date. The current date will also be marked in the calendar.
Since this is PowerShell the days are of course datetime objects and not just text, but because of this the default output formatting is not ideal for a calendar view. I have built-in support for the excellent FormatPx module by Kirk Munro, so if you are using this module the output will look like this:
If you don’t have FormatPx and don’t want to use it, I suggest using Format-Table to get the calendar view somewhat readable on the screen. The following image shows how that will look:
But seriously, if you haven’t checked out FormatPx yet, head on over to Kirks github project and give it a try!
And now for some code: