Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>dostounix() convert date and time to unix time format</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 dostounix()             Convert Date and Time to UNIX Time Format

 #include   <dos.h>

 long         dostounix(dateptr,timeptr);
 struct date  *dateptr;                  Pointer to date structure
 struct time  *timeptr;                  Pointer to time structure

    dostounix() converts a date and time into UNIX format--the number of
    seconds since midnight, January 1, 1970 (GMT). 'dateptr' and
    'timeptr' point respectively to a date and a time structure, both of
    which must contain valid DOS date and time information.

    The date and time can be obtained from getdate() and gettime().

       Returns:     The UNIX version of current time

   Portability:     MS-DOS only.

   -------------------------------- Example ---------------------------------

    The following statements produce a UNIX format time from the DOS date
    and time.

           #include <dos.h>

           main()
           {
               long unixtime;
               struct date dosdate;
               struct time dostime;
               char *st_time;

               getdate(&dosdate);
               gettime(&dostime);
               unixtime = dostounix(&dosdate,&dostime);
               st_time = ctime(&unixtime);
               printf("The date and time is %s\n",st_time);
           }


See Also: ctime() getdate() gettime() unixtodos()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson