|
|
1.1 root 1: /*
2: * Example of DOSGETDATETIME & DOSSETDATETIME usage
3: *
4: * These calls are used to set and get the current system time.
5: * Also shows the structure of the information returned.
6: *
7: * - on an IBM AT, DOSSETDATETIME changes the hardware real time clock
8: * - the system sets the 'timezone' value to -1 by default
9: *
10: * Compile as: cl -AL -G2 -Lp datetime.c
11: *
12: * Copyright (C) Microsoft Corp. 1986
13: */
14:
15: #include <doscalls.h>
16:
17: main()
18: {
19: struct DateTime curdt, newdt, setdt;
20:
21: /* Read current date and time */
22: DOSGETDATETIME(&curdt);
23:
24: /* Print date and time */
25: printf("TIME: %d:%02d:%02d.%02d DATE: %d/%d/%d DAY OF WEEK: %d\n",
26: curdt.hour,curdt.minutes,curdt.seconds,curdt.hundredths,
27: curdt.month,curdt.day,curdt.year,curdt.day_of_week);
28: /* NOTE: the system sets the 'timezone' value to -1 by default */
29: printf("GMT = local_time %+d minutes\n",curdt.timezone);
30:
31:
32: /* Set datetime struct to Thursday 12/25/86, 9:02:45.01pm PST */
33: setdt.hour = 21; /* Time is in 24 hour format */
34: setdt.minutes = 2;
35: setdt.seconds = 45;
36: setdt.hundredths = 1;
37: setdt.day = 25;
38: setdt.month = 12;
39: setdt.year = 1986; /* Year should include the century */
40: setdt.timezone = 480; /* PST is 8 hours after GMT (480 minutes) */
41:
42: /* Set system date and time */
43: DOSSETDATETIME(&setdt);
44:
45: /* Read new date and time just set */
46: DOSGETDATETIME(&newdt);
47:
48: /* Print date and time */
49: printf("TIME: %d:%02d:%02d.%02d DATE: %d/%d/%d DAY OF WEEK: %d\n",
50: newdt.hour,newdt.minutes,newdt.seconds,newdt.hundredths,
51: newdt.month,newdt.day,newdt.year,newdt.day_of_week);
52: printf("GMT = local_time %+d minutes\n",newdt.timezone);
53:
54: /* Reset date and time to whatever was read at the beginning */
55: DOSSETDATETIME(&curdt);
56: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.