Dermot has asked for the wisdom of the Perl Monks concerning the following question:

Oh great ones. How do I convert from year/day of year format to dd/mm/yyyy format ? I can think of a some non-trivial ways to do it. Are there any simple ways to do it ?
  • Comment on Converting date to dd/mm/yyyy from year/day of year

Replies are listed 'Best First'.
Re: Converting date to dd/mm/yyyy from year/day of year
by merlyn (Sage) on Sep 27, 2000 at 19:44 UTC
Re: Converting date to dd/mm/yyyy from year/day of year
by neophyte (Curate) on Sep 27, 2000 at 20:34 UTC
(Dermot) Re: Converting date to dd/mm/yyyy from year/day of year
by Dermot (Scribe) on Sep 27, 2000 at 20:01 UTC
    Someone offline suggested this to me. Ok, fair enough you don't reinvent the wheel unless you have too or for educational purposes but leaving that aside for the moment is messing with dates one of those things like parsing HTML that you're just better off not trying to do from scratch ?
    #!/usr/bin/perl -w use strict; use Time::Local qw( timelocal ); my $year = 2001; my $day = 200; my $year_sec = timelocal(0, 0, 0, 1, 0, $year-1900); my $new_sec = $year_sec + ($day-1) * 60 * 60 *24; print localtime($new_sec)."\n"; my ($theday, $month) = (localtime($new_sec))[3,4]; $month++; print "day = $theday, month = $month\n";
RE: Converting date to dd/mm/yyyy from year/day of year
by little (Curate) on Sep 27, 2000 at 19:49 UTC
    e.g. POSIX, which is quite powerfull for this, but sometimes it's also overkill:-)
    Have a nice day
    All decision is left to your taste