title: Adding MM::SS times, dividing them and printing the average
body: <p>Let's say I just ran for 10 km and I now have 10 1km split times in the form of MM::SS.  I want a simple way to add up an arbitrary number of the split times and average them.  For instance, maybe I want to see how much faster (or slower) the last 5 km were when compared with the first 5 km.</p>
  
  <p>I can do this myself by parsing the times, dividing them into seconds and then converting them back to MM::SS.  The math isn't hard, but I was wondering if something on CPAN already does this in a simple way.  My first attempt was using DateTime, but it doesn't convert from seconds to minutes, because of leap seconds.</p>
  
  <p>To be clear, I don't care about leap seconds in this context, but I'm curious as to whether a library exists.  As an example, here is what I have tried.</p>
  
  <pre><code>#!/usr/bin/env perl
  
  use strict;
  use warnings;
  use feature qw( say );
  
  use DateTime::Format::Duration;
  
  my $formatter = DateTime::Format::Duration-&gt;new( pattern =&gt; '%M:%S' );
  
  my @splits = @ARGV;
  my $split_number = @splits;
  
  my $total = $formatter-&gt;parse_duration( shift @splits );
  
  foreach my $split (@splits) {
      $total-&gt;add_duration(
          $formatter-&gt;parse_duration($split) );
  }
  
  say 'Total time: ' . join ':', $total-&gt;minutes, $total-&gt;seconds;
  
  $total-&gt;multiply( 1 / $split_number );
  
  say 'Average time: ' . join ':', $total-&gt;minutes, $total-&gt;seconds;
  say 'Using DateTime::Format::Duration: ' . $formatter-&gt;format_duration( $total );
  </code></pre>
  
  <p>And a sample run:</p>
  
  <pre><code>$ perl script/add-splits.pl 1:30 2:30
  Total time: 3:60
  Average time: 1.5:30
  Using DateTime::Format::Duration: 01:30
  </code></pre>
  
  <p>So, you can see that the duration object itself, gives me a correct answer, but not something that a human wants to decipher.</p>
  
  <p>DateTime::Format::Duration tries to be helpful, but tosses out 30 seconds in the process.</p>
  
  <p>I'm not looking for the raw code to do this.  I am interested in whether this already exists on CPAN.</p>