From d3e333dc4bc57a1fc5be3985340083f52ef14325 Mon Sep 17 00:00:00 2001 From: doug Date: Fri, 11 Oct 2013 03:01:20 -0400 Subject: [PATCH] Show unix time along with formatted date --- Changes | 1 + bin/log-defer-viz | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Changes b/Changes index 24b1a7c..5fdbd4e 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,5 @@ * Fix bug in date formatting (thanks Mike R) + * Show unix time along with formatted date 0.310 2013-09-01 * Don't die on log lines that don't start with JSON diff --git a/bin/log-defer-viz b/bin/log-defer-viz index 451000c..36b8ce2 100755 --- a/bin/log-defer-viz +++ b/bin/log-defer-viz @@ -226,7 +226,7 @@ sub handle_entry { } if ($opt->{date}) { - my $datetime = ''; + my $formatted = ''; if ($opt->{'since-now'}) { require Date::Calc; @@ -234,23 +234,23 @@ sub handle_entry { my $elapsed = int(time - $entry->{start}); if ($elapsed <= 0) { - $datetime = abs($elapsed) . " seconds in the future.. clock is wrong?"; + $formatted = abs($elapsed) . " seconds in the future.. clock is wrong?"; } else { my ($Dd,$Dh,$Dm,$Ds) = Date::Calc::Normalize_DHMS(0, 0, 0, int(time - $entry->{start})); - $datetime .= "$Dd days " if $Dd; - $datetime .= "$Dh hours " if $Dh; - $datetime .= "$Dm minutes " if $Dm; - $datetime .= "$Ds seconds " if $Ds; + $formatted .= "$Dd days " if $Dd; + $formatted .= "$Dh hours " if $Dh; + $formatted .= "$Dm minutes " if $Dm; + $formatted .= "$Ds seconds " if $Ds; - $datetime .= "ago"; + $formatted .= "ago"; } } else { require Date::Format; - $datetime = Date::Format::time2str("%Y-%m-%d %a %H:%M:%S$millis %Z", $entry->{start}); + $formatted = Date::Format::time2str("%Y-%m-%d %a %H:%M:%S$millis %Z", $entry->{start}); } - my $date_header = "------ " . $datetime . " ------"; + my $date_header = "------ $formatted ($entry->{start}) ------"; $date_header = colored($date_header, 'black on_white') if $opt->{colour};