Article 12042 of comp.lang.perl:
Newsgroups: comp.lang.perl
Path: feenix.metronet.com!news.utdallas.edu!convex!cs.utexas.edu!howland.reston.ans.net!EU.net!uknet!comlab.ox.ac.uk!mbeattie
From:
[email protected] (Malcolm Beattie)
Subject: Re: Help: Needs DayOfWeek on a given day
Message-ID: <
[email protected]>
Originator: mbeattie@black
Organization: Oxford University Computing Services, Oxford, U.K.
References: <
[email protected]>
Distribution: comp
Date: Mon, 28 Mar 1994 09:22:04 GMT
Lines: 25
In article <
[email protected]>
[email protected] (Peter Leung) writes:
>Hi,
>
>I'm a relatively new PERL user.
>
>I need to determine the DAY of Week for any given day, eg., Jan 10, 1994.
>
>Do I need to write a C program?
>
>Can I use PERL's localtime and how do I compose the time input needed for localtime?
Set $d to date (1-31), $m to month (1-12), $y to year (e.g. 1994). Then
@d = (0,3,2,5,0,3,5,1,4,6,2,4);
@day = (Sun, Mon, Tue, Wed, Thu, Fri, Sat);
$y-- if $m < 3;
$day = $day[($y+int($y/4)-int($y/100)+int($y/400)+$d[$m-1]+$d) % 7];
$day gives the day.
--Malcolm
--
Malcolm Beattie <
[email protected]>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee