Jump to content

DosGetDateTime: Difference between revisions

From EDM2
Ak120 (talk | contribs)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==DosGetDateTime==
'''DosGetDateTime''' gets the current date and time.  
;DosGetDateTime(pdtm) : Get the current date and time.  


=== Syntax===  
== Syntax==
rc = DosGetDateTime( pdtm );
DosGetDateTime ( pdtm )


=== Parameters ===
== Parameters ==
; pdtm - [[OS2 API:DataType:PDATETIME|PDATETIME]] - input : Pointer to a [[OS2 API:DataType:DATETIME|DATETIME]] structure where the date and time information is to be stored.
;pdtm - [[PDATETIME]] - input: Pointer to a [[DATETIME]] structure where the date and time information is to be stored.
 
=== Constants ===
 
=== Returns ===
This function returns an [[OS2 API:DataType:APIRET|APIRET]] with no values.


== Returns ==
This function returns an [[APIRET]] with no values.
  APIRET  rc
  APIRET  rc
  0      NO_ERROR
  0      NO_ERROR


=== Module ===
== Define (C/C++) ==
 
 
=== Define (C/C++) ===
  #define INCL_DOSDATETIME
  #define INCL_DOSDATETIME
  #include <os2.h>
  #include <os2.h>


=== Export name/Ordinal ===
== Export name/Ordinal ==
DosGetDateTime. DOSCALLS.DLL 230.
  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===  
== Gotchas==
The sign of the time zone is opposed to that ordinary used. Ie GMT+1 (Western Europe) <=> -60  
The sign of the time zone is opposed to that ordinary used. Ie GMT+1 (Western Europe) <=> -60  


=== Example Code ===
== Sample Code==
...
<code>
  [[OS2 API:DataType:PDATETIME|PDATETIME]] pdtm;
  PDATETIME  pdtm;
  [[OS2 API:DataType:DATETIME|DATETIME]]   dtm;
  DATETIME  dtm;
  [[OS2 API:DataType:APIRET|APIRET]]     rc;
  APIRET    rc;
  ...
  ...
  pdtm = &dtm;
  pdtm = &dtm;
  rc = DosGetDateTime (pdtm);
  rc = DosGetDateTime (pdtm);
...


=== Sample Code===
  #define INCL_DOSDATETIME  
  #define INCL_DOSDATETIME  
  #include <os2.h>  
  #include <os2.h>  
Line 72: Line 44:
       (short)dt.minutes,  
       (short)dt.minutes,  
       (short)dt.seconds);
       (short)dt.seconds);
</code>


=== Related Functions ===
== Related Functions ==
[[OS2 API:CPI:DosSetDateTime|DosSetDateTime]]
*[[DosSetDateTime]]
 
=== OS Version Introduced ===
OS/2 1.x
 
[[Category:The OS/2 API Project]]
 
==Alternative Version==
# OS2Linux project (Common Public License) created a clone for this function [https://github.com/OS2World/LINUX-SYSTEM-OS2Linux/blob/1eaffacb404b31b79068582ef8bf4d7583c8fa8d/os2/datetime.c].
 
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 11:24, 12 October 2018

DosGetDateTime gets the current date and time.

Syntax

DosGetDateTime ( pdtm )

Parameters

pdtm - PDATETIME - input
Pointer to a DATETIME structure where the date and time information is to be stored.

Returns

This function returns an APIRET with no values.

APIRET  rc
0       NO_ERROR

Define (C/C++)

#define INCL_DOSDATETIME
#include <os2.h>

Export name/Ordinal

DOSCALLS.DLL 230.

Gotchas

The sign of the time zone is opposed to that ordinary used. Ie GMT+1 (Western Europe) <=> -60

Sample Code

PDATETIME  pdtm;
DATETIME   dtm;
APIRET     rc;
...
pdtm = &dtm;
rc = DosGetDateTime (pdtm);
#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