in reply to Date Conversion: yyddd to yyyymmdd

$ perl -le' use Time::Local qw/ timegm_nocheck /; my $in_date = q/11004/; my ( $in_year, $day_of_year ) = $in_date =~ /\A(\d\d|\d\d\d\d)(\d\d\d) +\z/; $in_year = ( ( 4 == length $in_year ? "" : "20" ) . $in_year ) - 1900; my ( $day, $month, $year ) = ( gmtime timegm_nocheck 0, 0, 0, $day_of_ +year, 0, $in_year )[ 3, 4, 5 ]; printf "%d %d %d\n", $year + 1900, $month + 1, $day; ' 2011 1 4

Replies are listed 'Best First'.
Re^2: Date Conversion: yyddd to yyyymmdd
by Anonymous Monk on Jan 05, 2011 at 08:41 UTC
    Booo :) booo Doing your own century math is so 2001 1993 :) and oh look, Time::Piece->strptime seems to be broken

      “I was dreamin’ when I wrote this, so sue me if I code too fast ...”

      – (with apologies to...) Prince; 1999.