Skip to content

Commit

Permalink
Updated Add-WorkingDays
Browse files Browse the repository at this point in the history
  • Loading branch information
codaamok committed Apr 15, 2022
1 parent 2693c43 commit c6eac10
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 24 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
89 changes: 66 additions & 23 deletions docs/Add-WorkingDays.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -18,75 +18,116 @@ Add-WorkingDays [[-Date] <Object>] [-Days] <Int32> [[-NonWorkingDaysOfWeek] <Str
```

## DESCRIPTION
{{ Fill in the Description }}
Add a number of working days onto a given date.

What constitutes a "working day" in terms of day of the week, or calendar date, is arbitrary and completely customisable.

In other words, the default parameters dictate normal working days, which are Monday through Friday.

You can also specify particular dates, or days of the week, to be regarded as non-working dates via the -NonWorkingDates and -NonWorkingDaysOfWeek parameters.

## EXAMPLES

### Example 1
```powershell
PS C:\> {{ 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
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
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
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/Public/Add-WorkingDays.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function Add-WorkingDays {
[CmdletBinding()]
<#
.SYNOPSIS
Add a number of working days onto a given date.
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit c6eac10

Please sign in to comment.