Sources/Console/Format-Date.ps1

using namespace System.Globalization

<#
.SYNOPSIS
    Formats the specified date.
.INPUTS
    The date to format.
.OUTPUTS
    The formatted date.
#>

function Format-Date {
    [CmdletBinding()]
    [OutputType([int])]
    param (
        # The date to format.
        [Parameter(Mandatory, Position = 1, ValueFromPipeline)]
        [datetime] $Value,

        # Value indicating whether to return the quarter corresponding to the specified date.
        [Parameter(ParameterSetName = "Quarter")]
        [switch] $Quarter,

        # Value indicating whether to return the week number corresponding to the specified date.
        [Parameter(ParameterSetName = "WeekOfYear")]
        [switch] $WeekOfYear
    )

    process {
        if ($Quarter) { return [int] [Math]::Ceiling($Value.Month / 3) }
        if ($WeekOfYear) { return [ISOWeek]::GetWeekOfYear($Value) }
    }
}