I am almost back in a regular running schedule.
So looking ahead at the Copenhagen Marathon 2010, I sat down and adjusted a script I wrote at an earlier occasion.
- #!/usr/bin/perl
- # $Id$
- use strict;
- use warnings;
- use DateTime;
- use constant DAYS_IN_WEEK => 7;
- our $VERSION = ‘0.02’;
- my @distances
- = qw(20 45 50 65 65 60 50 55 55 55 45 50 50 50 40 45 45 45 35 40 40 40 30 35);
- if ( !$ARGV[0] ) {
- die ‘Usage: marathon-training.pl <date of marathon ddmmyyyy>’;
- }
- #parsing argument
- my ( $day, $month, $year ) = $ARGV[0] =~ m{
- (\d{2}) #day (two digits)
- (\d{2}) #month (two digits)
- (\d{4}) #year (four digits)
- }mx;
- #DT does it own dying
- my $dt = new DateTime(
- year => $year,
- month => $month,
- day => $day,
- time_zone => ‘UTC’,
- );
- #Using DateTime (machine) to go back the number of weeks scheduled in distances
- #minus one of be of by one week when we get to the marathon, eventhough an
- #extra week of preparation might not hurt
- $dt = $dt->subtract(
- DateTime::Duration->new(
- days => ( DAYS_IN_WEEK * scalar @distances ) - DAYS_IN_WEEK
- )
- );
- my $dt_now = DateTime->now(time_zone => ‘UTC’,);
- #Print the plan from the beginning and on...
- my $i = 0;
- while (@distances) {
- printf ‘Week: %02d’, ++$i;
- print “\tWeek number: “ . $dt->week_number();
- $dt = $dt->add(DateTime::Duration->new( days => DAYS_IN_WEEK ));
- my $this_week;
- if ($dt->week_number() == $dt_now->week_number()) {
- $this_week++;
- }
- print “\tDistance: “ . pop @distances;
- if ($this_week) {
- print “ <-- this week\n”;
- } else {
- print “\n”;
- }
- }
- exit 0;
So running it with the date: 23rd. of May 2010 gives the following output:
; perl ~/develop/stuff/marathon-training.pl 23052010
Week: 01 Week number: 50 Distance: 35
Week: 02 Week number: 51 Distance: 30
Week: 03 Week number: 52 Distance: 40
Week: 04 Week number: 53 Distance: 40
Week: 05 Week number: 1 Distance: 40
Week: 06 Week number: 2 Distance: 35 <-- this week
Week: 07 Week number: 3 Distance: 45
Week: 08 Week number: 4 Distance: 45
Week: 09 Week number: 5 Distance: 45
Week: 10 Week number: 6 Distance: 40
Week: 11 Week number: 7 Distance: 50
Week: 12 Week number: 8 Distance: 50
Week: 13 Week number: 9 Distance: 50
Week: 14 Week number: 10 Distance: 45
Week: 15 Week number: 11 Distance: 55
Week: 16 Week number: 12 Distance: 55
Week: 17 Week number: 13 Distance: 55
Week: 18 Week number: 14 Distance: 50
Week: 19 Week number: 15 Distance: 60
Week: 20 Week number: 16 Distance: 65
Week: 21 Week number: 17 Distance: 65
Week: 22 Week number: 18 Distance: 50
Week: 23 Week number: 19 Distance: 45
Week: 24 Week number: 20 Distance: 20If you compare to the output of the referred blog entry, this is of course another marathon, so the dates are different, but I have just added an indicator of the current week.



0 Comments.