SUMMARY: Date to DOW Conversion
Mark Turner
markt at tse.uucp
Fri Jun 21 03:18:06 AEST 1991
Yesterday, I posted the following query ....
>Hi folks! Can anyone help me with suggestions on how to convert a date to a day
>of the week? For example, I start with a date like '19910619'; I'd like some
>function to return 'Wed' or '4' or some such indication of the day. This must
>be doable!
I quickly received a helpful reply from steve at taumet, as follows:
>Well, I'm afraid it is embarassingly obvious. Check your manual for the
><time.h> functions. You take your date and plug values into a variable
>of type 'struct tm'. Once you have that, you use mktime() to convert
>it to a time_t, simultaneously filling in the missing fields in the
>struct. If any values in the struct are out of range, mktime() will
>adjust them. You now have a date expressed as both a time_t and a
>struct tm, and you can do anything you like with that.
Thanks to all those who took time to suggest solutions.
Regards,
Mark Turner
--------------------------------------------------------------------------------
mark at tse.uucp - Floor & Product Systems - The Toronto Stock Exchange
More information about the Comp.lang.c
mailing list