getdate, _dos_getdate, _dos_setdate, setdate
Gets and sets system date.
Defined in header <dos.h>
Syntax
#include <dos.h>
void getdate(struct date *datep);
void _dos_getdate(struct dosdatet *datep);
void setdate(struct date *datep);
unsigned _dos_setdate(struct dosdate_t *datep);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
getdate fills in the date structure (pointed to by datep) with the system's current date.
setdate sets the system date (month, day, and year) to that in the date structure pointed to by datep.
The date structure is defined as follows:
struct date {
| int da_year; | /* current year */ |
| char da_day; | /* day of the month */ |
| char da_mon; }; _dos_getdate fills in the dosdate_t structure (pointed to by datep) with the system's current date. | /* month (1 = Jan) */ |
The dosdate_t structure is defined as follows:
struct dosdate_t {
| unsigned char day; | /* 1-31 */ |
| unsigned char month; | /* 1-12 */ |
| unsigned int year; | /* 1980 - 2099 */ |
unsigned char dayofweek; /* 0 - 6 (0=Sunday) */ };
Return value
_dos_getdate, getdate, and setdate, do not return a value.
If the date is set successfully, _dos_setdate returns 0. Otherwise, it returns a non-zero value and the global variable errno is set to the following:
EINVAL Invalid date
See also
Example
Unclude <dos.h>
iinclude <process.h>
#include <stdio.h>
int main(void)
{
struct dosdate_t reset;
reset.year = 2001;
reset.day = 1;
reset.month = 1;
printf ("Setting date to 1/1/2001.\n");
_dos_setdate (&reset);
_dos_getdate(&reset) ;
printf ("The new year is: %d\n", reset.year);
printf ("The new.day is: %d\n", reset.day);
printf("The new month is: %d\n", reset.month)
return 0;
}
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/dos.h/getdate/
· short form /3.1/getdate/