It doesn't actually sound like those are Julian dates
that you've got there(1), but days of the year.
Assuming that I'm right, you could try something like
this:
use Time::Local;
my $date = '00250';
my ($yr, $day) = unpack('A2A3', $yr);
# Ugly hack to get round the fact that you have
# two digit dates. Adjust cutoff to taste.
$yr += 100 if $yr < 70;
# Get epoch time at start of year.
my $when = timelocal(0, 0, 0, 1, 0, $yr);
# Increment by number of days
$when += 86_400 * $day;
# Convert back to MMDD
my ($d, $m) = (localtime($when))[3, 4];
++$m;
sprintf('%02d%02d', $d, $m);
(1) See http://www.treasure-troves.com/astro/JulianDate.html
for more stuff about Julian dates.
--
<http://www.dave.org.uk>
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
|