Xref: utzoo comp.lang.c:15533 comp.sys.ibm.pc:23272 Path: utzoo!attcan!uunet!lll-winken!ames!xanth!mcnc!ece-csc!ncrcae!secola!broadway!furlani From: furlani@broadway.UUCP (John L. Furlani) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Microsoft C 5.1 question Message-ID: <198@broadway.UUCP> Date: 14 Jan 89 21:01:22 GMT References: <104@rpi.edu> Organization: University of South Carolina, College of Engineering Lines: 50 In article <104@rpi.edu>, mcintyre@turing.cs.rpi.edu (David McIntyre) writes: > > Could someone give me 2 or 3 sample lines of code showing > how to print these unsigned dates and times as xx:xx:xx and xx/xx/xxxx > values? > Here are two functions that do just that when passed the date and time, respectively. It should be noted that since DOS stores file times acurate only to 2 second intervals, seconds are usually left off. I recommend looking into purchasing The Waite Group's Microsoft C Bible. It has all the 5.1 functions will full usage, compatability, example codes, other book references for more information on a particular subject, and more. I hope these help. print_sysdate (int date) { unsigned day = (date & 0x1f); unsigned month = (date >> 5) & 0xf; unsigned year = (date >> 9) & 0x7f; printf("%2d/%2d/%2d", day, month, (year + 80)); } print_systime(int time) { char min_str[5]; char sec_str[5]; unsigned second = (time & 0x1f) * 2; unsigned minute = (time >> 5) & 0x3f; unsigned hour = (time >> 11) & 0x1f; if(minute < 10) sprintf(min_str, "0%d", minute); else sprintf(min_str, "%d", minute); if(second < 10) sprintf(sec_str, "0%d", second); else sprintf(sec_str, "%d", second); printf("%2d:%s:%s", hour, min_str, sec_str); } ____________ Disclaimer: "Just blame Me, Myself, and I for it." John L. Furlani The University of South Carolina, Columbia SC (...!uunet!ncrlnk!ncrcae!broadway!furlani)