[comp.lang.pascal] Day of Week Algorithm

bo@hubcap.clemson.edu (Bo Slaughter) (09/25/89)

Does anyone out there have a day of the week algorithm in pascal?
I want to be able to pass to it the date, and get the day out.
Something like this:

function dayofweek(day,month,year:integer):integer;

Pass to it 09 as the month, 24 as the day, and 1989 as the year, and get
1 as the output (sunday).

Thanks,
Bo Slaughter

bkottman@wright.EDU (Brett Kottmann) (09/26/89)

in article <6570@hubcap.clemson.edu>, bo@hubcap.clemson.edu (Bo Slaughter) says:
> 
> 
> Does anyone out there have a day of the week algorithm in pascal?
> I want to be able to pass to it the date, and get the day out.
> Something like this:
> 
> function dayofweek(day,month,year:integer):integer;
> 
> Pass to it 09 as the month, 24 as the day, and 1989 as the year, and get
> 1 as the output (sunday).
>

	Turbo Pascal has one built in,

otherwise, most of the Pascal textbooks use that program as an example.

It is similar to:

	check_for_leap_year(date);
	(add 1 for jan if yes)
	day_of_week = (day_of_year mod 7) + 1; 

where day_of_year is from 1..365 (366 for leap year).

	you can convert to day or have a set of (mon, tue, etc.) and
use the pos() function also.

jeff@com2serv.C2S.MN.ORG (Jeffery S. Wilson) (09/26/89)

In article <6570@hubcap.clemson.edu> bo@hubcap.clemson.edu (Bo Slaughter) writes:
>
>Does anyone out there have a day of the week algorithm in pascal?
>I want to be able to pass to it the date, and get the day out.
>Something like this:
>
>function dayofweek(day,month,year:integer):integer;
>
>Pass to it 09 as the month, 24 as the day, and 1989 as the year, and get
>1 as the output (sunday).
>
>Thanks,
>Bo Slaughter

Come on Bo, any reasonably competent programmer should be able to come up with
a function like this in a few minutes.  Why waste net.dollars begging for an 
answer?  I'm sure someone there at Clemson would be able to help you.  Then 
again, maybe not.

Is this a programming assignment for a computer science course you are taking?
If you can't figure this one out on your own, you have no chance pal.

------------------------------------------------------------------------------
Jeffery S. Wilson    |   jeff@c2s.mn.org   |   {amdahl|hpda}!bungia!com50!jeff

conan@vax1.acs.udel.EDU (Robert B Carroll) (09/26/89)

In article <2689@com50.C2S.MN.ORG> jeff@com2serv.c2s.mn.org (Jeffery S. Wilson) writes:
>In article <6570@hubcap.clemson.edu> bo@hubcap.clemson.edu (Bo Slaughter) writes:
>>
>>Does anyone out there have a day of the week algorithm in pascal?
>>I want to be able to pass to it the date, and get the day out.
>>
>Come on Bo, any reasonably competent programmer should be able to come up with
>a function like this in a few minutes.  Why waste net.dollars begging for an 
>answer?  I'm sure someone there at Clemson would be able to help you.  Then 
>again, maybe not.
>
>Is this a programming assignment for a computer science course you are taking?
>If you can't figure this one out on your own, you have no chance pal.
>
>Jeffery S. Wilson    |   jeff@c2s.mn.org   |   {amdahl|hpda}!bungia!com50!jeff

Nice flame. Please don't apply for a job any where east of the
mississippi. I don't want to have to worry about having the remotest chance
of working with you. Ask a simple question and get bullshit back from people
like you. But then again, your mister wizard programmer. I remember you
telling me about the time you wrote that b*tree driven database engine
on your trs-80 pocket computer with 2K ram. And in assembler to boot!
I wish i had your attitude. what a bloody genius! I'm just filling
up the pages in my diary right now! Now i can understand how you got
that job with IBM and drive a 959(no offence towards 959 owners
intended). How i envy you.


-- 
conan@vax1.acs.udel.edu OR conan@192.5.57.1
*******************************************
****I only play DISC GOLF and drink tea****
****      There is NO substitute!      ****

