_dos_setdate

Description

Sets the current system date, using system call 0x2B.

#include <dos.h>

unsigned _dos_setdate( struct _dosdate_t *date );

date New system date  

Remarks

The _dos_setdate routine uses system call 0x2B to set the current system date. The date is stored in the _dosdate_t structure pointed to by date, defined in DOS.H. The _dosdate_t structure contains the following elements:

Element Description

unsigned char day 1–31
unsigned char month 1–12
unsigned int year 1980–2099
unsigned char dayofweek 0–6 (0 = Sunday)

Return Value

If successful, the function returns 0. Otherwise, it returns a nonzero value and sets errno to EINVAL, indicating an invalid date was specified.

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

_dos_getdate, _dos_gettime, _dos_settime, gmtime, localtime, mktime, _strdate, _strtime, time

Example

/* 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 );

}

Output

12/15/99 18:26:09

07/04/99 03:45:30