Newsgroups: comp.lang.c Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!geac!tse!markt From: markt@tse.uucp (Mark Turner) Subject: SUMMARY: Date to DOW Conversion Message-ID: <1991Jun20.171806.5722@tse.uucp> Reply-To: markt@tse.UUCP (Mark Turner) Organization: Toronto Stock Exchange Distribution: na Date: Thu, 20 Jun 91 17:18:06 GMT 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@taumet, as follows: >Well, I'm afraid it is embarassingly obvious. Check your manual for the > 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@tse.uucp - Floor & Product Systems - The Toronto Stock Exchange