This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/settime.c

30 lines
840 B
C

#include <stdio.h>
#include <dos.h>
void main()
{
struct dosdate_t date;
struct dostime_t time;
/* Get and display the current date and time */
_dos_getdate( &date );
_dos_gettime( &time );
printf( "The date (MM-DD-YYYY) is: %d-%d-%d\n",
date.month, date.day, date.year );
printf( "The time (HH:MM:SS) is: %.2d:%.2d:%.2d\n",
time.hour, time.minute, time.second );
/* Change it to the turn of the century */
date.year = 1999;
date.month = 12;
date.day = 31;
time.hour = 23;
time.minute = 59;
_dos_setdate( &date );
_dos_settime( &time );
printf( "New date (MM-DD-YYYY) is: %d-%d-%d\n",
date.month, date.day, date.year );
printf( "New time (HH:MM:SS) is: %.2d:%.2d:%.2d\n",
time.hour, time.minute, time.second );
}