typedef struct _DATETIME { /* date */ UCHAR hours; /* current hour */ UCHAR minutes; /* current minute */ UCHAR seconds; /* current second */ UCHAR hundredths; /* current hundredths of a second */ UCHAR day; /* current day */ UCHAR month; /* current month */ USHORT year; /* current year */ SHORT timezone; /* minutes of time west of UTC */ UCHAR weekday; /* current day of week */ } DATETIME; #define INCL_DOSDATETIME USHORT rc = DosSetDateTime(DateTime); PDATETIME DateTime; /* Date/time structure */ USHORT rc; /* return code */
Example
The following example obtains and prints date and time information. It then changes the system date to 5/10/1987 and prints the updated information.
#define INCL_DOSDATETIME #include <os2.h> main() { DATETIME DateTime; /* Structure to hold date/time info. */ USHORT rc; rc = DosGetDateTime(&DateTime); /* Address of d/t structure */ printf("Today is %d-%d-%d; the time is %d:%d\n", DateTime.month, DateTime.day, DateTime.year, DateTime.hours, DateTime.minutes); DateTime.day = 10; DateTime.month = 5; DateTime.year = 1987; printf("The new date is %d-%d-%d; the time is %d:%d\n", DateTime.month, DateTime.day, DateTime.year, DateTime.hours, DateTime.minutes); rc = DosSetDateTime(&DateTime); /* Address of d/t structure */ printf("rc is %d\n", rc); }