mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
24 lines
704 B
PowerShell
24 lines
704 B
PowerShell
function ConvertTo-IcingaNumericTimeIndex()
|
|
{
|
|
param (
|
|
[int]$TimeValue = 0
|
|
);
|
|
|
|
if ($TimeValue -lt 60) {
|
|
return ([string]::Format('{0}s', $TimeValue));
|
|
}
|
|
|
|
[decimal]$Minutes = $TimeValue / 60;
|
|
[decimal]$Seconds = $Minutes - [math]::Truncate($Minutes);
|
|
[decimal]$Minutes = [math]::Truncate($Minutes);
|
|
[decimal]$Seconds = [math]::Round(60 * $Seconds, 0);
|
|
|
|
$TimeIndex = New-Object -TypeName 'System.Text.StringBuilder';
|
|
$TimeIndex.Append([string]::Format('{0}m', $Minutes)) | Out-Null;
|
|
|
|
if ($Seconds -ne 0) {
|
|
$TimeIndex.Append([string]::Format('{0}s', $Seconds)) | Out-Null;
|
|
}
|
|
|
|
return $TimeIndex.ToString();
|
|
}
|