Skip to content

Commit 6edd99c

Browse files
authored
Merge pull request #272 from Icinga:fix/exception_on_time_conversion
Fix: Exception on time conversion in case first letter matches time metric
2 parents bb9971c + 8f16291 commit 6edd99c

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
3333
* [#245](https://github.com/Icinga/icinga-powershell-framework/pull/245) Fixes loading of `.pfx` certificates by properly checking the file type
3434
* [#265](https://github.com/Icinga/icinga-powershell-framework/pull/265) Fixes `Test-Numeric` to now accept negative numeric values and als fixes errors, causing `.` to be allowed multiple times. `ConvertFrom-TimeSpan` now properly prints on negative values if the time provided is positive or negative and also prints microseconds as `us` in case the value is loer than `1ms`
3535
* [#269](https://github.com/Icinga/icinga-powershell-framework/pull/269) Fixes unhandled exception on `Set-IcingaCacheData`, as the `-ErrorAction Stop` argument was not set and therefor the function never halted on errors
36+
* [#272](https://github.com/Icinga/icinga-powershell-framework/pull/272) Fixes invalid unit conversion, in case first char of a string is matching time metrics
3637

3738
## 1.4.1 (2021-03-10)
3839

lib/core/tools/ConvertFrom-TimeSpan.psm1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ function ConvertFrom-TimeSpan()
1616
$Sign = '-';
1717
}
1818

19+
if ((Test-Numeric $Seconds) -eq $FALSE) {
20+
return $Seconds;
21+
}
22+
1923
$TimeSpan = [TimeSpan]::FromSeconds($Seconds);
2024

2125
if ($TimeSpan.TotalDays -ge 1.0) {

lib/core/tools/ConvertTo-Seconds.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function ConvertTo-Seconds()
7171
$result = ($ValueSplitted / [math]::Pow(10, 3));
7272
} else {
7373
if ($UnitPart.Length -gt 1) {
74-
Throw $errorMsg;
74+
return $Value;
7575
}
7676

7777
switch ([int][char]$UnitPart) {

0 commit comments

Comments
 (0)