|
|
Microsoft OS/2 SDK 03-01-1988
/*
* Example of DosGetDateTime & DosSetDateTime usage
*
* These calls are used to set and get the current system time.
* Also shows the structure of the information returned.
*
* - on an IBM AT, DosSetDateTime changes the hardware real time clock
* - the system sets the 'timezone' value to -1 by default
*
* Compile as: cl -AL -G0 -Lp datetime.c
*
* Created by Microsoft Corp. 1986
*/
#define INCL_DOSDATETIME
#include <os2def.h>
#include <bsedos.h>
main()
{
DATETIME curdt, newdt, setdt;
/* Read current date and time */
DosGetDateTime(&curdt);
/* Print date and time */
printf("TIME: %d:%02d:%02d.%02d DATE: %d/%d/%d DAY OF WEEK: %d\n",
curdt.hours,curdt.minutes,curdt.seconds,curdt.hundredths,
curdt.month,curdt.day,curdt.year,curdt.weekday);
/* NOTE: the system sets the 'timezone' value to -1 by default */
printf("GMT = local_time %+d minutes\n",curdt.timezone);
/* Set datetime struct to Thursday 12/25/86, 9:02:45.01pm PST */
setdt.hours = 21; /* Time is in 24 hour format */
setdt.minutes = 2;
setdt.seconds = 45;
setdt.hundredths = 1;
setdt.day = 25;
setdt.month = 12;
setdt.year = 1986; /* Year should include the century */
setdt.timezone = 480; /* PST is 8 hours after GMT (480 minutes) */
/* Set system date and time */
DosSetDateTime(&setdt);
/* Read new date and time just set */
DosGetDateTime(&newdt);
/* Print date and time */
printf("TIME: %d:%02d:%02d.%02d DATE: %d/%d/%d DAY OF WEEK: %d\n",
newdt.hours,newdt.minutes,newdt.seconds,newdt.hundredths,
newdt.month,newdt.day,newdt.year,newdt.weekday);
printf("GMT = local_time %+d minutes\n",newdt.timezone);
/* Reset date and time to whatever was read at the beginning */
DosSetDateTime(&curdt);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.