package doy;

;# Year, Month, Day   --> Day of Year
;# $_[0] $_[1]  $_[2]     $doy

sub ymdtodoy {

if ( $_[0] % 4 != 0 ) {
  @nmday = (0,31,59,90,120,151,181,212,243,273,304,334);
} else {
  @nmday = (0,31,60,91,121,152,182,213,244,274,305,335);
}

$doy = $nmday[$_[1]-1] + $_[2];

;#printf("%4.4d/%2.2d/%2.2d %3.3d\n", $_[0], $_[1], $_[2], $doy);

return($doy);
}
1;
