I'd give each day from 1/1/0001 a sequential number, and I'd test the
modulus of that day number divided by 7 to get the day of the week:
Given you have $yearnum $monthnum $daynum as input, you want a dayname out
of the array @monthdays defined below. Here's my untested [away from perl at
moment] go:
@daynames = ('mon','tue','wed','thu','fri','sat','sun');
@monthdays = (31,58,89,119,150,180,211,242,272,303,333,364);
$complete_years_contribution = ( int( ($yearnum-1) / 4)*(364+364+364+365) )
+ ( ( ($yearnum-1) % 4) * 364);
$complete_months_contribution = $monthdays [$monthnum - 2];
if ($year % 4) = 0{$complete_months_contribution ++};
$totaldays_AD = $complete_years_contribution + $complete_months_contribution
+ $daynum;
$dayname = $daynames[$totaldays_AD - int($totaldays_AD % 7) - 1];
John
PS - you have to get the position in the @monthdays array right - didn't
work tis out
----- Original Message -----
From: Scott R. Godin <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 11, 2001 9:04 PM
Subject: Re: [MacPerl-AnyPerl] input to formatted date
> on 03/11/2001 04:52 AM, allan at [EMAIL PROTECTED] wrote:
>
> > hi
> >
> > 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?
>
>
> This is just a guess since I've never looked at it myself, but have you
> checked the Date::Calc module? This sort of task seems to be something
that
> would be appropriate for a module of said name.
>
> I could be wrong, but it's worth a quick investigation via CPAN shell's
> 'readme Date::Calc' ... I'm just too lazy to do it for you ;-)
>
> --
> Scott R. Godin | e-mail : [EMAIL PROTECTED]
> Laughing Dragon Services | web : http://www.webdragon.net/
>
>
>