mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
WIP
This commit is contained in:
parent
5fd4838921
commit
01ebbaf085
1 changed files with 18 additions and 11 deletions
|
|
@ -3,19 +3,26 @@
|
||||||
function ConvertTo-Seconds()
|
function ConvertTo-Seconds()
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
[single]$Value,
|
[string]$Value,
|
||||||
[string]$Unit
|
[char]$Unit,
|
||||||
|
[switch]$Milliseconds
|
||||||
);
|
);
|
||||||
|
|
||||||
switch ($Unit) {
|
#100 D
|
||||||
{ 'ms', 'milliseconds' -contains $_ } { $result = ($Value / [math]::Pow(10, 3)); $boolOption = $true; }
|
#100 D
|
||||||
{ 's', 'seconds' -contains $_ } { $result = $Value; $boolOption = $true; }
|
$Unit = $Value.Substring($Value.get_Length()-2)[0];
|
||||||
{ 'm', 'minutes' -contains $_ } { $result = ($Value * 60); $boolOption = $true; }
|
[single]$ValueSplitted = $Value;
|
||||||
{ 'h', 'hours' -contains $_ } { $result = ($Value * 3600); $boolOption = $true; }
|
#$Name.Substring($Name.get_Length()-1);
|
||||||
{ 'd', 'day' -contains $_ } { $result = ($Value * 86400); $boolOption = $true; }
|
#$Name.Substring(0,$Name.get_Length()-1);
|
||||||
{ 'W', 'Week' -contains $_ } { $result = ($Value * 604800); $boolOption = $true; }
|
switch ([int][char]$Unit) {
|
||||||
{ 'M', 'Month' -contains $_ } { $result = ($Value * [math]::Pow(2.628, 6)); $boolOption = $true; }
|
# { 'ms', 'milliseconds' -contains $_ } { $result = ($Value / [math]::Pow(10, 3)); $boolOption = $true; }
|
||||||
{ 'Y', 'Year' -contains $_ } { $result = ($Value * [math]::Pow(10, 7)); $boolOption = $true; }
|
{ 115 -contains $_ } { $result = $ValueSplitted; $boolOption = $true; }
|
||||||
|
{ 109 -contains $_ } { $result = ($ValueSplitted * 60); $boolOption = $true; }
|
||||||
|
{ 104 -contains $_ } { $result = ($ValueSplitted * 3600); $boolOption = $true; }
|
||||||
|
{ 100 -contains $_ } { $result = ($ValueSplitted * 86400); $boolOption = $true; }
|
||||||
|
{ 87 -contains $_ } { $result = ($ValueSplitted * 604800); $boolOption = $true; }
|
||||||
|
{ 77 -contains $_ } { $result = ($ValueSplitted * (2.5[math]::Pow(10, 6))); $boolOption = $true; }
|
||||||
|
{ 89 -contains $_ } { $result = ($ValueSplitted * (3.10[math]::Pow(10, 7))); $boolOption = $true; }
|
||||||
default {
|
default {
|
||||||
if (-Not $boolOption) {
|
if (-Not $boolOption) {
|
||||||
Throw 'Invalid input';
|
Throw 'Invalid input';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue