Skip to content

Instantly share code, notes, and snippets.

@AndyA
Created September 2, 2014 17:33
Show Gist options
  • Select an option

  • Save AndyA/018fdd6f9c24da27af22 to your computer and use it in GitHub Desktop.

Select an option

Save AndyA/018fdd6f9c24da27af22 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use Date::Parse;
use Data::Dumper;
use JSON;
use POSIX qw( strftime );
my %itm = ();
my @rec = ();
while (<>) {
if (/^commit/) {
push @rec, {%itm} if keys %itm;
%itm = ();
next;
}
$itm{author} = $1 if /^Author:\s+(.+)/;
$itm{date} = str2time($1) if /^Date:\s+(.+)/;
}
push @rec, {%itm} if keys %itm;
@rec = grep { $_->{author} =~ /smoo/ } @rec;
my %by_day = ();
for my $itm (@rec) {
my $day = int( $itm->{date} / ( 60 * 60 * 24 ) );
push @{ $by_day{$day} }, $itm;
}
for my $day ( sort { $a <=> $b } keys %by_day ) {
my $date = strftime '%Y/%m/%d', gmtime $day * 60 * 60 * 24;
print "$date\n";
for my $itm ( sort { $a->{date} <=> $b->{date} } @{ $by_day{$day} } ) {
print ' ', strftime( '%H:%M:%S', gmtime $itm->{date} ), ' ',
$itm->{author}, "\n";
}
}
# vim:ts=2:sw=2:sts=2:et:ft=perl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment