diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 2acbc61..dfb81a5 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -12,6 +12,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic [Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/7?closed=1) * [#78](https://github.com/Icinga/icinga-powershell-framework/issues/78) Fix Icinga Agent package fetching for x86 architecture +* [#79](https://github.com/Icinga/icinga-powershell-framework/issues/79) Fix ConvertTo-Seconds to output valid numeric data with multiple digits ## 1.1.2 (2020-07-01) diff --git a/lib/core/tools/ConvertTo-Seconds.psm1 b/lib/core/tools/ConvertTo-Seconds.psm1 index 6472e51..59bd7aa 100644 --- a/lib/core/tools/ConvertTo-Seconds.psm1 +++ b/lib/core/tools/ConvertTo-Seconds.psm1 @@ -57,13 +57,13 @@ function ConvertTo-Seconds() } [single]$ValueSplitted = $NumberPart; - $result = 0; + $result = 0; if ($Negate) { - $ValueSplitted *= -1; + $ValueSplitted *= -1; } - [string]$errorMsg = ( + [string]$errorMsg = ( [string]::Format('Invalid unit type "{0}" specified for convertion. Allowed units: ms, s, m, h, d, w, M, y', $UnitPart) ); @@ -105,7 +105,13 @@ function ConvertTo-SecondsFromIcingaThresholds() $NewContent += (Get-IcingaThresholdsAsSeconds -Value $entry) } - return [string]::Join(':', $NewContent); + [string]$Value = [string]::Join(':', $NewContent); + + if ($Value.Contains(':') -eq $FALSE) { + return [convert]::ToDouble($Value); + } + + return $Value; } function Get-IcingaThresholdsAsSeconds()