diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b90945e..9f7a98c 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,6 +6,22 @@ { "label": "Build", "type": "process", + "command": "powershell", + "args": ["-noprofile","-command","Invoke-Build","-File","./invoke.build.ps1","-Author","'codaamok'","-ModuleName","'PSBusinessTime'"], + "group": "build", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false + }, + "problemMatcher": [] + }, + { + "label": "Build (pwsh)", + "type": "process", "command": "pwsh", "args": ["-noprofile","-command","Invoke-Build","-File","./invoke.build.ps1","-Author","'codaamok'","-ModuleName","'PSBusinessTime'"], "group": "build", @@ -22,6 +38,25 @@ { "label": "Build (with docs)", "type": "process", + "command": "powershell", + "args": ["-noprofile","-command","Invoke-Build","-File","./invoke.build.ps1","-Author","'codaamok'","-ModuleName","'PSBusinessTime'","-UpdateDocs","$true"], + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false + }, + "problemMatcher": [] + }, + { + "label": "Build (with pwsh & docs)", + "type": "process", "command": "pwsh", "args": ["-noprofile","-command","Invoke-Build","-File","./invoke.build.ps1","-Author","'codaamok'","-ModuleName","'PSBusinessTime'","-UpdateDocs","$true"], "group": { @@ -39,7 +74,7 @@ "problemMatcher": [] }, { - "label": "Tests", + "label": "Tests (with pwsh)", "type": "process", "command": "pwsh", "args": ["-noprofile", "-file", "./tests/invoke.tests.ps1"], @@ -57,5 +92,24 @@ }, "problemMatcher": [] }, + { + "label": "Tests", + "type": "process", + "command": "powershell", + "args": ["-noprofile", "-file", "./tests/invoke.tests.ps1"], + "group": { + "kind": "test", + "isDefault": true + }, + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false + }, + "problemMatcher": [] + }, ] } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 61e4df5..f1c7e8f 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 +- `New-BusinessTimeSpan` threw an exception in some scenarios for Windows PowerShell - see issue #1 ## [0.3.0] - 2022-05-04 ### Changed diff --git a/src/Public/New-BusinessTimeSpan.ps1 b/src/Public/New-BusinessTimeSpan.ps1 index f3e4157..c3a0a64 100644 --- a/src/Public/New-BusinessTimeSpan.ps1 +++ b/src/Public/New-BusinessTimeSpan.ps1 @@ -194,7 +194,7 @@ function New-BusinessTimeSpan { $NumberOfWorkingDays-- } - $InBetweenHours = $NumberOfWorkingDays * $WorkingHours + $InBetweenHours = New-TimeSpan -Seconds ($NumberOfWorkingDays * $WorkingHours.TotalSeconds) $InBetweenHours + $ElapsedTime } } \ No newline at end of file diff --git a/tests/Public/New-BusinessTimeSpan.Tests.ps1 b/tests/Public/New-BusinessTimeSpan.Tests.ps1 index 36bb804..1e3b0f2 100644 --- a/tests/Public/New-BusinessTimeSpan.Tests.ps1 +++ b/tests/Public/New-BusinessTimeSpan.Tests.ps1 @@ -63,7 +63,7 @@ Describe "New-BusinessTimeSpan" { It "should be 143 minutes, across 2 consecutive days, where 1 is a working days" { $StartDate = Get-Date '2022-04-10 13:52:12' $EndDate = Get-Date '2022-04-11 10:23:12' - (New-BusinessTimeSpan -Start $StartDate -End $EndDate).TotalMinutes | Should -Be 143.2 + [decimal](New-BusinessTimeSpan -Start $StartDate -End $EndDate).TotalMinutes | Should -Be 143.2 } It "should be 10 hours, across 1 full day and 1 partial day, where both are working days" {