Date to Day-of-Week Conversion (Question)

D'Arcy J.M. Cain darcy at druid.uucp
Fri Jun 21 02:45:34 AEST 1991


In article <1991Jun19.170753.593 at tse.uucp> Mark Turner writes:
>Hi folks! Can anyone help me with suggestions on how to convert a date to a
>day of the week? ...
>Please don't suggest that I should reset the system date and then pass a "tm" 
>structure to the one of the ctime-related functions. I'd like to keep the 

No need to muck with the system date.  Just create a tm structure and fill
it in with the known values.  now call mktime(3) and you should have the
day of the week in the tm_wday field.  If you don't have mktime then send
me mail and I will send you a version.  It's a flawed version but the flaw
is well defined and can be worked around.  It calls localtime which is not
strictly allowed under ANSI.   BTW, anyone know where I can get a PD or
freeware localtime so I can fix and post my mktime?

-- 
D'Arcy J.M. Cain (darcy at druid)     |
D'Arcy Cain Consulting             |   There's no government
Toronto, Ontario, Canada           |   like no government!
+1 416 424 2871                    |



More information about the Comp.lang.c mailing list