DosGetDateTime: Difference between revisions
Appearance
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
==DosGetDateTime== | ==DosGetDateTime== | ||
;DosGetDateTime(pdtm) : Get the current date and time. | ;DosGetDateTime(pdtm) : Get the current date and time. | ||
=== Syntax=== | |||
rc = DosGetDateTime( pdtm ); | |||
=== Parameters === | === Parameters === | ||
Line 9: | Line 12: | ||
=== Returns === | === Returns === | ||
This function returns an [[OS2 API:DataType:APIRET|APIRET]] with no values. | This function returns an [[OS2 API:DataType:APIRET|APIRET]] with no values. | ||
APIRET rc | |||
0 NO_ERROR | |||
=== Module === | === Module === | ||
Line 22: | Line 28: | ||
=== Calling conversion === | === Calling conversion === | ||
=== Relevant Structures === | |||
typedef struct _DATETIME | |||
{ | |||
UCHAR hours; /* 0..23 */ | |||
UCHAR minutes; /* 0..59 */ | |||
UCHAR seconds; /* 0..59 */ | |||
UCHAR hundredths; /* 0..99, 1/100 s */ | |||
UCHAR day; /* 0..31 */ | |||
UCHAR month; /* 0..12 */ | |||
USHORT year; | |||
SHORT timezone; /* Difference in minutes between current time zone */ | |||
/* and GMT. >0 = west of Greenwich, -1 = undefined */ | |||
/* time zone. */ | |||
UCHAR weekday; /* 0..6 0=Sunday */ | |||
} DATETIME, *PDATETIME; | |||
=== Gotchas=== | |||
The sign of the time zone is opposed to that ordinary used. Ie GMT+1 (Western Europe) <=> -60 | |||
=== Example Code === | === Example Code === | ||
Line 32: | Line 57: | ||
rc = DosGetDateTime (pdtm); | rc = DosGetDateTime (pdtm); | ||
... | ... | ||
=== Sample Code=== | |||
#define INCL_DOSDATETIME | |||
#include <os2.h> | |||
#include <stdio.h> /* For printf */ | |||
DATETIME dt; | |||
APIRET rc; | |||
rc=DosGetDateTime(&dt); /* Get current time and date */ | |||
printf("The time is %d:%d:%d\n", | |||
(short)dt.hours, | |||
(short)dt.minutes, | |||
(short)dt.seconds); | |||
=== Related Functions === | === Related Functions === |
Revision as of 18:52, 29 June 2012
DosGetDateTime
- DosGetDateTime(pdtm)
- Get the current date and time.
Syntax
rc = DosGetDateTime( pdtm );
Parameters
- pdtm - PDATETIME - input
- Pointer to a DATETIME structure where the date and time information is to be stored.
Constants
Returns
This function returns an APIRET with no values.
APIRET rc 0 NO_ERROR
Module
Define (C/C++)
#define INCL_DOSDATETIME #include <os2.h>
Export name/Ordinal
DosGetDateTime. DOSCALLS.DLL 230.
Calling conversion
Relevant Structures
typedef struct _DATETIME { UCHAR hours; /* 0..23 */ UCHAR minutes; /* 0..59 */ UCHAR seconds; /* 0..59 */ UCHAR hundredths; /* 0..99, 1/100 s */ UCHAR day; /* 0..31 */ UCHAR month; /* 0..12 */ USHORT year; SHORT timezone; /* Difference in minutes between current time zone */ /* and GMT. >0 = west of Greenwich, -1 = undefined */ /* time zone. */ UCHAR weekday; /* 0..6 0=Sunday */ } DATETIME, *PDATETIME;
Gotchas
The sign of the time zone is opposed to that ordinary used. Ie GMT+1 (Western Europe) <=> -60
Example Code
... PDATETIME pdtm; DATETIME dtm; APIRET rc; ... pdtm = &dtm; rc = DosGetDateTime (pdtm); ...
Sample Code
#define INCL_DOSDATETIME #include <os2.h> #include <stdio.h> /* For printf */ DATETIME dt; APIRET rc; rc=DosGetDateTime(&dt); /* Get current time and date */ printf("The time is %d:%d:%d\n", (short)dt.hours, (short)dt.minutes, (short)dt.seconds);
Related Functions
OS Version Introduced
OS/2 1.x