mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 08:34:46 +02:00
add change_seconds function
This commit is contained in:
parent
b1b9c3ebb3
commit
825b52aa4a
@ -306,6 +306,31 @@ sub minimal_version {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub change_seconds {
|
||||||
|
my %options = @_;
|
||||||
|
my ($str, $str_append) = ('', '');
|
||||||
|
my $periods = [
|
||||||
|
{ unit => 'y', value => 31556926 },
|
||||||
|
{ unit => 'M', value => 2629743 },
|
||||||
|
{ unit => 'w', value => 604800 },
|
||||||
|
{ unit => 'd', value => 86400 },
|
||||||
|
{ unit => 'h', value => 3600 },
|
||||||
|
{ unit => 'm', value => 60 },
|
||||||
|
{ unit => 's', value => 1 },
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (@$periods) {
|
||||||
|
my $count = int($options{value} / $_->{value});
|
||||||
|
|
||||||
|
next if ($count == 0);
|
||||||
|
$str .= $str_append . $count . $_->{unit};
|
||||||
|
$options{value} = $options{value} % $_->{value};
|
||||||
|
$str_append = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user