mirror of https://github.com/schoebel/mars
marsadm: allow omission of nanoseconds
This commit is contained in:
parent
7697826b5d
commit
0edca689bf
|
@ -889,14 +889,23 @@ sub get_peers {
|
||||||
|
|
||||||
sub __conv_tv {
|
sub __conv_tv {
|
||||||
my ($tv_sec, $tv_nsec) = @_;
|
my ($tv_sec, $tv_nsec) = @_;
|
||||||
|
if (defined($tv_nsec)) {
|
||||||
|
$tv_nsec = ".$tv_nsec";
|
||||||
|
} else {
|
||||||
|
$tv_nsec = "";
|
||||||
|
}
|
||||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(int($tv_sec));
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(int($tv_sec));
|
||||||
return "$tv_sec.$tv_nsec" unless defined($sec);
|
return "$tv_sec$tv_nsec" unless defined($sec);
|
||||||
return sprintf("%04d-%02d-%02d %02d:%02d:%02d.%s", $year+1900, $mon + 1, $mday, $hour, $min, $sec, $tv_nsec);
|
return sprintf("%04d-%02d-%02d %02d:%02d:%02d%s", $year+1900, $mon + 1, $mday, $hour, $min, $sec, $tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _replace_timestamps {
|
sub _replace_timestamps {
|
||||||
my ($txt) = @_;
|
my ($txt, $omit_nsec) = @_;
|
||||||
|
if (defined($omit_nsec) && $omit_nsec) {
|
||||||
|
$txt =~ s:([0-9]{9,99})\.([0-9]{9}):__conv_tv($1):ge;
|
||||||
|
} else {
|
||||||
$txt =~ s:([0-9]{9,99})\.([0-9]{9}):__conv_tv($1,$2):ge;
|
$txt =~ s:([0-9]{9,99})\.([0-9]{9}):__conv_tv($1,$2):ge;
|
||||||
|
}
|
||||||
return $txt;
|
return $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue