<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://kono.phpage.fr/index.php?action=history&amp;feed=atom&amp;title=PowerShell%2FFonction%2FShow-Calendar</id>
	<title>PowerShell/Fonction/Show-Calendar - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://kono.phpage.fr/index.php?action=history&amp;feed=atom&amp;title=PowerShell%2FFonction%2FShow-Calendar"/>
	<link rel="alternate" type="text/html" href="https://kono.phpage.fr/index.php?title=PowerShell/Fonction/Show-Calendar&amp;action=history"/>
	<updated>2026-11-07T18:59:46Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://kono.phpage.fr/index.php?title=PowerShell/Fonction/Show-Calendar&amp;diff=4296&amp;oldid=prev</id>
		<title>Fylip22 : Page créée avec « {{Sommaire}}  &lt;source&gt; &lt;#  .Synopsis   Displays a visual representation of a calendar.   .Description   Displays a visual representation of a calendar. This function supports multiple months   and lets you highlight specific date ranges or days.   .Parameter Start   The first month to display.   .Parameter End   The last month to display.   .Parameter FirstDayOfWeek   The day of the month on which the week begins.   .Parameter HighlightDay   Specific days (number... »</title>
		<link rel="alternate" type="text/html" href="https://kono.phpage.fr/index.php?title=PowerShell/Fonction/Show-Calendar&amp;diff=4296&amp;oldid=prev"/>
		<updated>2023-11-15T22:37:32Z</updated>

		<summary type="html">&lt;p&gt;Page créée avec « {{Sommaire}}  &amp;lt;source&amp;gt; &amp;lt;#  .Synopsis   Displays a visual representation of a calendar.   .Description   Displays a visual representation of a calendar. This function supports multiple months   and lets you highlight specific date ranges or days.   .Parameter Start   The first month to display.   .Parameter End   The last month to display.   .Parameter FirstDayOfWeek   The day of the month on which the week begins.   .Parameter HighlightDay   Specific days (number... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Sommaire}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&amp;lt;#&lt;br /&gt;
 .Synopsis&lt;br /&gt;
  Displays a visual representation of a calendar.&lt;br /&gt;
&lt;br /&gt;
 .Description&lt;br /&gt;
  Displays a visual representation of a calendar. This function supports multiple months&lt;br /&gt;
  and lets you highlight specific date ranges or days.&lt;br /&gt;
&lt;br /&gt;
 .Parameter Start&lt;br /&gt;
  The first month to display.&lt;br /&gt;
&lt;br /&gt;
 .Parameter End&lt;br /&gt;
  The last month to display.&lt;br /&gt;
&lt;br /&gt;
 .Parameter FirstDayOfWeek&lt;br /&gt;
  The day of the month on which the week begins.&lt;br /&gt;
&lt;br /&gt;
 .Parameter HighlightDay&lt;br /&gt;
  Specific days (numbered) to highlight. Used for date ranges like (25..31).&lt;br /&gt;
  Date ranges are specified by the Windows PowerShell range syntax. These dates are&lt;br /&gt;
  enclosed in square brackets.&lt;br /&gt;
&lt;br /&gt;
 .Parameter HighlightDate&lt;br /&gt;
  Specific days (named) to highlight. These dates are surrounded by asterisks.&lt;br /&gt;
&lt;br /&gt;
 .Example&lt;br /&gt;
   # Show a default display of this month.&lt;br /&gt;
   Show-Calendar&lt;br /&gt;
&lt;br /&gt;
 .Example&lt;br /&gt;
   # Display a date range.&lt;br /&gt;
   Show-Calendar -Start &amp;quot;March, 2010&amp;quot; -End &amp;quot;May, 2010&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 .Example&lt;br /&gt;
   # Highlight a range of days.&lt;br /&gt;
   Show-Calendar -HighlightDay (1..10 + 22) -HighlightDate &amp;quot;2008-12-25&amp;quot;&lt;br /&gt;
#&amp;gt;&lt;br /&gt;
function Show-Calendar {&lt;br /&gt;
param(&lt;br /&gt;
    [DateTime] $start = [DateTime]::Today,&lt;br /&gt;
    [DateTime] $end = $start,&lt;br /&gt;
    $firstDayOfWeek,&lt;br /&gt;
    [int[]] $highlightDay,&lt;br /&gt;
    [string[]] $highlightDate = [DateTime]::Today.ToString(&amp;#039;yyyy-MM-dd&amp;#039;)&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
## Determine the first day of the start and end months.&lt;br /&gt;
$start = New-Object DateTime $start.Year,$start.Month,1&lt;br /&gt;
$end = New-Object DateTime $end.Year,$end.Month,1&lt;br /&gt;
&lt;br /&gt;
## Convert the highlighted dates into real dates.&lt;br /&gt;
[DateTime[]] $highlightDate = [DateTime[]] $highlightDate&lt;br /&gt;
&lt;br /&gt;
## Retrieve the DateTimeFormat information so that the&lt;br /&gt;
## calendar can be manipulated.&lt;br /&gt;
$dateTimeFormat  = (Get-Culture).DateTimeFormat&lt;br /&gt;
if($firstDayOfWeek)&lt;br /&gt;
{&lt;br /&gt;
    $dateTimeFormat.FirstDayOfWeek = $firstDayOfWeek&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$currentDay = $start&lt;br /&gt;
&lt;br /&gt;
## Process the requested months.&lt;br /&gt;
while($start -le $end)&lt;br /&gt;
{&lt;br /&gt;
    ## Return to an earlier point in the function if the first day of the month&lt;br /&gt;
    ## is in the middle of the week.&lt;br /&gt;
    while($currentDay.DayOfWeek -ne $dateTimeFormat.FirstDayOfWeek)&lt;br /&gt;
    {&lt;br /&gt;
        $currentDay = $currentDay.AddDays(-1)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ## Prepare to store information about this date range.&lt;br /&gt;
    $currentWeek = New-Object PsObject&lt;br /&gt;
    $dayNames = @()&lt;br /&gt;
    $weeks = @()&lt;br /&gt;
&lt;br /&gt;
    ## Continue processing dates until the function reaches the end of the month.&lt;br /&gt;
    ## The function continues until the week is completed with&lt;br /&gt;
    ## days from the next month.&lt;br /&gt;
    while(($currentDay -lt $start.AddMonths(1)) -or&lt;br /&gt;
        ($currentDay.DayOfWeek -ne $dateTimeFormat.FirstDayOfWeek))&lt;br /&gt;
    {&lt;br /&gt;
        ## Determine the day names to use to label the columns.&lt;br /&gt;
        $dayName = &amp;quot;{0:ddd}&amp;quot; -f $currentDay&lt;br /&gt;
        if($dayNames -notcontains $dayName)&lt;br /&gt;
        {&lt;br /&gt;
            $dayNames += $dayName&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        ## Pad the day number for display, highlighting if necessary.&lt;br /&gt;
        $displayDay = &amp;quot; {0,2} &amp;quot; -f $currentDay.Day&lt;br /&gt;
&lt;br /&gt;
        ## Determine whether to highlight a specific date.&lt;br /&gt;
        if($highlightDate)&lt;br /&gt;
        {&lt;br /&gt;
            $compareDate = New-Object DateTime $currentDay.Year,&lt;br /&gt;
                $currentDay.Month,$currentDay.Day&lt;br /&gt;
            if($highlightDate -contains $compareDate)&lt;br /&gt;
            {&lt;br /&gt;
                $displayDay = &amp;quot;*&amp;quot; + (&amp;quot;{0,2}&amp;quot; -f $currentDay.Day) + &amp;quot;*&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        ## Otherwise, highlight as part of a date range.&lt;br /&gt;
        if($highlightDay -and ($highlightDay[0] -eq $currentDay.Day))&lt;br /&gt;
        {&lt;br /&gt;
            $displayDay = &amp;quot;[&amp;quot; + (&amp;quot;{0,2}&amp;quot; -f $currentDay.Day) + &amp;quot;]&amp;quot;&lt;br /&gt;
            $null,$highlightDay = $highlightDay&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        ## Add the day of the week and the day of the month as note properties.&lt;br /&gt;
        $currentWeek | Add-Member NoteProperty $dayName $displayDay&lt;br /&gt;
&lt;br /&gt;
        ## Move to the next day of the month.&lt;br /&gt;
        $currentDay = $currentDay.AddDays(1)&lt;br /&gt;
&lt;br /&gt;
        ## If the function reaches the next week, store the current week&lt;br /&gt;
        ## in the week list and continue.&lt;br /&gt;
        if($currentDay.DayOfWeek -eq $dateTimeFormat.FirstDayOfWeek)&lt;br /&gt;
        {&lt;br /&gt;
            $weeks += $currentWeek&lt;br /&gt;
            $currentWeek = New-Object PsObject&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ## Format the weeks as a table.&lt;br /&gt;
    $calendar = $weeks | Format-Table $dayNames -AutoSize | Out-String&lt;br /&gt;
&lt;br /&gt;
    ## Add a centered header.&lt;br /&gt;
    $width = ($calendar.Split(&amp;quot;`n&amp;quot;) | Measure-Object -Maximum Length).Maximum&lt;br /&gt;
    $header = &amp;quot;{0:MMMM yyyy}&amp;quot; -f $start&lt;br /&gt;
    $padding = &amp;quot; &amp;quot; * (($width - $header.Length) / 2)&lt;br /&gt;
    $displayCalendar = &amp;quot; `n&amp;quot; + $padding + $header + &amp;quot;`n &amp;quot; + $calendar&lt;br /&gt;
    $displayCalendar.TrimEnd()&lt;br /&gt;
&lt;br /&gt;
    ## Move to the next month.&lt;br /&gt;
    $start = $start.AddMonths(1)&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
Export-ModuleMember -Function Show-Calendar&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Catégorie:PowerShell]]&lt;/div&gt;</summary>
		<author><name>Fylip22</name></author>
	</entry>
</feed>