[lug] Perl days/dates

Atkinson, Chip CAtkinson at Circadence.com
Tue Nov 14 16:55:40 MST 2000


Greetings,

I'm writing a perl script to figure out the day of the week based on a given
date.  The numeric value for the day of the week seems rather odd in that
the week starts with Friday.  Does anyone know about this?  Here's the
script in its entirety.

Chip

#!/usr/bin/perl

$| = 1;
use strict;
use Time::Local;

use vars qw (@months @days $i);
use vars qw ($sec $min $hours $mday $mon $year);
use vars qw ($TIME $WEEKDAY @datestuff);

@months = ("January",
           "February",
           "March",
           "April",
           "May",
           "June",
           "July",
           "August",
           "September",
           "October",
           "November",
           "December");

@days = ("Fri",
         "Sat",
         "Sun",
         "Mon",
         "Tue",
         "Wed",
         "Thu",
         "Fri",
         "Sat");



$year = 2000;
$mon  = 11;
$mday  = 4;
for ($mday = 1; $mday < 11; $mday++)
{
  $TIME = timelocal (1, 1, 1, $mday, $mon, $year);
   print ("\nYear: $year, Month: $mon, Day: $mday");

   @datestuff = localtime ($TIME);
   print (" Mon: $datestuff[4]");
   print (" Year: ", $datestuff[5] + 1900);
   print (" Wday: ", $days[$datestuff[6]], "\n");
}




More information about the LUG mailing list