On Sun, 11 Mar 2001 10:52:02 +0100, allan wrote:
>i have three html dropdown boxes containg intergers which a user can
>select as input for a desired date like:
>
>11 03 01
>
>i want to display the input above as:
>
>Sunday the 11th of march 2001
>
>the one that causes the trouble is the weekday.
>so my question is how can i extract/calculate the correct weekday
>based on arbritary user-input in the format shown above?
localtime() can do it. And timelocal(), in the standard module
Time::Local, present in every Perl installation, even a Mac, can find
out which time number (seconds since epoch) is associated with a date.
my($d,$m,$y) = ('11', '3', '01');
use Time::Local;
my $time = timelocal(0, 0, 12, $d, $m-1, 2000+$y);
my($dow) = (localtime($time))[6];
my @wday = qw(sunday monday tuesday wednesday thursday friday
saturday);
print "DOW = $wday[$dow]\n";
# coincidence? I think not!
print scalar localtime($time); print "\n";
--
Bart.