Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!unmvax!polyslo!ddurbin From: ddurbin@polyslo.CalPoly.EDU (Daniel A. Durbin) Newsgroups: comp.sys.ibm.pc Subject: Re: Date routines in turbo C 1.5. Summary: fdate.c Keywords: Consistency. Message-ID: <11479@polyslo.CalPoly.EDU> Date: 16 May 89 06:58:59 GMT References: <1513@sdcc15.ucsd.edu> Reply-To: ddurbin@polyslo.CalPoly.EDU (Daniel A. Durbin) Distribution: usa Organization: Cygnus Data Systems (805) 541-8505 (data) Lines: 60 In article <1513@sdcc15.ucsd.edu> pa1343@sdcc15.ucsd.edu (John J. Marco) writes: >I am trying to write an 'ls' program under DOS. I am using Turbo C >version 1.5 and I use findfirst() and findnext() to get the files. >I am having a problem with file dates. find... () returns a structure >ffblk such that the time is split into (int ff_ftime, int ff_fdate); >These functions use the DOS interrupt for finding the files. >Does anybody know of any routines for converting these integers to >UNIX format? If not, could somebody who knows please email me and tell >me how exactly these integers tell the time. Turbo C does not seem >to have any conversion routines and when I print out the integers >I get meaningless numbers which do not look like dates. >I appreciate any and all help. > I whipped this out real quick and it shows how to decode the fdate and ftime returned by the DOS interrupt used by the TurboC findfirst() and findnext() functions. I tested it and it does the same thing as a DOS dir command. BEGIN -- cut here -- cut here -------------------- /* fdate.c by Daniel Durbin 05/15/89 */ /* for TurboC v1.5 */ #include #include #include void main(int argc, char *argv[]) { char s1[9], s2[9]; struct ffblk ffblk; int result; if (argc < 2) return; result = findfirst(argv[1], &ffblk, FA_ARCH); while (result != -1) { sprintf(s1, "%02d/%02d/%02d", (ffblk.ff_fdate & 0x01e0) / 32, (ffblk.ff_fdate & 0x001f), (ffblk.ff_fdate & 0xfe00) / 512 + 80 ); sprintf(s2, "%02d:%02d:%02d", (ffblk.ff_ftime & 0xfc00) / 2048, (ffblk.ff_ftime & 0x07e0) / 32, (ffblk.ff_ftime & 0x001f) ); printf("%-12s %6lu %s %s\n", ffblk.ff_name, ffblk.ff_fsize, s1, s2 ); result = findnext(&ffblk); } } -------------- END -- cut here -- cut here Daniel Durbin___________________________________________________ SysOp: Cygnus X-1 BBS | CIS: 73447,1744 (805) 541-8505 (data) | GEnie: D.DURBIN EL major at PolySlo | ddurbin@polyslo.CalPoly.EDU