Sets the current system time, using system call 0x2D.
#include <dos.h>
unsigned _dos_settime( struct _dostime_t *time );
time | New system time |
The _dos_settime routine uses system call 0x2D to set the current system time to the value stored in the _dostime_t structure that time points to, as defined in DOS.H. The _dostime_t structure contains the following elements:
Element | Description |
unsigned char hour | 0–23 |
unsigned char minute | 0–59 |
unsigned char second | 0–59 |
unsigned char hsecond | Hundredths of a second; 0–99 |
If successful, the function returns 0. Otherwise, it returns a nonzero value and sets errno to EINVAL, indicating an invalid time was specified.
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
_dos_getdate, _dos_gettime, _dos_setdate, gmtime, localtime, mktime, _strdate, _strtime
/* DSTIME.C: This program changes the time and date values and displays the
* new date and time values.
*/
#include <dos.h>
#include <conio.h>
#include <stdio.h>
#include <time.h>
void main( void )
{
struct _dosdate_t olddate, newdate = { { 4 }, { 7 }, { 1999 } };
struct _dostime_t oldtime, newtime = { { 3 }, { 45 }, { 30 }, { 0 } };
char datebuf[40], timebuf[40];
/* Get current date and time values */
_dos_getdate( &olddate );
_dos_gettime( &oldtime );
printf( “%s %s\n” , _strdate( datebuf ), _strtime( timebuf ) );
/* Modify date and time structures */
_dos_setdate( &newdate );
_dos_settime( &newtime );
printf( “%s %s\n” , _strdate( datebuf ), _strtime( timebuf ) );
/* Restore old date and time */
_dos_setdate( &olddate );
_dos_settime( &oldtime );
}
12/15/99 18:26:09
07/04/99 03:45:30