[comp.lang.pascal] I need a date :) please help

ts@uwasa.fi (Timo Salmi LASK) (04/07/90)

In article <13000001@uxh.cso.uiuc.edu> mead@uxh.cso.uiuc.edu writes:
>QUERY:  Does anyone know of *any* source for an intelligent algorythm
>for getting the day ('Monday, Tuesday, ...') from the date (4/3/90).
>My PC does it like lightning each time I issue the 'DATE' command, and
>if IBM can do it, anyone can - right? :)  Textbooks or whatever are
>fine, but please don't direct me to existing software unless it's PD
>source code (in BASIC, C, Pascal, or FORTRAN).  Thanks.

Ok, I won't direct you anywhere :-), but if anyone else has the same
problem, there is an unit in (/pc/ts/)tspas18.arc to do just this. 
Available by anonymous ftp from chyde.uwasa.fi. 

... I'll backtrack a bit.  Also see Press & Flannery & al:
Numerical Recipes, Cabridge University Press.  Hope this helps.

(Incidentally, this has been a very frequently asked question, but
for some reason it has been dormant for a few months, kinda lying
low, biding its time, or whatever.  You wouldn't believe how many
messages we had about this way back when.)

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

mead@uxh.cso.uiuc.edu (04/07/90)

Sorry if you caught this in another group (but then why did you look at
this one?).

I am writing a simulation in which the user will get (simulated)
"memos".  These memos will have embedded symbols which my code shall
have to expand into appropriate dates (eg, @d3 might get expanded to
the string, 'Tuesday April 3, 1990' - the date three days before I'm
writing this note.  Tomorrow, it would be expanded to 'Wednesday April
4, 1990', ...).

QUERY:  Does anyone know of *any* source for an intelligent algorythm
for getting the day ('Monday, Tuesday, ...') from the date (4/3/90).
My PC does it like lightning each time I issue the 'DATE' command, and
if IBM can do it, anyone can - right? :)  Textbooks or whatever are
fine, but please don't direct me to existing software unless it's PD
source code (in BASIC, C, Pascal, or FORTRAN).  Thanks.

-alan mead : mead@uxh.cso.uiuc.edu

n257cl@tamunix.tamu.edu (Sean Malloy) (04/13/90)

As I said to Mr. Mead, there is a DOS service function available to you
that does this automatically.

Set AH = 2Ah (decimal 42)
Use interrupt 21h (decimal 33).

Register AL now contains a number (0-6) which corresponds to Sunday -
Saturday.  Register CX will contain the year, and DH contains the month #
and DL contains the day #.  I'll leave it up to one more experienced in 
linking assembly to PASCAL to explain how to accomplish this in PASCAL.
Perhaps you can use a Pascal Command to check the contents of your
registers?

Best of luck with this (shorter) method...
-Sean