Skip to content

Commit

Permalink
Renamed Get-ElapsedBusinessTime +semver:minor
Browse files Browse the repository at this point in the history
  • Loading branch information
codaamok committed Apr 22, 2022
1 parent b0886f9 commit b93f538
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ jobs:
- name: Custom post-release tasks
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
run: Invoke-Build -File "custom.build.ps1" -ModuleName $env:GH_PROJECTNAME -Author $env:GH_USERNAME -Version $env:GitVersion_SemVer -NewRelease $true -Task PostRelease
shell: pwsh
shell: pwsh
16 changes: 9 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ 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]
### Changed
- Renamed `Get-ElapsedBusinessTime` to `New-BusinessTimeSpan`, and changed parameters `-StartDate` and `-EndDate` to `-Start` and `-End`, similar to `New-TimeSpan` and its datetime parameters.

## [0.2.2] - 2022-04-15
### 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
- `Get-ElapsedBusinessTime` did not return correct result if `-StartDate` and `-EndDate` were on the same day, but it was a working day, and its time for both dates were outside of working hours
- `New-BusinessTimeSpan` did not return correct result if `-StartDate` and `-EndDate` were on the same day, but it was a working day, and its time for both dates were outside of working hours

## [0.2.0] - 2022-04-14
### Added
Expand All @@ -21,29 +23,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.1.7] - 2022-04-14
### Changed
- `Test-WorkingDay` now has parameter validation to ensure `-StartHour` is less then `-FinishHour`
- `Get-ElapsedBusinessTime` now has parameter validation to ensure `-StartHour` is less then `-FinishHour`
- `New-BusinessTimeSpan` now has parameter validation to ensure `-StartHour` is less then `-FinishHour`

## [0.1.6] - 2022-04-14
### Fixed
- `Get-ElapsedBusinessTime` did not return correct result if `-StartDate` and `-EndDate` were on the same day, but it was a working day, and its time for both dates were outside of working hours
- `New-BusinessTimeSpan` did not return correct result if `-StartDate` and `-EndDate` were on the same day, but it was a working day, and its time for both dates were outside of working hours

## [0.1.5] - 2022-04-14
### Fixed
- `Get-ElapsedBusinessTime` did not return correct result if range between `-StartHour` and `-FinishHour` was not whole, ie was a span of time where minutes and seconds also needed consideration
- `New-BusinessTimeSpan` did not return correct result if range between `-StartHour` and `-FinishHour` was not whole, ie was a span of time where minutes and seconds also needed consideration

## [0.1.4] - 2022-04-14
### Fixed
- `Get-ElapsedBusinessTime` did not return correct result when either the start date or end date were outside of business hours
- `New-BusinessTimeSpan` did not return correct result when either the start date or end date were outside of business hours
- Added line breaks in between each line for all comment based help

## [0.1.2] - 2022-04-13
### Fixed
- `Get-ElapsedBusinessTime` did not return correct result where the number of working days between `-StartDate` and `-EndDate` was 1 but the date range spanned more than 1 calendar day, e.g. Sunday through to Monday.
- `New-BusinessTimeSpan` did not return correct result where the number of working days between `-StartDate` and `-EndDate` was 1 but the date range spanned more than 1 calendar day, e.g. Sunday through to Monday.

## [0.1.1] - 2022-04-12
### Fixed
- Some typo and grammar issues in comment based help
- `Get-WorkingDates` would not return the correct number of working dates, which also impacted `Get-ElapsedBusinessTime`
- `Get-WorkingDates` would not return the correct number of working dates, which also impacted `New-BusinessTimeSpan`

## [0.1.0] - 2022-04-11
### Added
Expand Down
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ branches:
regex: ^(hot)?fix(es)?[/-]
ignore:
sha: []
merge-message-formats: {}
merge-message-formats: {}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Inspired by https://pleasework.robbievance.net/howto-calculate-elapsed-business-
## Functions

- [Add-WorkingDays](docs/Add-WorkingDays.md)
- [Get-ElapsedBusinessTime](docs/Get-ElapsedBusinessTime.md)
- [New-BusinessTimeSpan](docs/New-BusinessTimeSpan.md)
- [Get-WorkingDates](docs/Get-WorkingDates.md)
- [Test-WorkingDay](docs/Test-WorkingDay.md)

Expand All @@ -37,7 +37,7 @@ Get-Command -Module PSBusinessTime
## Examples

```powershell
Get-ElapsedBusinessTime -StartDate (Get-Date '2022-04-01 00:00:00') -EndDate (Get-Date '2022-04-30 23:59:59') -NonWorkingDates (Get-Date '2022-04-15'), (Get-Date '2022-04-18')
New-BusinessTimeSpan -StartDate (Get-Date '2022-04-01 00:00:00') -EndDate (Get-Date '2022-04-30 23:59:59') -NonWorkingDates (Get-Date '2022-04-15'), (Get-Date '2022-04-18')
```

The function will return a timespan object of 171 hours:
Expand Down
27 changes: 13 additions & 14 deletions docs/Get-ElapsedBusinessTime.md → docs/New-BusinessTimeSpan.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ online version:
schema: 2.0.0
---

# Get-ElapsedBusinessTime
# New-BusinessTimeSpan

## SYNOPSIS
Get the elapsed time between two dates, where the time measured is only inbetween "business hours".

## SYNTAX

```
Get-ElapsedBusinessTime [-StartDate] <DateTime> [-EndDate] <DateTime> [[-StartHour] <DateTime>]
[[-FinishHour] <DateTime>] [[-NonWorkingDaysOfWeek] <String[]>] [[-NonWorkingDates] <DateTime[]>]
[<CommonParameters>]
New-BusinessTimeSpan [-Start] <DateTime> [-End] <DateTime> [[-StartHour] <DateTime>] [[-FinishHour] <DateTime>]
[[-NonWorkingDaysOfWeek] <String[]>] [[-NonWorkingDates] <DateTime[]>] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -35,31 +34,31 @@ This function does consider both date and time while calculating the elapsed tim

### EXAMPLE 1
```
Get-ElapsedBusinessTime -StartDate (Get-Date '2022-04-11 10:00:00') -EndDate (Get-Date '2022-04-11 10:37:00')
New-BusinessTimeSpan -Start (Get-Date '2022-04-11 10:00:00') -End (Get-Date '2022-04-11 10:37:00')
```

The function will return a timespan object of 37 minutes.
2022-04-11 is a Monday and the whole time inbetween the date range given is within the default parameters.

### EXAMPLE 2
```
Get-ElapsedBusinessTime -StartDate (Get-Date '2022-04-11 08:00:00') -EndDate (Get-Date '2022-04-12 08:00:00')
New-BusinessTimeSpan -Start (Get-Date '2022-04-11 08:00:00') -End (Get-Date '2022-04-12 08:00:00')
```

The function will return a timespan object of 9 hours.
2022-04-11 is a Monday and 2022-04-12 is a Tuesday, and only 9 hours is considered "working hours" within the default parameters.

### EXAMPLE 3
```
Get-ElapsedBusinessTime -StartDate (Get-Date '2022-04-11 13:00:00') -EndDate (Get-Date '2022-04-13 13:00:00')
New-BusinessTimeSpan -Start (Get-Date '2022-04-11 13:00:00') -End (Get-Date '2022-04-13 13:00:00')
```

The function will return a timespan object of 18 hours.
2022-04-11 through 2022-04-13 is Monday through Wednesday, and only 18 hours is considered "working hours" within the default parameters.

### EXAMPLE 4
```
Get-ElapsedBusinessTime -StartDate (Get-Date '2022-04-01 00:00:00') -EndDate (Get-Date '2022-04-30 23:59:59') -NonWorkingDates (Get-Date '2022-04-15'), (Get-Date '2022-04-18')
New-BusinessTimeSpan -Start (Get-Date '2022-04-01 00:00:00') -End (Get-Date '2022-04-30 23:59:59') -NonWorkingDates (Get-Date '2022-04-15'), (Get-Date '2022-04-18')
```

The function will return a timespan object of 162 hours.
Expand All @@ -68,7 +67,7 @@ The function will return a timespan object of 162 hours.

### EXAMPLE 5
```
Get-ElapsedBusinessTime -StartDate (Get-Date '2022-01-01 00:00:00') -EndDate (Get-Date '2022-12-31 23:59:59') -NonWorkingDates (Get-Date '2022-01-03'), (Get-Date '2022-04-15'), (Get-Date '2022-04-18'), (Get-Date '2022-05-02'), (Get-Date '2022-06-02'), (Get-Date '2022-06-03'), (Get-Date '2022-08-29'), (Get-Date '2022-12-26'), (Get-Date '2022-12-27')
New-BusinessTimeSpan -Start (Get-Date '2022-01-01 00:00:00') -End (Get-Date '2022-12-31 23:59:59') -NonWorkingDates (Get-Date '2022-01-03'), (Get-Date '2022-04-15'), (Get-Date '2022-04-18'), (Get-Date '2022-05-02'), (Get-Date '2022-06-02'), (Get-Date '2022-06-03'), (Get-Date '2022-08-29'), (Get-Date '2022-12-26'), (Get-Date '2022-12-27')
```

The function will return a timespan object of 2259 hours.
Expand All @@ -77,7 +76,7 @@ All dates passed to -NonWorkingDates are considered non-working dates (public ho

### EXAMPLE 6
```
Get-ElapsedBusinessTime -StartDate (Get-Date '2022-01-01 00:00:00') -EndDate (Get-Date '2022-12-31 23:59:59') -NonWorkingDaysOfWeek 'Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'
New-BusinessTimeSpan -Start (Get-Date '2022-01-01 00:00:00') -End (Get-Date '2022-12-31 23:59:59') -NonWorkingDaysOfWeek 'Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'
```

The function will return a timespan object of 0 hours.
Expand All @@ -86,9 +85,9 @@ All days passed to -NonWorkingDaysOfWeek are considered non-working days, hence

## PARAMETERS

### -StartDate
### -Start
The datetime object to start calculating the elapsed time from.
It must be an older datetime than -EndDate.
It must be an older datetime than -End.

```yaml
Type: DateTime
Expand All @@ -102,9 +101,9 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -EndDate
### -End
The datetime object to end calculating the elapsed time to.
It must be a newer datetime than -StartDate.
It must be a newer datetime than -Start.
```yaml
Type: DateTime
Expand Down
Loading

0 comments on commit b93f538

Please sign in to comment.