
use Time::Local;
my $latitude = shift() || 40;   # Use negative for South latitude
my $pi = 3.141592654;
$latitude /= 180/$pi;  # Radians
my $spy = 86400 * 365.2422;

prec("20061201");
prec("20061221");
for ("01" .. "07") {
  prec("2007${_}01");
}
prec("20070322");
prec("20070621");

sub len {
  my  $date = shift;
  my ($y, $m, $d) = unpack "A4 A2 A2", $date;
  my $time = timelocal(0,0,0,$d, $m-1, $y-1900);
  720 - 160 * cos(($time + 11*86400) * 2 * 3.1416 / $spy);
}

sub prec {
  my $date = shift;
  printf "%8s %7.3f\n", $date, len($date);
}
