From c6eac1080baed2249124f12e5623092fc724baa6 Mon Sep 17 00:00:00 2001 From: codaamok Date: Fri, 15 Apr 2022 21:52:58 +0100 Subject: [PATCH] Updated Add-WorkingDays --- CHANGELOG.md | 2 + docs/Add-WorkingDays.md | 89 +++++++++++++++++++++++++--------- src/Public/Add-WorkingDays.ps1 | 2 +- 3 files changed, 69 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e8c69..ee61dec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- CmdletBinding attribute was in incorrect position for `Add-WorkingDays`. This caused PlatyPS to not generate docs properly. This fix does not provide any functional improvement to `Add-WorkingDays`. At this time, it is just necessary to push to source control which invokes the release pipeline. ## [0.2.1] - 2022-04-15 ### Fixed diff --git a/docs/Add-WorkingDays.md b/docs/Add-WorkingDays.md index 5f77d70..274cf5a 100644 --- a/docs/Add-WorkingDays.md +++ b/docs/Add-WorkingDays.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Add-WorkingDays ## SYNOPSIS -{{ Fill in the Synopsis }} +Add a number of working days onto a given date. ## SYNTAX @@ -18,21 +18,54 @@ Add-WorkingDays [[-Date] ] [-Days] [[-NonWorkingDaysOfWeek] {{ Add example code here }} +### EXAMPLE 1 +``` +Add-WorkingDays -Days 3 +``` + +Adds 3 working days onto the current date. +For example, if today's date is 2022-04-07, then the returned datetime object will be 2022-04-12. + +### EXAMPLE 2 +``` +Add-WorkingDays -Days -3 +``` + +Minuses 3 working days from the current date. +For example, if today's date is 2022-04-07, then the returned datetime object will be 2022-04-04. + +### EXAMPLE 3 +``` +Add-WorkingDays -Date (Get-Date '2022-04-14') -Days 5 -NonWorkingDates (Get-Date '2022-04-15'),(Get-Date '2022-04-18') ``` -{{ Add example description here }} +Add 5 working days from 2022-04-14, discounting 2022-04-15 (Good Friday) and 2022-04-18 (Easter Monday) as working days. +The returned datetime object will be 2022-04-25. + +### EXAMPLE 4 +``` +Add-WorkingDays -Days 1 -NonWorkingDaysOfWeek 'Friday','Saturday','Sunday' +``` + +Add 1 working day onto the current date. +For example, if today's date is 2022-04-07, then the returned datetime object will be 2022-04-11. ## PARAMETERS ### -Date -{{ Fill Date Description }} +The starting date used for calculation. + +The default value is the current datetime. ```yaml Type: Object @@ -40,14 +73,16 @@ Parameter Sets: (All) Aliases: Required: False -Position: 0 -Default value: None +Position: 1 +Default value: (Get-Date) Accept pipeline input: False Accept wildcard characters: False ``` ### -Days -{{ Fill Days Description }} +The number of working days to add onto from the given date. + +Number can be negative in order to substract from the given date, too. ```yaml Type: Int32 @@ -55,38 +90,44 @@ Parameter Sets: (All) Aliases: Required: True -Position: 1 -Default value: None +Position: 2 +Default value: 0 Accept pipeline input: False Accept wildcard characters: False ``` -### -NonWorkingDates -{{ Fill NonWorkingDates Description }} +### -NonWorkingDaysOfWeek +The days of the week, representated as strings e.g. +'Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday', which denotes non-working days of the week. + +Days specified in this parameter will not be considered as working days. + +Default values are Saturday and Sunday. ```yaml -Type: DateTime[] +Type: String[] Parameter Sets: (All) Aliases: Required: False Position: 3 -Default value: None +Default value: @('Saturday','Sunday') Accept pipeline input: False Accept wildcard characters: False ``` -### -NonWorkingDaysOfWeek -{{ Fill NonWorkingDaysOfWeek Description }} +### -NonWorkingDates +An array of datetime objects which denote specific non-working dates. + +Dates specified in this parameter will not be considered as working days. ```yaml -Type: String[] +Type: DateTime[] Parameter Sets: (All) Aliases: -Accepted values: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday Required: False -Position: 2 +Position: 4 Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -97,10 +138,12 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## INPUTS -### None +### This function does not accept pipeline input. ## OUTPUTS -### System.Object +### System.DateTime ## NOTES +Chris Dent (@indented-automation) wrote this in the WinAdmins Discord +https://discord.com/channels/618712310185197588/618857671608500234/913855890384371712 ## RELATED LINKS diff --git a/src/Public/Add-WorkingDays.ps1 b/src/Public/Add-WorkingDays.ps1 index 5abc798..09c29f2 100644 --- a/src/Public/Add-WorkingDays.ps1 +++ b/src/Public/Add-WorkingDays.ps1 @@ -1,5 +1,4 @@ function Add-WorkingDays { - [CmdletBinding()] <# .SYNOPSIS Add a number of working days onto a given date. @@ -53,6 +52,7 @@ function Add-WorkingDays { Chris Dent (@indented-automation) wrote this in the WinAdmins Discord https://discord.com/channels/618712310185197588/618857671608500234/913855890384371712 #> + [CmdletBinding()] param ( [Parameter()] [object]$Date = (Get-Date),