Time::Local (which should be in your Perl distribution) has a conversion mode where its date arguments aren't validated to be in the proper range. A nifty side-effect of this is that you can ask it to convert the 176th of January (or 10_000th second of 2003, or 1234th hour of February, etc), and it will Do What You Mean©.
use Time::Local 'timelocal_nocheck';
my $year = 2003 - 1900;
my $dyear = 176;
my $epoch = timelocal_nocheck 0,0,0,$dyear,0,$year;
## January is month 0 ^
Time::Local only converts Y/M/D,H:M:S to epoch seconds, but you can very easily extract out the month and day components from the epoch time with localtime:
my ($month, $day) = (localtime $epoch)[4,3];
$month++; ## again, months run from 0 to 11
.. or you could format the date with whatever format you like, using strftime
use POSIX 'strftime';
print strftime("%x", localtime $epoch), $/;
For doing simple date calculations like this, using localtime and Time::Local is a lot less overhead than the behemoth Date::Calc.
UPDATE: If you only care about getting the text output (you don't need the day/month components individually), it looks like strftime also normalizes its input in the same way as timelocal_nocheck:
$ perl -MPOSIX=strftime -le 'print strftime("%c", 0,0,0,176,0,103)'
Thu Jun 25 00:00:00 2003
Also realized that I needed to use 2003-1900 (not just 2003) as the final argument to timelocal_nocheck, so updated that.
blokhead |