ts@chyde.uwasa.fi (Timo Salmi LASK) (09/26/89)

In article <6570@hubcap.clemson.edu> bo@hubcap.clemson.edu (Bo Slaughter) writes:
>Does anyone out there have a day of the week algorithm in pascal?
>I want to be able to pass to it the date, and get the day out.
>Something like this:
>function dayofweek(day,month,year:integer):integer;

I just don't believe it.  This question has been posed and answered
at least n + 1 times where n -> infinite, and beyond :-). 

Never mind though, let's do it once more.  Dr.Dobb's Journal had the
source in one of last year's issues.  The Numerical Recipies by
William Press & al has this algorithm.  And the Turbo Pascal units
collection TSPAS13.ARC (about to be updated by yours truly) has a
function WKDAYFN (day, month, year : word) : byte; in TSUNTE.TPU. 

...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun

ts@chyde.uwasa.fi (Timo Salmi LASK) (09/26/89)

In article <676@thor.wright.EDU> bkottman@wright.EDU (Brett Kottmann) writes:
>in article <6570@hubcap.clemson.edu>, bo@hubcap.clemson.edu (Bo Slaughter) says:
>> Does anyone out there have a day of the week algorithm in pascal?
>
>	Turbo Pascal has one built in,

Now really!?  Would you please divulge which *built in* Turbo Pascal
function gives the general day of the week.  GetDate does it for the
current date, only.  (Please do not suggest changing the system
date.  It only covers 1980-2079, is destructive in multitasking, and
bad programming anyway.)

...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun

bkottman@thor.wright.edu (Brett Kottmann) (09/27/89)

From article <2689@com50.C2S.MN.ORG>, by jeff@com2serv.C2S.MN.ORG (Jeffery S. Wilson):
> Come on Bo, any reasonably competent programmer should be able to come up with
> a function like this in a few minutes.  Why waste net.dollars begging for an 
> answer?  I'm sure someone there at Clemson would be able to help you.  Then 
> again, maybe not.
> 
> Is this a programming assignment for a computer science course you are taking?
> If you can't figure this one out on your own, you have no chance pal.
>


	It doesn't matter how good a programmer you are if you've never
programmed that kind of application before or have no idea where to
start looking for the information.

	Hope you never need help with a program.... 

brianr@phred.UUCP (Brian Reese) (09/28/89)

In article <2689@com50.C2S.MN.ORG> jeff@com2serv.c2s.mn.org (Jeffery S. Wilson) writes:
>In article <6570@hubcap.clemson.edu> bo@hubcap.clemson.edu (Bo Slaughter) writes:
>>Does anyone out there have a day of the week algorithm in pascal?
>>I want to be able to pass to it the date, and get the day out.
>>Something like this:
>>
>> [psuedo-code deleted]
>>
>>Thanks,
>>Bo Slaughter
>
>Come on Bo, any reasonably competent programmer should be able to come up with
>a function like this in a few minutes.  Why waste net.dollars begging for an 
>answer?  I'm sure someone there at Clemson would be able to help you.  Then 
>again, maybe not.
>Is this a programming assignment for a computer science course you are taking?
>If you can't figure this one out on your own, you have no chance pal.
>
>Jeffery S. Wilson    |   jeff@c2s.mn.org   |   {amdahl|hpda}!bungia!com50!jeff

Come on Jeff, any reasonably sensitive netter should be able to come up with a
more constructive reply than that.  Isn't this kind of thing what this forum is
for in the first place?  Granted, it's a simple task, but Bo may be new to
tickling the 8088's.  Give a guy a break!  (just my half-a-nibble)

BTW, *God* doesn't think he's a *programmer*....what's with you? 

As for my reply....RTFM.  ;-)
(You may learn more in just a few minutes than if I were to give you the code.)
(If you're still stuck, e-mail me.  I'd be happy to help.)


Brian

Defn: Broad-mindedness: high-mindedness that has been flattened by expirience.

-- 
Brian Reese                           uw-beaver!pilchuck!seahcx!phred!brianr
Physio Control Corp., Redmond, Wa.                         brianr@phred.UUCP
"Do not write on this line.  This line has been left blank intentionally."