#!/usr/bin/perl
use Time::Local;
require '/usr/share/mhonarc/mhtime.pl';
$y = shift if ($ARGV[0] eq '-y');
if (@d = &mhonarc::parse_date($l=<>)) {
    $currentTime = time;
    $receivedTime = timelocal($d[6],$d[5],$d[4],$d[1],$d[2],($d[3] < 1900 ? $d[3] : $d[3]- 1900));
    if(abs($currentTime - $receivedTime) < 172800)   # more than three days difference
    {
        printf "%02d", $d[3] % 100;
        printf "%02d",($d[2]+1) if (!$y);
    }
    else
    {
        printf "%02d", (((localtime)[5] + 1900) % 100);
        printf "%02d", ((localtime)[4] + 1);
    }
}
else {
    printf "%02d", (((localtime)[5] + 1900) % 100);
    printf "%02d", ((localtime)[4] + 1);
}
