mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Merge pull request #272 from Icinga:fix/exception_on_time_conversion
Fix: Exception on time conversion in case first letter matches time metric
This commit is contained in:
commit
6edd99c432
3 changed files with 6 additions and 1 deletions
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue