Created
September 2, 2014 17:33
-
-
Save AndyA/018fdd6f9c24da27af22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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