Fixes exception on time conversion

This commit is contained in:
Lord Hepipud 2021-06-01 16:20:45 +02:00
parent bb9971c26c
commit 8f16291fb5
3 changed files with 6 additions and 1 deletions

View file

@ -33,6 +33,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#245](https://github.com/Icinga/icinga-powershell-framework/pull/245) Fixes loading of `.pfx` certificates by properly checking the file type * [#245](https://github.com/Icinga/icinga-powershell-framework/pull/245) Fixes loading of `.pfx` certificates by properly checking the file type
* [#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` * [#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`
* [#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 * [#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
* [#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
## 1.4.1 (2021-03-10) ## 1.4.1 (2021-03-10)

View file

@ -16,6 +16,10 @@ function ConvertFrom-TimeSpan()
$Sign = '-'; $Sign = '-';
} }
if ((Test-Numeric $Seconds) -eq $FALSE) {
return $Seconds;
}
$TimeSpan = [TimeSpan]::FromSeconds($Seconds); $TimeSpan = [TimeSpan]::FromSeconds($Seconds);
if ($TimeSpan.TotalDays -ge 1.0) { if ($TimeSpan.TotalDays -ge 1.0) {

View file

@ -71,7 +71,7 @@ function ConvertTo-Seconds()
$result = ($ValueSplitted / [math]::Pow(10, 3)); $result = ($ValueSplitted / [math]::Pow(10, 3));
} else { } else {
if ($UnitPart.Length -gt 1) { if ($UnitPart.Length -gt 1) {
Throw $errorMsg; return $Value;
} }
switch ([int][char]$UnitPart) { switch ([int][char]$UnitPart) {