#!/usr/bin/perl

use POSIX qw(mktime);

my $date = $ARGV[0];

if ($date =~m#(\d\d)/(\d\d)/\d?\d?(\d\d)#) {
	$date = sprintf("%04d%02d%02d","20$3",$2,$1);
}

$date=~m/(\d{4})(\d{2})(\d{2})/ || die "I'm fick. I don'tgetcha date format.";

$date = mktime(59,59,23,$3,$2-1,$1-1900,,,,);
my $diff = ($date - time) / (60*60*24);

die "Back in time? fro" if $diff <0;
die "Less than a day, you blithering fool" if $diff < 1;

my %units = qw(365 year 7 week 1 day);

for (reverse sort {$a <=> $b} keys %units) {
	if ( int($diff / $_ )) { push @out, plural(int($diff/$_),$units{$_}); }
	$diff = int($diff % $_);
}

my $end = (localtime())[2] < 17 ? ' and to-cocking-day' : '';
print "Another " .join(', ',@out) . "$end\n";

sub plural { return "$_[0] $_[1]" . ($_[0] > 1 ? 's' : ''); }

# BUGS - sod leap years
