en:docs:fapi:dosgetdatetime

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:docs:fapi:dosgetdatetime [2021/08/20 03:44] prokusheven:docs:fapi:dosgetdatetime [2021/12/05 09:57] (current) prokushev
Line 5: Line 5:
 This call gets the current date and time maintained by the operating system.  This call gets the current date and time maintained by the operating system. 
  
-==Syntax== +===== Syntax =====
- DosGetDateTime (DateTime)+
  
-==Parameters== +<code c> 
-;DateTime (PDATETIME) - output : Address of the date and time structure: +DosGetDateTime (DateTime) 
-::hours (UCHAR) - Current hour +</code> 
-::minutes (UCHAR) - Current minute + 
-::seconds (UCHAR) - Current second +===== Parameters ===== 
-::hundredths (UCHAR) - Current hundredth of a second + 
-::day (UCHAR) - Current day +  DateTime ([[PDATETIME]]) - output : Address of the date and time structure: 
-::month (UCHAR) - Current month +    hours ([[UCHAR]]) - Current hour 
-::year (USHORT) - Current year +    minutes ([[UCHAR]]) - Current minute 
-::timezone (SHORT) - Minutes west of UTC (Universal Time Coordinate) +    seconds ([[UCHAR]]) - Current second 
-::weekday (UCHAR) - Current day of the week. Sunday is 0.+    hundredths ([[UCHAR]]) - Current hundredth of a second 
 +    day ([[UCHAR]]) - Current day 
 +    month ([[UCHAR]]) - Current month 
 +    year ([[USHORT]]) - Current year 
 +    timezone ([[SHORT]]) - Minutes west of UTC (Universal Time Coordinate) 
 +    weekday ([[UCHAR]]) - Current day of the week. Sunday is 0. 
 + 
 +===== Return Code ===== 
 + 
 +rc ([[USHORT]]) - return
  
-==Return Code== 
- rc (USHORT) - return 
 Return code description is: Return code description is:
-* 0  NO_ERROR 
  
-==Remarks==+  * 0  NO_ERROR 
 + 
 +===== Remarks ===== 
 The dayofweek value is based on Sunday equal to zero. The value of timezone is the difference in minutes between the current time zone and UTC. This number is positive if it is earlier than UTC and negative if it is later than UTC. For Eastern Standard Time, this value is 300 (5 hours earlier than UTC). The dayofweek value is based on Sunday equal to zero. The value of timezone is the difference in minutes between the current time zone and UTC. This number is positive if it is earlier than UTC and negative if it is later than UTC. For Eastern Standard Time, this value is 300 (5 hours earlier than UTC).
  
-If the application is executing in the OS/2 environment, it is more efficient to obtain these variables by calling DosGetInfoSeg instead of this function. However, applications written to the family API cannot depend on the availability of DosGetInfoSeg. +If the application is executing in the OS/2 environment, it is more efficient to obtain these variables by calling [[DosGetInfoSeg]] instead of this function. However, applications written to the family API cannot depend on the availability of DosGetInfoSeg.  
 + 
 +===== Example Code =====
  
-==Example Code== +==== C Binding ====
-===C Binding===+
  
 +<code c>
   typedef struct _DATETIME {  /* date */   typedef struct _DATETIME {  /* date */
     UCHAR   hours;            /* current hour */     UCHAR   hours;            /* current hour */
Line 50: Line 60:
   PDATETIME DateTime;      /* Address of date/time structure (returned) */   PDATETIME DateTime;      /* Address of date/time structure (returned) */
   USHORT    rc;            /* return code */   USHORT    rc;            /* return code */
 +
 +</code>
  
 This example gets the current time and date. This example gets the current time and date.
  
 +<code c>
   #define INCL_DOSDATETIME   #define INCL_DOSDATETIME
      
Line 59: Line 72:
      
   rc = DosGetDateTime(&DateBuffer);        /* Date/Time structure */   rc = DosGetDateTime(&DateBuffer);        /* Date/Time structure */
 +</code>
  
 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. 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.
  
 +<code c>
   #define INCL_DOSDATETIME   #define INCL_DOSDATETIME
   #include <os2.h>   #include <os2.h>
Line 81: Line 96:
     printf("rc is %d\n", rc);     printf("rc is %d\n", rc);
    }    }
 +</code>
  
-===MASM Binding===+==== MASM Binding ====
  
 +<code asm>
   DATETIME struc   DATETIME struc
     date_hours      db  ? ;current hour     date_hours      db  ? ;current hour
Line 101: Line 118:
   PUSH@  OTHER   DateTime      ;Date/time structure (returned)   PUSH@  OTHER   DateTime      ;Date/time structure (returned)
   CALL   DosGetDateTime   CALL   DosGetDateTime
 +</code>
  
 Returns WORD Returns WORD
  
- +===== Note =====
-====== Note ======+
  
 Text based on [[http://www.edm2.com/index.php/DosGetDateTime_(Legacy)]] Text based on [[http://www.edm2.com/index.php/DosGetDateTime_(Legacy)]]