Permalink
Browse files

Show unix time along with formatted date

  • Loading branch information...
1 parent 6bd746c commit d3e333dc4bc57a1fc5be3985340083f52ef14325 @hoytech committed Oct 11, 2013
Showing with 10 additions and 9 deletions.
  1. +1 −0 Changes
  2. +9 −9 bin/log-defer-viz
View
@@ -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
View
@@ -226,31 +226,31 @@ sub handle_entry {
}
if ($opt->{date}) {
- my $datetime = '';
+ my $formatted = '';
if ($opt->{'since-now'}) {
require Date::Calc;
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};

0 comments on commit d3e333d

Please sign in to comment.