#!/usr/bin/perl
use Time::Local;
use Getopt::Std;
require '/usr/share/mhonarc/mhtime.pl';
$|++;
getopts('dy');		# $opt_y => don't print year, #opt_d => disable time check
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) < 259200) || $opt_d)   # more than three days difference
    {
        printf "%02d", $d[3] % 100;
        printf "%02d",($d[2]+1) if (!$opt_y);
    }
    else
    {
        printf "%02d", (((localtime)[5] + 1900) % 100);
        printf "%02d", ((localtime)[4] + 1) if (!$opt_y);
    }
}
else {
    printf "%02d", (((localtime)[5] + 1900) % 100);
    printf "%02d", ((localtime)[4] + 1) if (!$opt_y);
}
